Skip to content
Snippets Groups Projects
Verified Commit d7d3f46c authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Rename ou endpoint and attribute on sponsor

- OU endpoints changed from orgunit/ to orgunits/.
- OU attribute on objects from sponsor endpoint changed from units to
  orgunits.

Resolves: GREG-124
parent dbe6db61
No related branches found
No related tags found
1 merge request!171Rename ou endpoint and attribute on sponsor
Pipeline #101082 passed
...@@ -5,8 +5,8 @@ from greg.models import Sponsor ...@@ -5,8 +5,8 @@ from greg.models import Sponsor
class SponsorSerializer(serializers.ModelSerializer): class SponsorSerializer(serializers.ModelSerializer):
units = OrganizationalUnitSerializer(many=True, read_only=True) orgunits = OrganizationalUnitSerializer(many=True, read_only=True, source="units")
class Meta: class Meta:
model = Sponsor model = Sponsor
fields = ["id", "feide_id", "first_name", "last_name", "units"] fields = ["id", "feide_id", "first_name", "last_name", "orgunits"]
...@@ -22,7 +22,7 @@ router.register(r"persons", PersonViewSet, basename="person") ...@@ -22,7 +22,7 @@ router.register(r"persons", PersonViewSet, basename="person")
router.register(r"roletypes", RoleTypeViewSet, basename="roletype") router.register(r"roletypes", RoleTypeViewSet, basename="roletype")
router.register(r"consenttypes", ConsentTypeViewSet, basename="consenttype") router.register(r"consenttypes", ConsentTypeViewSet, basename="consenttype")
router.register(r"sponsors", SponsorViewSet, basename="sponsor") router.register(r"sponsors", SponsorViewSet, basename="sponsor")
router.register(r"orgunit", OrganizationalUnitViewSet, basename="orgunit") router.register(r"orgunits", OrganizationalUnitViewSet, basename="orgunit")
urlpatterns = router.urls urlpatterns = router.urls
......
...@@ -70,7 +70,7 @@ def test_add_sponsor_with_unit(client, unit_foo: OrganizationalUnit): ...@@ -70,7 +70,7 @@ def test_add_sponsor_with_unit(client, unit_foo: OrganizationalUnit):
sponsor_lookup_response_body = sponsor_lookup_response.json() sponsor_lookup_response_body = sponsor_lookup_response.json()
assert len(sponsor_lookup_response_body["results"]) == 1 assert len(sponsor_lookup_response_body["results"]) == 1
assert len(sponsor_lookup_response_body["results"][0]["units"]) == 0 assert len(sponsor_lookup_response_body["results"][0]["orgunits"]) == 0
data = {"hierarchical_access": "True"} data = {"hierarchical_access": "True"}
...@@ -83,9 +83,9 @@ def test_add_sponsor_with_unit(client, unit_foo: OrganizationalUnit): ...@@ -83,9 +83,9 @@ def test_add_sponsor_with_unit(client, unit_foo: OrganizationalUnit):
sponsor_lookup_response = client.get(sponsor_url, kwargs={"id": sponsor_id}) sponsor_lookup_response = client.get(sponsor_url, kwargs={"id": sponsor_id})
sponsor_lookup_response_body = sponsor_lookup_response.json() sponsor_lookup_response_body = sponsor_lookup_response.json()
assert len(sponsor_lookup_response_body["results"][0]["units"]) == 1 assert len(sponsor_lookup_response_body["results"][0]["orgunits"]) == 1
attached_unit = sponsor_lookup_response_body["results"][0]["units"][0] attached_unit = sponsor_lookup_response_body["results"][0]["orgunits"][0]
assert attached_unit["id"] == unit_foo.id assert attached_unit["id"] == unit_foo.id
...@@ -95,7 +95,7 @@ def test_remove_sponsor_orgunit_link( ...@@ -95,7 +95,7 @@ def test_remove_sponsor_orgunit_link(
): ):
sponsor_detail_url = reverse("v1:sponsor-detail", kwargs={"id": sponsor_guy.id}) sponsor_detail_url = reverse("v1:sponsor-detail", kwargs={"id": sponsor_guy.id})
response_get = client.get(sponsor_detail_url).json() response_get = client.get(sponsor_detail_url).json()
assert len(response_get["units"]) == 0 assert len(response_get["orgunits"]) == 0
data = {"hierarchical_access": "True"} data = {"hierarchical_access": "True"}
...@@ -108,14 +108,14 @@ def test_remove_sponsor_orgunit_link( ...@@ -108,14 +108,14 @@ def test_remove_sponsor_orgunit_link(
response_get = client.get(sponsor_detail_url).json() response_get = client.get(sponsor_detail_url).json()
assert len(response_get["units"]) == 1 assert len(response_get["orgunits"]) == 1
assert response_get["units"][0]["id"] == unit_foo.id assert response_get["orgunits"][0]["id"] == unit_foo.id
response_delete = client.delete(sponsor_orgunit_url) response_delete = client.delete(sponsor_orgunit_url)
assert response_delete.status_code == status.HTTP_204_NO_CONTENT assert response_delete.status_code == status.HTTP_204_NO_CONTENT
response_get = client.get(sponsor_detail_url).json() response_get = client.get(sponsor_detail_url).json()
assert len(response_get["units"]) == 0 assert len(response_get["orgunits"]) == 0
@pytest.mark.django_db @pytest.mark.django_db
...@@ -128,7 +128,7 @@ def test_delete_sponsor_connected_to_identity_not_allowed( ...@@ -128,7 +128,7 @@ def test_delete_sponsor_connected_to_identity_not_allowed(
): ):
sponsor_detail_url = reverse("v1:sponsor-detail", kwargs={"id": sponsor_guy.id}) sponsor_detail_url = reverse("v1:sponsor-detail", kwargs={"id": sponsor_guy.id})
response_get = client.get(sponsor_detail_url).json() response_get = client.get(sponsor_detail_url).json()
assert len(response_get["units"]) == 0 assert len(response_get["orgunits"]) == 0
response_delete = client.delete(sponsor_detail_url) response_delete = client.delete(sponsor_detail_url)
...@@ -177,9 +177,9 @@ def test_add_sponsor_unit_link_with_no_access_parameter( ...@@ -177,9 +177,9 @@ def test_add_sponsor_unit_link_with_no_access_parameter(
# Check that the unit is attached to the sponsor # Check that the unit is attached to the sponsor
sponsor_lookup_response = client.get(sponsor_url, kwargs={"id": sponsor_id}) sponsor_lookup_response = client.get(sponsor_url, kwargs={"id": sponsor_id})
sponsor_lookup_response_body = sponsor_lookup_response.json() sponsor_lookup_response_body = sponsor_lookup_response.json()
assert len(sponsor_lookup_response_body["results"][0]["units"]) == 1 assert len(sponsor_lookup_response_body["results"][0]["orgunits"]) == 1
attached_unit = sponsor_lookup_response_body["results"][0]["units"][0] attached_unit = sponsor_lookup_response_body["results"][0]["orgunits"][0]
assert attached_unit["id"] == unit_foo.id assert attached_unit["id"] == unit_foo.id
# Check that hierarchical_access is set to False for the link between the sponsor and unit # Check that hierarchical_access is set to False for the link between the sponsor and unit
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment