150 lines
4.8 KiB
Python
150 lines
4.8 KiB
Python
from statements import *
|
|
from django.utils import timezone
|
|
nu = datetime.datetime.now(tz=timezone.utc)
|
|
|
|
# set up
|
|
|
|
import rowers.teams as teams
|
|
import rowers.plannedsessions as plannedsessions
|
|
|
|
|
|
@override_settings(TESTING=True)
|
|
class PermissionsBasicsTests(TestCase):
|
|
def setUp:
|
|
self.c = Client()
|
|
## Users - Pro, Basic, Coach & Self Coach
|
|
|
|
self.ucoach = UserFactory(username='coachuser')
|
|
self.rcoach = Rower.objects.create(user=self.ucoach,
|
|
birthdate=faker.profile()['birthdate'],
|
|
gdproptin=True,gdproptindate=timezone.now(),
|
|
rowerplan='coach')
|
|
|
|
self.ucoach_workouts = WorkoutFactory.create_batch(5, user=self.rcoach)
|
|
self.factory = RequestFactory()
|
|
self.password = faker.word()
|
|
self.ucoach.set_password(self.password)
|
|
self.ucoach.save()
|
|
|
|
self.uplan = UserFactory(username='planuser')
|
|
self.rplan = Rower.objects.create(user=self.uplan,
|
|
birthdate=faker.profile()['birthdate'],
|
|
gdproptin=True,gdproptindate=timezone.now(),
|
|
rowerplan='plan')
|
|
|
|
self.uselfplan_workouts = WorkoutFactory.create_batch(5, user=self.rselfplan)
|
|
self.factory = RequestFactory()
|
|
self.password = faker.word()
|
|
self.uselfplan.set_password(self.password)
|
|
self.uselfplan.save()
|
|
|
|
self.upro = UserFactory(username='prouser')
|
|
self.rpro = Rower.objects.create(user=self.upro,
|
|
birthdate=faker.profile()['birthdate'],
|
|
gdproptin=True,gdproptindate=timezone.now(),
|
|
rowerplan='pro')
|
|
|
|
self.upro_workouts = WorkoutFactory.create_batch(5, user=self.rpro)
|
|
self.factory = RequestFactory()
|
|
self.password = faker.word()
|
|
self.upro.set_password(self.password)
|
|
self.upro.save()
|
|
|
|
self.ubasic = UserFactory(username='basicuser')
|
|
self.rbasic = Rower.objects.create(user=self.ubasic,
|
|
birthdate=faker.profile()['birthdate'],
|
|
gdproptin=True,gdproptindate=timezone.now(),
|
|
rowerplan='basic')
|
|
|
|
self.ubasic_workouts = WorkoutFactory.create_batch(5, user=self.rbasic)
|
|
self.factory = RequestFactory()
|
|
self.password = faker.word()
|
|
self.ubasic.set_password(self.password)
|
|
self.ubasic.save()
|
|
|
|
|
|
|
|
## TeamPro, TeamCoach, TeamSelfCoach
|
|
|
|
# Requirements
|
|
|
|
## Low level
|
|
|
|
## Coach can have any number of groups
|
|
|
|
## Basic athletes can be member of Coach led group
|
|
|
|
## Coach can create planned sessions and team planned sessions
|
|
|
|
## Self coach can create one group
|
|
|
|
## Self coach cannot create more than one group
|
|
|
|
## Pro users (and higher) can join group led by other Pro (or higher) user
|
|
|
|
## Self Coach can create planned sessions and team planned sessions
|
|
|
|
## Pro can have one group
|
|
|
|
## Pro cannot create more than one group
|
|
|
|
## Pro cannot create planned sessions or team planned sessions
|
|
|
|
## Basic cannot join groups led by Pro or Self Coach
|
|
|
|
## Basic can join group led by Coach
|
|
|
|
## Basic cannot manage a group
|
|
def test_basic_groupmanager(self):
|
|
self.assertRaises ...
|
|
|
|
# View based
|
|
|
|
## Coach can have any number of groups
|
|
|
|
## Basic athletes can be member of Coach led group
|
|
|
|
## Coach can create planned sessions and team planned sessions
|
|
|
|
## Coach can edit on behalf of athlete
|
|
|
|
## Coach can run analytics for athlete
|
|
|
|
## Coach can upload on behalf of athlete
|
|
|
|
## Coach can edit athlete's workout
|
|
|
|
## Self coach can create one group
|
|
|
|
## Self coach cannot create more than one group
|
|
|
|
## Pro users (and higher) can join group led by other Pro (or higher) user
|
|
|
|
## Self Coach can create planned sessions and team planned sessions
|
|
|
|
## Self Coach cannot edit on behalf of athlete
|
|
|
|
## Self Coach cannot run analytics on behalf of athlete
|
|
|
|
## Self Coach cannot upload on behalf of athlete
|
|
|
|
## Pro can have one group
|
|
|
|
## Pro cannot create more than one group
|
|
|
|
## Pro cannot create planned sessions or team planned sessions
|
|
|
|
## Pro can create planned sessions and team planned sessions
|
|
|
|
## Pro cannot edit on behalf of athlete
|
|
|
|
## Pro cannot run analytics on behalf of athlete
|
|
|
|
## Basic cannot join groups from Pro or Self Coach users (redirects to paid plans)
|
|
|
|
## Pro users can see team members' workout, but not edit
|
|
|
|
## Self Coach users can see team members' workout, but not edit
|
|
|
|
## Basic users can see team members' workout, but not edit
|