Skip to content

Commit

Permalink
🚚 [#59] moved the old api to legacy file
Browse files Browse the repository at this point in the history
  • Loading branch information
bart-maykin committed Oct 19, 2023
1 parent 5ca61b0 commit a99fbbf
Show file tree
Hide file tree
Showing 88 changed files with 188 additions and 164 deletions.
1 change: 0 additions & 1 deletion src/openklant/components/contactmomenten/__init__.py

This file was deleted.

1 change: 0 additions & 1 deletion src/openklant/components/klanten/__init__.py

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions src/openklant/components/legacy/contactmomenten/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
default_app_config = (
"openklant.components.legacy.contactmomenten.apps.ContactmomentenConfig"
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from vng_api_common.filtersets import FilterSet
from vng_api_common.utils import get_help_text

from openklant.components.contactmomenten.models.contactmomenten import (
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ContactMoment,
KlantContactMoment,
ObjectContactMoment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

from notifications_api_common.kanalen import Kanaal

from openklant.components.contactmomenten.models.contactmomenten import ContactMoment
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ContactMoment,
)

KANAAL_CONTACTMOMENTEN = Kanaal(
settings.CONTACTMOMENTEN_NOTIFICATIONS_KANAAL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from vng_api_common.serializers import add_choice_values_help_text
from vng_api_common.validators import IsImmutableValidator, URLValidator

from openklant.components.contactmomenten.models.constants import ObjectTypes
from openklant.components.contactmomenten.models.contactmomenten import (
from openklant.components.legacy.contactmomenten.models.constants import ObjectTypes
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ContactMoment,
KlantContactMoment,
Medewerker,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from rest_framework.test import APITestCase
from vng_api_common.tests import AuthCheckMixin, reverse

from openklant.components.contactmomenten.models.tests.factories import (
from openklant.components.legacy.contactmomenten.models.tests.factories import (
ContactMomentFactory,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
from vng_api_common.constants import ComponentTypes
from vng_api_common.tests import JWTAuthMixin, get_validation_errors, reverse

from openklant.components.contactmomenten.models.constants import InitiatiefNemer
from openklant.components.contactmomenten.models.contactmomenten import ContactMoment
from openklant.components.contactmomenten.models.tests.factories import (
from openklant.components.legacy.contactmomenten.models.constants import InitiatiefNemer
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ContactMoment,
)
from openklant.components.legacy.contactmomenten.models.tests.factories import (
ContactMomentFactory,
KlantContactMomentFactory,
MedewerkerFactory,
Expand All @@ -18,7 +20,7 @@

from ..scopes import SCOPE_CONTACTMOMENTEN_AANMAKEN, SCOPE_CONTACTMOMENTEN_ALLES_LEZEN

KLANT = "http://klanten.nl/api/v1/klanten/12345"
KLANT = "http://klanten.nl/api/v0/klanten/12345"


class ContactMomentTests(JWTAuthMixin, APITestCase):
Expand Down Expand Up @@ -770,18 +772,18 @@ def test_filter_object_url(self):
cm3 = ContactMomentFactory.create(kanaal="email")

ObjectContactMomentFactory.create(
contactmoment=cm1, object="http://example.com/api/v1/1"
contactmoment=cm1, object="http://example.com/api/v0/1"
)
ObjectContactMomentFactory.create(
contactmoment=cm2, object="http://example.com/api/v1/2"
contactmoment=cm2, object="http://example.com/api/v0/2"
)
ObjectContactMomentFactory.create(
contactmoment=cm3, object="http://example.com/api/v1/2"
contactmoment=cm3, object="http://example.com/api/v0/2"
)

response = self.client.get(
self.list_url,
{"object": "http://example.com/api/v1/2"},
{"object": "http://example.com/api/v0/2"},
HTTP_HOST="testserver.com",
)

Expand All @@ -802,18 +804,18 @@ def test_filter_object_url_multiple(self):
cm3 = ContactMomentFactory.create(kanaal="email")

ObjectContactMomentFactory.create(
contactmoment=cm1, object="http://example.com/api/v1/1"
contactmoment=cm1, object="http://example.com/api/v0/1"
)
ObjectContactMomentFactory.create(
contactmoment=cm2, object="http://example.com/api/v1/2"
contactmoment=cm2, object="http://example.com/api/v0/2"
)
ObjectContactMomentFactory.create(
contactmoment=cm3, object="http://example.com/api/v1/3"
contactmoment=cm3, object="http://example.com/api/v0/3"
)

response = self.client.get(
self.list_url,
{"object": "http://example.com/api/v1/2,http://example.com/api/v1/3"},
{"object": "http://example.com/api/v0/2,http://example.com/api/v0/3"},
HTTP_HOST="testserver.com",
)

Expand All @@ -834,18 +836,18 @@ def test_filter_klant_url(self):
cm3 = ContactMomentFactory.create(kanaal="email")

KlantContactMomentFactory.create(
contactmoment=cm1, klant="http://example.com/api/v1/1"
contactmoment=cm1, klant="http://example.com/api/v0/1"
)
KlantContactMomentFactory.create(
contactmoment=cm2, klant="http://example.com/api/v1/2"
contactmoment=cm2, klant="http://example.com/api/v0/2"
)
KlantContactMomentFactory.create(
contactmoment=cm3, klant="http://example.com/api/v1/2"
contactmoment=cm3, klant="http://example.com/api/v0/2"
)

response = self.client.get(
self.list_url,
{"klant": "http://example.com/api/v1/2"},
{"klant": "http://example.com/api/v0/2"},
HTTP_HOST="testserver.com",
)

Expand All @@ -866,18 +868,18 @@ def test_filter_klant_url_multiple(self):
cm3 = ContactMomentFactory.create(kanaal="email")

KlantContactMomentFactory.create(
contactmoment=cm1, klant="http://example.com/api/v1/1"
contactmoment=cm1, klant="http://example.com/api/v0/1"
)
KlantContactMomentFactory.create(
contactmoment=cm2, klant="http://example.com/api/v1/2"
contactmoment=cm2, klant="http://example.com/api/v0/2"
)
KlantContactMomentFactory.create(
contactmoment=cm3, klant="http://example.com/api/v1/3"
contactmoment=cm3, klant="http://example.com/api/v0/3"
)

response = self.client.get(
self.list_url,
{"klant": "http://example.com/api/v1/2,http://example.com/api/v1/3"},
{"klant": "http://example.com/api/v0/2,http://example.com/api/v0/3"},
HTTP_HOST="testserver.com",
)

Expand All @@ -898,29 +900,29 @@ def test_filter_klant_url_and_object_url(self):
cm3 = ContactMomentFactory.create(kanaal="email")

KlantContactMomentFactory.create(
contactmoment=cm1, klant="http://example.com/api/v1/1"
contactmoment=cm1, klant="http://example.com/api/v0/1"
)
KlantContactMomentFactory.create(
contactmoment=cm2, klant="http://example.com/api/v1/2"
contactmoment=cm2, klant="http://example.com/api/v0/2"
)
KlantContactMomentFactory.create(
contactmoment=cm3, klant="http://example.com/api/v1/2"
contactmoment=cm3, klant="http://example.com/api/v0/2"
)
ObjectContactMomentFactory.create(
contactmoment=cm1, object="http://example.com/api/v1/1"
contactmoment=cm1, object="http://example.com/api/v0/1"
)
ObjectContactMomentFactory.create(
contactmoment=cm2, object="http://example.com/api/v1/2"
contactmoment=cm2, object="http://example.com/api/v0/2"
)
ObjectContactMomentFactory.create(
contactmoment=cm3, object="http://example.com/api/v1/3"
contactmoment=cm3, object="http://example.com/api/v0/3"
)

response = self.client.get(
self.list_url,
{
"klant": "http://example.com/api/v1/2",
"object": "http://example.com/api/v1/3",
"klant": "http://example.com/api/v0/2",
"object": "http://example.com/api/v0/3",
},
HTTP_HOST="testserver.com",
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@
from vng_api_common.models import APICredential
from vng_api_common.tests import JWTAuthMixin, get_validation_errors, reverse

from openklant.components.contactmomenten.models.constants import InitiatiefNemer, Rol
from openklant.components.contactmomenten.models.contactmomenten import (
from openklant.components.legacy.contactmomenten.models.constants import (
InitiatiefNemer,
Rol,
)
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
KlantContactMoment,
)
from openklant.components.contactmomenten.models.tests.factories import (
from openklant.components.legacy.contactmomenten.models.tests.factories import (
ContactMomentFactory,
KlantContactMomentFactory,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
from vng_api_common.tests import JWTAuthMixin, get_validation_errors, reverse
from zds_client.tests.mocks import mock_client

from openklant.components.contactmomenten.models.constants import ObjectTypes
from openklant.components.contactmomenten.models.contactmomenten import (
from openklant.components.legacy.contactmomenten.models.constants import ObjectTypes
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ObjectContactMoment,
)
from openklant.components.contactmomenten.models.tests.factories import (
from openklant.components.legacy.contactmomenten.models.tests.factories import (
ContactMomentFactory,
ObjectContactMomentFactory,
)

ZAAK = "http://example.com/api/v1/zaken/1"
ZAAK = "http://example.com/api/v0/zaken/1"


class ObjectContactMomentTests(JWTAuthMixin, APITestCase):
Expand Down Expand Up @@ -63,7 +63,7 @@ def test_read_objectcontactmoment(self):
)
@patch(
"zds_client.client.get_operation_url",
return_value="/api/v1/zaakcontactmomenten",
return_value="/api/v0/zaakcontactmomenten",
)
@patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={})
@patch("vng_api_common.validators.obj_has_shape", return_value=True)
Expand All @@ -77,10 +77,10 @@ def test_create_objectcontactmoment(self, *mocks):
"object": ZAAK,
}
responses = {
"http://example.com/api/v1/zaakcontactmomenten": [
"http://example.com/api/v0/zaakcontactmomenten": [
{
"url": f"https://example.com/api/v1/zaakcontactmomenten/{uuid.uuid4()}",
"contactmoment": f"http://testserver/api/v1/contactmomenten/{uuid.uuid4()}",
"url": f"https://example.com/api/v0/zaakcontactmomenten/{uuid.uuid4()}",
"contactmoment": f"http://testserver/api/v0/contactmomenten/{uuid.uuid4()}",
"zaak": ZAAK,
}
]
Expand All @@ -101,7 +101,7 @@ def test_create_objectcontactmoment(self, *mocks):
)
@patch(
"zds_client.client.get_operation_url",
return_value="/api/v1/zaakcontactmomenten",
return_value="/api/v0/zaakcontactmomenten",
)
@patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={})
@patch("vng_api_common.validators.obj_has_shape", return_value=True)
Expand All @@ -114,7 +114,7 @@ def test_create_objectcontactmoment_fail_no_remote_relation(self, *mocks):
"objectType": ObjectTypes.zaak,
"object": ZAAK,
}
responses = {"http://example.com/api/v1/zaakcontactmomenten": []}
responses = {"http://example.com/api/v0/zaakcontactmomenten": []}
with mock_client(responses):
response = self.client.post(list_url, data)

Expand All @@ -126,15 +126,15 @@ def test_create_objectcontactmoment_fail_no_remote_relation(self, *mocks):

@patch(
"zds_client.client.get_operation_url",
return_value="/api/v1/zaakcontactmomenten",
return_value="/api/v0/zaakcontactmomenten",
)
@patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={})
def test_destroy_objectcontactmoment(self, *mocks):
objectcontactmoment = ObjectContactMomentFactory.create(
object=ZAAK, object_type=ObjectTypes.zaak
)
detail_url = reverse(objectcontactmoment)
responses = {"http://example.com/api/v1/zaakcontactmomenten": []}
responses = {"http://example.com/api/v0/zaakcontactmomenten": []}

with mock_client(responses):
response = self.client.delete(detail_url)
Expand All @@ -144,7 +144,7 @@ def test_destroy_objectcontactmoment(self, *mocks):

@patch(
"zds_client.client.get_operation_url",
return_value="/api/v1/zaakcontactmomenten",
return_value="/api/v0/zaakcontactmomenten",
)
@patch("zds_client.tests.mocks.MockClient.fetch_schema", return_value={})
def test_destroy_fail_existing_relation(self, *mocks):
Expand All @@ -153,10 +153,10 @@ def test_destroy_fail_existing_relation(self, *mocks):
)
detail_url = reverse(objectcontactmoment)
responses = {
"http://example.com/api/v1/zaakcontactmomenten": [
"http://example.com/api/v0/zaakcontactmomenten": [
{
"url": f"https://example.com/api/v1/zaakcontactmomenten/{uuid.uuid4()}",
"contactmoment": f"http://testserver/api/v1/contactmomenten/{uuid.uuid4()}",
"url": f"https://example.com/api/v0/zaakcontactmomenten/{uuid.uuid4()}",
"contactmoment": f"http://testserver/api/v0/contactmomenten/{uuid.uuid4()}",
"zaak": ZAAK,
}
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from vng_api_common.validators import ResourceValidator
from zds_client import ClientError

from openklant.components.contactmomenten.models.contactmomenten import (
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ObjectContactMoment,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@


class ContactmomentenConfig(AppConfig):
name = "openklant.components.contactmomenten"
name = "openklant.components.legacy.contactmomenten"
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

from .factories import ContactMomentFactory

KLANT = "http://some.klanten.nl/api/v1/klanten/951e4660-3835-4643-8f9c-e523e364a30f"
ZAAK = "http://some.zrc.nl/api/v1/zaken/ffb1a466-fdad-4898-87fa-dae026df38c0"
KLANT = "http://some.klanten.nl/api/v0/klanten/951e4660-3835-4643-8f9c-e523e364a30f"
ZAAK = "http://some.zrc.nl/api/v0/zaken/ffb1a466-fdad-4898-87fa-dae026df38c0"
MEDEWERKER = (
"http://some.klanten.nl/api/v1/medewerkers/951e4660-3835-4643-8f9c-e523e364a30f"
"http://some.klanten.nl/api/v0/medewerkers/951e4660-3835-4643-8f9c-e523e364a30f"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1435,7 +1435,7 @@ paths:
type: string
format: uuid
servers:
- url: /contactmomenten/api/v1
- url: /contactmomenten/api/v0
components:
responses:
'400':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
from vng_api_common.audittrails.models import AuditTrail
from vng_api_common.tests import JWTAuthMixin, reverse

from openklant.components.contactmomenten.models.constants import InitiatiefNemer
from openklant.components.contactmomenten.models.contactmomenten import ContactMoment
from openklant.components.legacy.contactmomenten.models.constants import InitiatiefNemer
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ContactMoment,
)

KLANT = "http://some.klanten.nl/api/v1/klanten/951e4660-3835-4643-8f9c-e523e364a30f"
KLANT = "http://some.klanten.nl/api/v0/klanten/951e4660-3835-4643-8f9c-e523e364a30f"
MEDEWERKER = (
"http://some.medewerkers.nl/api/v1/medewerkers/ffb1a466-fdad-4898-87fa-dae026df38c0"
"http://some.medewerkers.nl/api/v0/medewerkers/ffb1a466-fdad-4898-87fa-dae026df38c0"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
from rest_framework.test import APITestCase
from zgw_consumers.models import Service

from openklant.components.contactmomenten.models.contactmomenten import ContactMoment
from openklant.components.legacy.contactmomenten.models.contactmomenten import (
ContactMoment,
)


@override_settings(IS_HTTPS=True)
Expand Down
Loading

0 comments on commit a99fbbf

Please sign in to comment.