Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TestDeleteRecognizedFood(SoloTeamCreatingTest, APITestCase):
- def setUp(self):
- super(TestDeleteRecognizedFood, self).setUp()
- self.recognizedfood = mommy.make('RecognizedFood', food_log_entry_item__user=self.user)
- def subject(self, email, password, recognizedfood_uuid=None):
- self.client.login(email=email, password=password)
- if not recognizedfood_uuid:
- recognizedfood_uuid = self.recognizedfood.uuid
- return self.client.delete(
- '/api/v4/recognized-foods/{}/'.format(recognizedfood_uuid),
- format='json',
- )
- def test_coach_can_delete(self):
- response = self.subject(self.coach_email, self.coach_password)
- self.assertEqual(response.status_code, 204)
- def test_user_can_delete(self):
- response = self.subject(self.user_email, self.user_password)
- self.assertEqual(response.status_code, 204)
- def test_given_unauthorized_user_returns_403(self):
- bad_user_password = '12345678'
- bad_user = mommy.make('accounts.User', password=bad_user_password)
- response = self.subject(bad_user.email, bad_user_password)
- self.assertEqual(response.status_code, 403)
- def test_given_unexisting_uuid_returns_404(self):
- response = self.subject(self.user_email, self.user_password, uuid.uuid4())
- self.assertEqual(response.status_code, 404)
Add Comment
Please, Sign In to add comment