Skip to content

Commit

Permalink
Merge pull request #891 from maykinmedia/fix/1928-statustype-missing-…
Browse files Browse the repository at this point in the history
…volgnummer

[#1928] Check missing volgnummer for second status preview
  • Loading branch information
alextreme authored Dec 14, 2023
2 parents f9e17ba + 4993699 commit 520d1d9
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 4 deletions.
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

0 comments on commit 520d1d9

Please sign in to comment.