From 57db2dc262f0fa936d1587ce7151534c087fde0d Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Fri, 25 Jan 2019 11:12:18 +0100 Subject: [PATCH] test create target & trainingplan --- rowers/admin.py | 7 ++- rowers/tests/test_plans.py | 70 ++++++++++++++++++++++++++ rowers/tests/testdata/testdata.csv.gz | Bin 11426 -> 11426 bytes rowers/tests/testdata/testdata.tcx | 2 +- 4 files changed, 77 insertions(+), 2 deletions(-) diff --git a/rowers/admin.py b/rowers/admin.py index 5be9aa7f..4c2c861c 100644 --- a/rowers/admin.py +++ b/rowers/admin.py @@ -7,7 +7,7 @@ from .models import ( Team,TeamInvite,TeamRequest, WorkoutComment,C2WorldClassAgePerformance,PlannedSession, GeoCourse,GeoPolygon,GeoPoint,VirtualRace,VirtualRaceResult, - PaidPlan + PaidPlan,IndoorVirtualRaceResult, ) # Register your models here so you can use them in the Admin module @@ -123,6 +123,10 @@ class VirtualRaceResultAdmin(admin.ModelAdmin): list_display = ('race','userid','username','boattype','age','weightcategory') search_fields = ['race__name','username'] +class IndoorVirtualRaceResultAdmin(admin.ModelAdmin): + list_display = ('race','userid','username','boatclass','age','weightcategory') + search_fields = ['race__name','username'] + class PaidPlanAdmin(admin.ModelAdmin): list_display = ('name','shortname','price','paymenttype','paymentprocessor','clubsize','external_id') @@ -142,4 +146,5 @@ admin.site.register(PlannedSession,PlannedSessionAdmin) admin.site.register(GeoCourse, GeoCourseAdmin) admin.site.register(VirtualRace, VirtualRaceAdmin) admin.site.register(VirtualRaceResult, VirtualRaceResultAdmin) +admin.site.register(IndoorVirtualRaceResult, IndoorVirtualRaceResultAdmin) admin.site.register(PaidPlan,PaidPlanAdmin) diff --git a/rowers/tests/test_plans.py b/rowers/tests/test_plans.py index de2fce3d..2f031554 100644 --- a/rowers/tests/test_plans.py +++ b/rowers/tests/test_plans.py @@ -1,3 +1,73 @@ #from __future__ import print_function from statements import * nu = datetime.datetime.now() + +class PlannedSessionsTest(TestCase): + def setUp(self): + self.u = UserFactory() + + self.r = Rower.objects.create(user=self.u, + birthdate=faker.profile()['birthdate'], + gdproptin=True, + gdproptindate=timezone.now(), + rowerplan='coach') + + 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, WindowsError): + pass + + def test_createplan(self): + login = self.c.login(username=self.u.username, password=self.password) + self.assertTrue(login) + + url = '/rowers/createplan/' + response = self.c.get(url) + self.assertEqual(response.status_code,200) + + # add target + + targetdate = (nu+datetime.timedelta(days=300)) + + form_data = { + 'name': faker.word(), + 'date': targetdate.strftime("%Y-%m-%d"), + 'notes': faker.text(), + } + + targetform = TrainingTargetForm(form_data,user=self.u) + self.assertTrue(targetform.is_valid()) + + response = self.c.post(url,form_data) + self.assertEqual(response.status_code,200) + + form_data = { + 'name': faker.word(), + 'target': '1', + 'startdate': nu.strftime("%Y-%m-%d"), + 'enddate': targetdate.strftime("%Y-%m-%d"), + 'active': True, + } + + newplanform = TrainingPlanForm(form_data,user=self.u) + self.assertTrue(newplanform.is_valid()) + + response = self.c.post(url,form_data) + self.assertEqual(response.status_code,200) + + urlplan = '/rowers/plan/1/' + response = self.c.get(url) + self.assertEqual(response.status_code,200) + + + + diff --git a/rowers/tests/testdata/testdata.csv.gz b/rowers/tests/testdata/testdata.csv.gz index 2e2d805425a0bf5ea66550fc611bb87eb936d398..045ae87e5dafbe2897ba670b5e347028f3513399 100644 GIT binary patch delta 15 WcmZ1!xhRrNzMF&N|Lu)zb94YO9|jNr delta 15 WcmZ1!xhRrNzMF$1W79^qIXVC<$OTXU diff --git a/rowers/tests/testdata/testdata.tcx b/rowers/tests/testdata/testdata.tcx index 439615e4..16f58ea9 100644 --- a/rowers/tests/testdata/testdata.tcx +++ b/rowers/tests/testdata/testdata.tcx @@ -2502,7 +2502,7 @@ - <Element 'Notes' at 0x13918240> + <Element 'Notes' at 0x13065cf8>