Commit ba32bd08 by Marko Jevtic

Fix test owner

parent 8e33ec52
...@@ -26,8 +26,8 @@ class PhotoVerificationStatusViewTests(TestCase): ...@@ -26,8 +26,8 @@ class PhotoVerificationStatusViewTests(TestCase):
def setUp(self): def setUp(self):
super(PhotoVerificationStatusViewTests, self).setUp() super(PhotoVerificationStatusViewTests, self).setUp()
self.user = UserFactory.create(password=self.PASSWORD) self.user = UserFactory(password=self.PASSWORD)
self.staff = UserFactory.create(is_staff=True, password=self.PASSWORD) self.staff = UserFactory(is_staff=True, password=self.PASSWORD)
self.verification = SoftwareSecurePhotoVerification.objects.create(user=self.user, status='submitted') self.verification = SoftwareSecurePhotoVerification.objects.create(user=self.user, status='submitted')
self.path = reverse('verification_status', kwargs={'username': self.user.username}) self.path = reverse('verification_status', kwargs={'username': self.user.username})
self.client.login(username=self.staff.username, password=self.PASSWORD) self.client.login(username=self.staff.username, password=self.PASSWORD)
...@@ -57,7 +57,7 @@ class PhotoVerificationStatusViewTests(TestCase): ...@@ -57,7 +57,7 @@ class PhotoVerificationStatusViewTests(TestCase):
def test_no_verifications(self): def test_no_verifications(self):
""" The endpoint should return HTTP 404 if the user has no verifications. """ """ The endpoint should return HTTP 404 if the user has no verifications. """
user = UserFactory.create() user = UserFactory()
path = reverse('verification_status', kwargs={'username': user.username}) path = reverse('verification_status', kwargs={'username': user.username})
self.assert_path_not_found(path) self.assert_path_not_found(path)
...@@ -69,17 +69,19 @@ class PhotoVerificationStatusViewTests(TestCase): ...@@ -69,17 +69,19 @@ class PhotoVerificationStatusViewTests(TestCase):
def test_staff_user(self): def test_staff_user(self):
""" The endpoint should be accessible to staff users. """ """ The endpoint should be accessible to staff users. """
self.client.logout()
self.client.login(username=self.staff.username, password=self.PASSWORD) self.client.login(username=self.staff.username, password=self.PASSWORD)
self.assert_verification_returned() self.assert_verification_returned()
def test_owner(self): def test_owner(self):
""" The endpoint should be accessible to the user who submitted the verification request. """ """ The endpoint should be accessible to the user who submitted the verification request. """
self.client.login(username=self.user.username, password=self.user.password) self.client.logout()
self.client.login(username=self.user.username, password=self.PASSWORD)
self.assert_verification_returned() self.assert_verification_returned()
def test_non_owner_or_staff_user(self): def test_non_owner_or_staff_user(self):
""" The endpoint should NOT be accessible if the request is not made by the submitter or staff user. """ """ The endpoint should NOT be accessible if the request is not made by the submitter or staff user. """
user = UserFactory.create() user = UserFactory()
self.client.login(username=user.username, password=self.PASSWORD) self.client.login(username=user.username, password=self.PASSWORD)
response = self.client.get(self.path) response = self.client.get(self.path)
self.assertEqual(response.status_code, 403) self.assertEqual(response.status_code, 403)
...@@ -88,5 +90,6 @@ class PhotoVerificationStatusViewTests(TestCase): ...@@ -88,5 +90,6 @@ class PhotoVerificationStatusViewTests(TestCase):
""" The endpoint should return that the user is verified if the user's verification is accepted. """ """ The endpoint should return that the user is verified if the user's verification is accepted. """
self.verification.status = 'approved' self.verification.status = 'approved'
self.verification.save() self.verification.save()
self.client.login(username=self.user.username, password=self.user.password) self.client.logout()
self.client.login(username=self.user.username, password=self.PASSWORD)
self.assert_verification_returned(verified=True) self.assert_verification_returned(verified=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment