Private
Public Access
1
0

added a test

This commit is contained in:
2025-01-05 14:30:11 +01:00
parent 6cdce7c515
commit 7a8271ca95
8 changed files with 91 additions and 82 deletions

View File

@@ -34,26 +34,7 @@
</p>
</li>
<li class="grid_2">
<h1>Facebook Group</h1>
<p>We run a facebook group where you can post questions and report problems,
especially if you think the wider user community benefits from the answers.</p>
<ul>
<li><a href="https://www.facebook.com/groups/rowsandall/">https://www.facebook.com/groups/rowsandall/</a></li>
</ul>
</li>
<li class="grid_2">
<h1>Twitter</h1>
<p>You can also check me on Twitter:
<ul>
<li><a href="https://twitter.com/rowsandall">https://twitter.com/rowsandall</a>
</ul>
When the site is down, this is the appropriate channel to look for apologies, updates, and offer help.
</p>
</li>
<li class="grid_2">
<h1>Rowsandall s.r.o.</h1>

View File

@@ -110,12 +110,6 @@
</li>
</ul>
<p class="midden">
<a class="twitter-follow-button"
href="https://twitter.com/rowsandall">
Follow @rowsandall</a>
</p>
<p class="midden">
Local Time: {% now "jS F Y H:i" %}

View File

@@ -23,6 +23,59 @@ from django.utils.crypto import get_random_string
from django.http.response import Http404
@override_settings(TESTING=True)
class PlanStepTest(TestCase):
def setUp(self):
self.u = UserFactory()
self.r = Rower.objects.create(user=self.u,
birthdate=faker.profile()['birthdate'],
gdproptin=True, ftpset=True,surveydone=True,
gdproptindate=timezone.now(),
rowerplan='pro', eurocredits=100)
self.c = Client()
self.user_workouts = WorkoutFactory.create_batch(5, user=self.r)
self.factory = RequestFactory()
self.password = faker.word()
self.u.set_password(self.password)
self.u.save()
def tearDown(self):
for workout in self.user_workouts:
try:
os.remove(workout.csvfilename)
except (IOError, FileNotFoundError,OSError):
pass
def test_createplannedsession(self):
ps = PlannedSession(
startdate=nu.date(),
enddate=(nu+datetime.timedelta(days=1)).date(),
sessiontype='session',
sessionmode = 'time',
preferreddate=nu.date(),
sessionvalue = 60,
sessionunit='min',
manager=self.u,
sessionsport='water',
criterium='none',
interval_string='4x(5min@20spm+5min@22spm)',
name='test',
)
ps.save()
ps.rower.add(self.r)
self.assertEqual(ps.rower.count(),1)
steps = ps.steps
self.assertEqual(len(steps['steps']),3)
s = ps.steps_intervals()
expected = '\n\n4x\n- 300s 20rpm Active 0\n- 300s 22rpm Active 1\n\n'
self.assertEqual(s,expected)
@override_settings(TESTING=True)
class TrainingPlanTest(TestCase):
def setUp(self):
@@ -33,7 +86,7 @@ class TrainingPlanTest(TestCase):
gdproptin=True, ftpset=True,surveydone=True,
defaulttimezone='US/Pacific',
gdproptindate=timezone.now(),
rowerplan='pro')
rowerplan='pro', eurocredits=100)
self.c = Client()
self.user_workouts = WorkoutFactory.create_batch(5, user=self.r)
@@ -200,7 +253,7 @@ class SessionTemplateTest(TestCase):
birthdate=faker.profile()['birthdate'],
gdproptin=True, ftpset=True,surveydone=True,
gdproptindate=timezone.now(),
rowerplan='pro')
rowerplan='pro', eurocredits=100)
self.c = Client()
self.user_workouts = WorkoutFactory.create_batch(5, user=self.r)
@@ -551,7 +604,7 @@ class SessionCompleteTest(TestCase):
birthdate=faker.profile()['birthdate'],
gdproptin=True, ftpset=True,surveydone=True,
gdproptindate=timezone.now(),
rowerplan='pro')
rowerplan='pro', eurocredits=100)
self.c = Client()
@@ -1246,7 +1299,7 @@ class PlannedSessionsView(TestCase):
gdproptin=True, ftpset=True,surveydone=True,
gdproptindate=timezone.now(),
defaulttimezone='US/Pacific',
rowerplan='pro')
rowerplan='pro', eurocredits=100)
self.r.save()
self.c = Client()
@@ -1671,6 +1724,10 @@ description: ""
response = self.c.get(url,follow=True)
self.assertEqual(response.status_code,200)
# count number of PlannedSession objects for self.r
ps = PlannedSession.objects.filter(rower__in=[self.r])
self.assertEqual(ps.count(),5)
def test_clone_view(self):
login = self.c.login(username=self.u.username, password=self.password)
self.assertTrue(login)
@@ -2336,3 +2393,32 @@ description: ""
response = self.c.post(url,form_data,follow=True)
self.assertEqual(response.status_code,200)
# add a plan
url = reverse('rower_view_instantplan', kwargs={'id':self.instantplan.uuid})
response = self.c.get(url)
self.assertEqual(response.status_code,200)
form_data = {
'name': 'Test Plan',
'startdate':datetime.datetime.now().strftime('%Y-%m-%d'),
'enddate':(datetime.datetime.now()+datetime.timedelta(days=self.instantplan.duration)).strftime('%Y-%m-%d'),
'plan_past_days': False,
'datechoice':'startdate',
'notes': faker.word(),
'byrscore': False,
'target': '',
}
form = InstantPlanSelectForm(form_data)
self.assertTrue(form.is_valid())
form = PlanByRscoreForm(form_data)
self.assertTrue(form.is_valid())
# post the form to url
response = self.c.post(url,form_data,follow=True)
self.assertEqual(response.status_code,200)
# check the number of PlannedSession objects
ps = PlannedSession.objects.filter(rower__in=[self.r])
self.assertEqual(ps.count(),5)

Binary file not shown.

View File

@@ -2060,6 +2060,7 @@ def plannedsession_tointervals_view(request, id=0):
startdate, enddate = get_dates_timeperiod(request)
startdate = startdate.date()
enddate = enddate.date()
ps = get_object_or_404(PlannedSession, pk=id)