Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#1928] Check missing volgnummer for second status preview #891

Merged
merged 1 commit into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/open_inwoner/cms/cases/views/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,10 @@ def get_second_status_preview(self, statustypen: list) -> Optional[StatusType]:
"""
statustype_numbers = [s.volgnummer for s in statustypen]

# status_types retrieved via eSuite don't always have a volgnummer
if not all(statustype_numbers):
return

# only 1 statustype for `self.case`
# (this scenario is blocked by openzaak, but not part of the zgw standard)
if len(statustype_numbers) < 2:
Expand Down
2 changes: 1 addition & 1 deletion src/open_inwoner/openzaak/api_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class StatusType(ZGWModel):
url: str # bug: not required according to OAS
zaaktype: str
omschrijving: str
volgnummer: int
volgnummer: Optional[int] # not in eSuite
omschrijving_generiek: str = ""
statustekst: str = ""
is_eindstatus: bool = False
Expand Down
61 changes: 58 additions & 3 deletions src/open_inwoner/openzaak/tests/test_case_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from unittest.mock import patch

from django.contrib.auth.models import AnonymousUser
from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import reverse
from django.utils.translation import gettext_lazy as _
Expand All @@ -23,7 +24,7 @@

from open_inwoner.accounts.choices import LoginTypeChoices
from open_inwoner.accounts.tests.factories import UserFactory, eHerkenningUserFactory
from open_inwoner.cms.cases.views.status import SimpleFile
from open_inwoner.cms.cases.views.status import InnerCaseDetailView, SimpleFile
from open_inwoner.openzaak.constants import StatusIndicators
from open_inwoner.openzaak.tests.factories import (
StatusTranslationFactory,
Expand Down Expand Up @@ -204,12 +205,12 @@ def setUpTestData(cls):
cls.second_status_preview = StatusType(
url=cls.status_type_in_behandeling["url"],
zaaktype=cls.status_type_in_behandeling["zaaktype"],
omschrijving=cls.status_type_in_behandeling["omschrijving"],
volgnummer=cls.status_type_in_behandeling["volgnummer"],
omschrijving="In behandeling",
omschrijving_generiek=cls.status_type_in_behandeling[
"omschrijvingGeneriek"
],
statustekst=cls.status_type_in_behandeling["statustekst"],
volgnummer=3,
is_eindstatus=cls.status_type_in_behandeling["isEindstatus"],
informeren=cls.status_type_in_behandeling["informeren"],
)
Expand Down Expand Up @@ -625,6 +626,60 @@ def test_pass_endstatus_type_data_if_endstatus_not_reached(self, m):
},
)

def test_second_status_preview(self, m):
"""Unit test for `InnerCaseDetailView.get_second_status_preview`"""

request = RequestFactory().get("/")
detail_view = InnerCaseDetailView()
detail_view.setup(request)
detail_view.case = self.zaak

st1 = StatusType(
url="http://statustype_2.com",
zaaktype=self.status_type_in_behandeling["zaaktype"],
omschrijving=self.status_type_in_behandeling["omschrijving"],
volgnummer=2,
omschrijving_generiek=self.status_type_in_behandeling[
"omschrijvingGeneriek"
],
statustekst=self.status_type_in_behandeling["statustekst"],
is_eindstatus=self.status_type_in_behandeling["isEindstatus"],
informeren=self.status_type_in_behandeling["informeren"],
)
st2 = StatusType(
url="http://statustype_1.com",
zaaktype=self.status_type_new["zaaktype"],
omschrijving=self.status_type_new["omschrijving"],
volgnummer=1,
omschrijving_generiek=self.status_type_new["omschrijvingGeneriek"],
statustekst=self.status_type_new["statustekst"],
is_eindstatus=self.status_type_new["isEindstatus"],
informeren=self.status_type_new["informeren"],
)
st3 = StatusType(
url=self.status_type_in_behandeling["url"],
zaaktype=self.status_type_in_behandeling["zaaktype"],
omschrijving=self.status_type_in_behandeling["omschrijving"],
volgnummer=None,
omschrijving_generiek=self.status_type_in_behandeling[
"omschrijvingGeneriek"
],
statustekst=self.status_type_in_behandeling["statustekst"],
is_eindstatus=self.status_type_in_behandeling["isEindstatus"],
informeren=self.status_type_in_behandeling["informeren"],
)

test_cases = [
([st1, st2], st1), # OK
([st1, st2, st3], None), # status_type with volgnummer=None
([st1], None), # no second status_type
([], None), # no status_type
]
for i, (status_types, result) in enumerate(test_cases):
with self.subTest(i=i):
res = detail_view.get_second_status_preview(status_types)
self.assertEqual(res, result)

@freeze_time("2021-01-12 17:00:00")
def test_new_docs(self, m):
self._setUpMocks(m)
Expand Down
Loading