def it_fails_without_email(self, rf, inactive_user): request = rf.get('/resend_email/') request.user = inactive_user mock_messages(request) response = resend_email(request) assert response.status_code == 302 assert response.url == '/'
def it_doesnt_delete_with_bad_img_path(self, rf, avatar_user): with avatar_user.login(): request = rf.post('/profile/picture/remove/', {}) request.user = avatar_user mock_messages(request) response = remove_avatar(request) assert response.url == '/profile/picture/' assert avatar_user.avatar is not None
def it_doesnt_allow_delete_with_no_image(self, rf, active_user): with active_user.login(): request = rf.post('/profile/picture/remove/', {}) request.user = active_user mock_messages(request) response = remove_avatar(request) url = '/profile/view/{}/'.format(active_user.username) assert response.url == url
def it_allows_delete(self, rf, avatar_user): with avatar_user.login(): fake_image(avatar_user.avatar.path) request = rf.post('/profile/picture/remove/', {}) request.user = avatar_user mock_messages(request) response = remove_avatar(request) assert response.url == '/profile/picture/' assert not avatar_user.avatar
def it_allows_editing(self, rf, active_user): with active_user.login(): assert not active_user.avatar img = fake_image() request = rf.post('/profile/picture/', {'avatar': img}) request.user = active_user mock_messages(request) edit_avatar(request) assert active_user.avatar os.remove(img.path) os.remove(active_user.avatar.path)
def it_allows_editing(self, rf, active_user): with active_user.login(): request = rf.post('/profile/edit/', { 'email': active_user.email, 'username': '******', 'first_name': 'Test', 'last_name': 'User', }) request.user = active_user mock_messages(request) edit_profile(request) assert active_user.first_name == 'Test' assert active_user.last_name == 'User'