Clean up worker tests after Repository based right removal
Apparently I missed some things in !2347 (merged), at least in test_workers.py
e.g.
def test_workers_retrieve_repository(self):
"""
A user can retrieve a worker by having contributor access on its repository
"""
repo2 = Repository.objects.create(
url="http://gitlab/repo2"
)
worker_2 = repo2.workers.create(name="Worker 2", slug="worker_2", type=self.worker_type_dla)
repo2.memberships.create(user=self.user, level=Role.Contributor.value)
self.client.force_login(self.user)
with self.assertNumQueries(3):
response = self.client.get(reverse("api:worker-retrieve", kwargs={"pk": str(worker_2.id)}))
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertDictEqual(response.json(), {
"id": str(worker_2.id),
"repository_id": str(repo2.id),
"name": "Worker 2",
"description": "",
"slug": "worker_2",
"type": "dla",
"archived": False,
})
or
@patch("arkindex.users.managers.BaseACLManager.filter_rights")
def test_workers_retrieve_no_rights(self, filter_rights_mock):
filter_rights_mock.side_effect = [
Worker.objects.none(),
Repository.objects.none(),
]
self.client.force_login(self.user)
with self.assertNumQueries(3):
response = self.client.get(reverse("api:worker-retrieve", kwargs={"pk": str(self.worker_reco.id)}))
self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND)
self.assertEqual(response.json(), {"detail": "No Worker matches the given query."})
self.assertListEqual(filter_rights_mock.call_args_list, [
call(self.user, Worker, Role.Contributor.value),
call(self.user, Repository, Role.Contributor.value),
])
which actually I don't understand passes ... I feel like it should be broken