Skip to content

Commit

Permalink
👌 [open-zaak/open-notificaties#156] Process PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenbal committed Dec 6, 2024
1 parent 99e77b4 commit 90b3d3d
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
4 changes: 2 additions & 2 deletions notifications_api_common/kanalen.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ def __repr__(self):
)

@staticmethod
def get_field(model: Model, field: str) -> Field:
def get_field(model: Model, field_name: str) -> Field:
"""
Function to retrieve a field from a Model
"""
return model._meta.get_field(field)
return model._meta.get_field(field_name)

def get_help_text(self, field: Field, kenmerk: str) -> str:
"""
Expand Down
17 changes: 17 additions & 0 deletions tests/test_kanaal_documentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@ def test_generate_docs():
"""

assert result == expected


def test_kanaal_get_help_text():
kanaal = Kanaal(label="dummy", main_resource=Person, kenmerken=("name",))
field = kanaal.get_field(Person, "name")

assert kanaal.get_help_text(field, "name") == "The name of the person"

kanaal = Kanaal(
label="dummy",
main_resource=Person,
kenmerken=("name",),
extra_kwargs={"name": {"help_text": "help text 2"}},
)
field = kanaal.get_field(Person, "name")

assert kanaal.get_help_text(field, "name") == "help text 2"
8 changes: 4 additions & 4 deletions tests/test_register_webhook.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from unittest.mock import patch

from django.contrib.messages import get_messages
from django.utils.translation import gettext as _

Expand Down Expand Up @@ -48,7 +46,8 @@ def test_register_webhook_request_exception(
channels=["zaken"],
)

with patch("requests.Session.post", side_effect=RequestException("exception")):
with requests_mock.Mocker() as m:
m.post(f"{NOTIFICATIONS_API_ROOT}abonnement", exc=RequestException("exception"))
register_webhook(object, request_with_middleware, Subscription.objects.all())

messages = list(get_messages(request_with_middleware))
Expand All @@ -68,7 +67,8 @@ def test_register_webhook_http_error(request_with_middleware, notifications_conf
channels=["zaken"],
)

with patch("requests.Session.post", side_effect=HTTPError("400")):
with requests_mock.Mocker() as m:
m.post(f"{NOTIFICATIONS_API_ROOT}abonnement", exc=HTTPError("400"))
register_webhook(object, request_with_middleware, Subscription.objects.all())

messages = list(get_messages(request_with_middleware))
Expand Down

0 comments on commit 90b3d3d

Please sign in to comment.