Commit b1b02c4a authored by Bryan  BRANCOTTE's avatar Bryan BRANCOTTE
Browse files

test ensuring curators can edit mapping

Copying DataSourceRangeMappingEditTestCase.test_works onto DataSourceMappingEditTestCase.test_works to have same scenario to test
parent 877b3223
......@@ -1047,16 +1047,38 @@ class DataSourceDetailViewTestCase(ViewTestCase):
class DataSourceMappingEditTestCase(ViewTestCase):
def test_works(self):
url = reverse('viralhostrangedb:data-source-mapping-label-edit', args=[self.private_data_source_of_toto.pk])
url = reverse('viralhostrangedb:data-source-mapping-label-edit', args=[self.public_data_source_of_user.pk])
response = self.client.get(url)
self.assertRedirects(
response,
expected_url=reverse('basetheme_bootstrap:login') + "?next=" + url
)
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
self.client.force_login(self.toto)
self.assertEqual(self.client.get(url).status_code, 404)
self.private_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=False))
self.assertEqual(self.client.get(url).status_code, 404)
self.private_data_source_of_user.allowed_users.remove(self.toto)
self.private_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=True))
self.assertEqual(self.client.get(url).status_code, 404)
self.public_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=False))
self.assertEqual(self.client.get(url).status_code, 404)
self.public_data_source_of_user.allowed_users.remove(self.toto)
self.public_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=True))
self.assertEqual(self.client.get(url).status_code, 200)
self.public_data_source_of_user.allowed_users.remove(self.toto)
self.assertEqual(self.client.get(url).status_code, 404)
business_process.set_curator(self.toto, True)
self.assertEqual(self.client.get(url).status_code, 200)
business_process.set_curator(self.toto, True)
self.assertEqual(self.client.get(url).status_code, 404)
self.client.force_login(self.user)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
......@@ -1976,17 +1998,28 @@ class DataSourceRangeMappingEditTestCase(ViewTestCase):
)
self.client.force_login(self.toto)
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
self.assertEqual(self.client.get(url).status_code, 404)
self.private_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=False))
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
self.assertEqual(self.client.get(url).status_code, 404)
self.private_data_source_of_user.allowed_users.remove(self.toto)
self.private_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=True))
response = self.client.get(url)
self.assertEqual(response.status_code, 404)
self.assertEqual(self.client.get(url).status_code, 404)
self.public_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=False))
self.assertEqual(self.client.get(url).status_code, 404)
self.public_data_source_of_user.allowed_users.remove(self.toto)
self.public_data_source_of_user.allowed_users.add(self.toto, through_defaults=dict(can_write=True))
self.assertEqual(self.client.get(url).status_code, 200)
self.public_data_source_of_user.allowed_users.remove(self.toto)
self.assertEqual(self.client.get(url).status_code, 404)
business_process.set_curator(self.toto, True)
self.assertEqual(self.client.get(url).status_code, 200)
business_process.set_curator(self.toto, True)
self.assertEqual(self.client.get(url).status_code, 404)
self.client.force_login(self.user)
response = self.client.get(url)
......
Supports Markdown
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