Changeset 1d92bf2 in OpenWorkouts-current for ow/tests/views/test_root.py
- Timestamp:
- Dec 16, 2018, 1:07:04 AM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 6560b8f
- Parents:
- 929097a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/tests/views/test_root.py
r929097a r1d92bf2 20 20 21 21 @pytest.fixture 22 def root(self): 22 def john(self): 23 user = User(firstname='John', lastname='Doe', 24 email='john.doe@example.net') 25 user.password = 's3cr3t' 26 return user 27 28 @pytest.fixture 29 def root(self, john): 23 30 root = OpenWorkouts() 24 root['john'] = User(firstname='John', lastname='Doe', 25 email='john.doe@example.net') 26 root['john'].password = 's3cr3t' 31 root.add_user(john) 27 32 workout = Workout( 28 33 start=datetime(2015, 6, 28, 12, 55, tzinfo=timezone.utc), … … 30 35 distance=30, sport='cycling' 31 36 ) 32 root['john'].add_workout(workout)37 john.add_workout(workout) 33 38 return root 34 39 … … 50 55 return request 51 56 52 def test_user_list(self, get_request ):57 def test_user_list(self, get_request, john): 53 58 request = get_request 54 59 response = user_list(request.root, request) 55 assert list(response['users']) == [ request.root['john']]60 assert list(response['users']) == [john] 56 61 57 62 def test_add_user_get(self, get_request): … … 66 71 response = add_user(request.root, request) 67 72 assert 'form' in response 68 # All required fields ( 4) are marked in the form errors73 # All required fields (3) are marked in the form errors 69 74 # You can see which fields are required in the schema 70 75 # ow.schemas.user.UserAddSchema 71 assert len(response['form'].form.errors) == 4 76 errors = response['form'].form.errors 77 assert len(errors) == 3 78 assert 'email' in errors 79 assert 'firstname' in errors 80 assert 'lastname' in errors 72 81 73 82 def test_add_user_post_valid(self, post_request): 74 83 request = post_request 75 request.POST[' uid'] = 'addeduser'84 request.POST['nickname'] = 'addeduser' 76 85 request.POST['email'] = 'addeduser@example.net' 77 86 request.POST['firstname'] = 'added' … … 80 89 assert isinstance(response, HTTPFound) 81 90 assert response.location.endswith('/userlist') 82 assert len(request.root.all_usernames()) == 2 83 assert 'addeduser' in request.root.all_usernames() 91 # 1 nick name, as the default user has no nickname 92 assert len(request.root.all_nicknames) == 1 93 assert 'addeduser' in request.root.all_nicknames
Note: See TracChangeset
for help on using the changeset viewer.