def test_zaaktype_no_notify_on_no_change(self, m): procestype_url = ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d") mock_oas_get(m) mock_resource_list(m, "procestypen") mock_resource_get(m, "procestypen", procestype_url) mock_nrc_oas_get(m) m.post("https://notificaties-api.vng.cloud/api/v1/notificaties", status_code=201) zaaktype = ZaakTypeFactory.create( concept=True, zaaktype_omschrijving="test", vertrouwelijkheidaanduiding="openbaar", trefwoorden=["test"], verantwoordingsrelatie=["bla"], selectielijst_procestype=procestype_url, ) url = reverse("admin:catalogi_zaaktype_change", args=(zaaktype.pk, )) response = self.app.get(url) form = response.forms["zaaktype_form"] with capture_on_commit_callbacks(execute=True): form.submit("_save") called_urls = [item.url for item in m.request_history] self.assertNotIn( "https://notificaties-api.vng.cloud/api/v1/notificaties", called_urls)
def test_selectielijst_selectielijstklasse(self, m): """ Test that the selectielijst procestype field is a dropdown. """ procestype_url = ( "https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d" ) mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") mock_resource_list(m, "resultaten") mock_resource_get(m, "procestypen", procestype_url) zaaktype = ResultaatTypeFactory.create( zaaktype__selectielijst_procestype=procestype_url ) url = reverse("admin:catalogi_resultaattype_change", args=(zaaktype.pk,)) response = self.app.get(url) self.assertEqual(response.status_code, 200) form = response.forms["resultaattype_form"] field = form.fields["selectielijstklasse"][0] self.assertEqual(field.tag, "input") # first element of JSON response self.assertEqual( field._value, "https://selectielijst.openzaak.nl/api/v1/resultaten/cc5ae4e3-a9e6-4386-bcee-46be4986a829", )
def test_publish_zaaktype(self, m): procestype_url = ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d") mock_oas_get(m) mock_resource_list(m, "procestypen") mock_resource_get(m, "procestypen", procestype_url) mock_nrc_oas_get(m) m.post("https://notificaties-api.vng.cloud/api/v1/notificaties", status_code=201) zaaktype = ZaakTypeFactory.create( concept=True, zaaktype_omschrijving="test", vertrouwelijkheidaanduiding="openbaar", trefwoorden=["test"], verantwoordingsrelatie=["bla"], selectielijst_procestype=procestype_url, ) url = reverse("admin:catalogi_zaaktype_change", args=(zaaktype.pk, )) response = self.app.get(url) # Verify that the publish button is visible and enabled publish_button = response.html.find("input", {"name": "_publish"}) self.assertIsNotNone(publish_button) publish_button = response.html.find("input", { "name": "_publish", "disabled": "disabled" }) self.assertIsNone(publish_button) form = response.forms["zaaktype_form"] with capture_on_commit_callbacks(execute=True): response = form.submit("_publish").follow() zaaktype.refresh_from_db() self.assertFalse(zaaktype.concept) # Verify that the publish button is disabled publish_button = response.html.find("input", { "name": "_publish", "disabled": "disabled" }) self.assertIsNotNone(publish_button) # Verify notification is sent called_urls = [item.url for item in m.request_history] self.assertIn("https://notificaties-api.vng.cloud/api/v1/notificaties", called_urls)
def test_resultaattype_detail(self, m): procestype_url = ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d") mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") mock_resource_list(m, "resultaten") mock_resource_get(m, "procestypen", procestype_url) resultaattype = ResultaatTypeFactory.create( zaaktype__selectielijst_procestype=procestype_url) url = reverse("admin:catalogi_resultaattype_change", args=(resultaattype.pk, )) response = self.app.get(url) self.assertEqual(response.status_code, 200)
def setUp(self): super().setUp() mocker = requests_mock.Mocker() mocker.start() self.addCleanup(mocker.stop) mock_oas_get(mocker) mock_resource_list(mocker, "procestypen") mock_resource_get( mocker, "procestypen", ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d"), )
def test_readonly_zaaktype(self, m): """ check that in case of published zaaktype only "datum_einde_geldigheid" field is editable """ procestype_url = ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d") mock_oas_get(m) mock_resource_get(m, "procestypen", procestype_url) zaaktype = ZaakTypeFactory.create( concept=False, zaaktype_omschrijving="test", vertrouwelijkheidaanduiding="openbaar", trefwoorden=["test1", "test2"], verantwoordingsrelatie=["bla"], selectielijst_procestype=procestype_url, doorlooptijd_behandeling=timedelta(days=10), producten_of_diensten=[ "http://example.com/1", "http://example.com/2" ], ) url = reverse("admin:catalogi_zaaktype_change", args=(zaaktype.pk, )) response = self.app.get(url) form = response.form form_fields = list(form.fields.keys()) zaaktype_fields = [ f.name for f in zaaktype._meta.get_fields() if f.name != "datum_einde_geldigheid" ] self.assertEqual("datum_einde_geldigheid" in form_fields, True) for field in zaaktype_fields: self.assertEqual(field in form_fields, False) # check custom formatting procestype = response.html.find( class_="field-selectielijst_procestype").div.div self.assertEqual(procestype.text, "1 - Instellen en inrichten organisatie") behandeling = response.html.find( class_="field-doorlooptijd_behandeling").div.div self.assertEqual(behandeling.text, "10 days") producten_of_diensten = response.html.find( class_="field-producten_of_diensten").div.div self.assertEqual(len(producten_of_diensten.find_all("a")), 2)
def test_resultaattype_detail(self, m): procestype_url = ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d") mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") mock_resource_list(m, "resultaten") mock_resource_get(m, "procestypen", procestype_url) resultaattype = ResultaatTypeFactory.create( zaaktype__selectielijst_procestype=procestype_url) url = reverse("admin:catalogi_resultaattype_change", args=(resultaattype.pk, )) response = self.app.get(url) self.assertEqual(response.status_code, 200) # Verify that the save button is visible save_button = response.html.find("input", {"name": "_save"}) self.assertIsNotNone(save_button)
def test_publish_zaaktype(self, m): procestype_url = ("https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d") mock_oas_get(m) mock_resource_list(m, "procestypen") mock_resource_get(m, "procestypen", procestype_url) zaaktype = ZaakTypeFactory.create( concept=True, zaaktype_omschrijving="test", vertrouwelijkheidaanduiding="openbaar", trefwoorden=["test"], verantwoordingsrelatie=["bla"], selectielijst_procestype=procestype_url, ) url = reverse("admin:catalogi_zaaktype_change", args=(zaaktype.pk, )) response = self.app.get(url) # Verify that the publish button is visible and enabled publish_button = response.html.find("input", {"name": "_publish"}) self.assertIsNotNone(publish_button) publish_button = response.html.find("input", { "name": "_publish", "disabled": "disabled" }) self.assertIsNone(publish_button) form = response.forms["zaaktype_form"] response = form.submit("_publish").follow() zaaktype.refresh_from_db() self.assertFalse(zaaktype.concept) # Verify that the publish button is disabled publish_button = response.html.find("input", { "name": "_publish", "disabled": "disabled" }) self.assertIsNotNone(publish_button)
def test_resultaattype_detail_with_read_only_user(self, m): user = UserFactory.create(is_staff=True) view_resultaattype = Permission.objects.get(codename="view_resultaattype") user.user_permissions.add(view_resultaattype) self.app.set_user(user) selectielijst_api = "https://selectielijst.openzaak.nl/api/v1/" procestype_url = ( f"{selectielijst_api}procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d" ) resultaat_url = ( f"{selectielijst_api}resultaten/cc5ae4e3-a9e6-4386-bcee-46be4986a829" ) omschrijving_url = ( "https://referentielijsten-api.vng.cloud/api/v1/" "resultaattypeomschrijvingen/e6a0c939-3404-45b0-88e3-76c94fb80ea7" ) mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") mock_resource_list(m, "resultaten") mock_resource_get(m, "procestypen", procestype_url) mock_resource_get(m, "resultaten", resultaat_url) mock_resource_get(m, "resultaattypeomschrijvingen", omschrijving_url) resultaattype = ResultaatTypeFactory.create( zaaktype__selectielijst_procestype=procestype_url, selectielijstklasse=resultaat_url, resultaattypeomschrijving=omschrijving_url, ) url = reverse("admin:catalogi_resultaattype_change", args=(resultaattype.pk,)) response = self.app.get(url) self.assertEqual(response.status_code, 200)
def test_readonly_resultaattype(self, m): """ check that in case of published zaaktype, resultaattype page is readonly """ selectielijst_api = "https://selectielijst.openzaak.nl/api/v1/" procestype_url = ( f"{selectielijst_api}procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d" ) resultaat_url = ( f"{selectielijst_api}resultaten/cc5ae4e3-a9e6-4386-bcee-46be4986a829" ) omschrijving_url = ( "https://referentielijsten-api.vng.cloud/api/v1/" "resultaattypeomschrijvingen/e6a0c939-3404-45b0-88e3-76c94fb80ea7") mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") mock_resource_list(m, "resultaten") mock_resource_get(m, "procestypen", procestype_url) mock_resource_get(m, "resultaten", resultaat_url) mock_resource_get(m, "resultaattypeomschrijvingen", omschrijving_url) resultaattype = ResultaatTypeFactory.create( zaaktype__concept=False, zaaktype__selectielijst_procestype=procestype_url, selectielijstklasse=resultaat_url, resultaattypeomschrijving=omschrijving_url, archiefactietermijn=relativedelta(years=5), ) url = reverse("admin:catalogi_resultaattype_change", args=(resultaattype.pk, )) response = self.app.get(url) form = response.form form_fields = list(form.fields.keys()) resultaattype_fields = [ f.name for f in resultaattype._meta.get_fields() ] for field in resultaattype_fields: self.assertEqual(field in form_fields, False) # check custom formatting selectielijstklasse = response.html.find( class_="field-selectielijstklasse").div.div self.assertEqual(selectielijstklasse.text, "1.1 - Ingericht - vernietigen") omschrijving = response.html.find( class_="field-resultaattypeomschrijving").div.div self.assertEqual(omschrijving.text, "Afgewezen") archiefactietermijn = response.html.find( class_="field-archiefactietermijn").div.div self.assertEqual(archiefactietermijn.text, "5 years")
def test_create_resultaattype_selectielijst_bewaartermijn_null(self, m): """ Test if creating a resultaattype with selectielijstklasse.bewaartermijn = null is possible """ procestype_url = ( "https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d" ) selectielijstklasse_url = ( "https://selectielijst.openzaak.nl/api/v1/" "resultaten/8320ab7d-3a8d-4c8b-b94a-14b4fa374d0a" ) omschrijving_url = ( "https://referentielijsten-api.vng.cloud/api/v1/" "resultaattypeomschrijvingen/e6a0c939-3404-45b0-88e3-76c94fb80ea7" ) mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") mock_resource_list(m, "resultaten") mock_resource_get(m, "procestypen", procestype_url) mock_resource_get(m, "resultaten", selectielijstklasse_url) mock_resource_get(m, "resultaattypeomschrijvingen", omschrijving_url) zaaktype = ZaakTypeFactory.create(selectielijst_procestype=procestype_url) url = reverse("admin:catalogi_resultaattype_add") response = self.app.get(url) self.assertEqual(response.status_code, 200) form = response.forms["resultaattype_form"] form["zaaktype"] = zaaktype.pk form["omschrijving"] = "test" form["selectielijstklasse"] = selectielijstklasse_url form["resultaattypeomschrijving"] = omschrijving_url form["brondatum_archiefprocedure_afleidingswijze"] = "ingangsdatum_besluit" response = form.submit() self.assertEqual(response.status_code, 302) self.assertEqual(ResultaatType.objects.count(), 1) self.assertEqual(ResultaatType.objects.first().omschrijving, "test")
def test_create_resultaattype_selectielijst_filtered_by_procestype(self, m): """ Test that the selectielijst procestype field is a dropdown. """ procestype_url = ( "https://selectielijst.openzaak.nl/api/v1/" "procestypen/e1b73b12-b2f6-4c4e-8929-94f84dd2a57d" ) mock_oas_get(m) mock_resource_list(m, "resultaattypeomschrijvingen") selectielijstklasse_url = ( "https://selectielijst.openzaak.nl/api/v1/" "resultaten/d92e5a77-c523-4273-b8e0-c912115ef156" ) m.get( f"{_get_base_url()}resultaten?{urlencode({'procesType': procestype_url})}", json={ "count": 100, "next": None, "previous": None, "results": [ { "algemeenBestuurEnInrichtingOrganisatie": True, "alleTaakgebieden": False, "bedrijfsvoeringEnPersoneel": True, "bewaartermijn": "P5Y", "burgerzaken": True, "economie": False, "generiek": True, "heffenBelastingen": False, "herkomst": "Risicoanalyse", "naam": "Niet doorgegaan", "nummer": 4, "omschrijving": "", "onderwijs": False, "procesType": procestype_url, "procestermijn": "nihil", "procestermijnOpmerking": "", "procestermijnWeergave": "Nihil", "publiekeInformatieEnRegistratie": False, "sociaalDomein": False, "specifiek": False, "sportCultuurEnRecreatie": False, "toelichting": "", "url": selectielijstklasse_url, "veiligheid": False, "verkeerEnVervoer": False, "vhrosv": False, "volksgezonheidEnMilieu": False, "volledigNummer": "1.4", "waardering": "vernietigen", }, ], }, ) mock_resource_get(m, "procestypen", procestype_url) zaaktype = ZaakTypeFactory.create(selectielijst_procestype=procestype_url) query_params = urlencode( { "zaaktype__id__exact": zaaktype.id, "zaaktype": zaaktype.id, "catalogus": zaaktype.catalogus.pk, } ) url = f"{reverse('admin:catalogi_resultaattype_add')}?_changelist_filters={query_params}" response = self.app.get(url) self.assertEqual(response.status_code, 200) form = response.forms["resultaattype_form"] zaaktype_procestype = ( response.html("div", {"class": "field-get_zaaktype_procestype"})[0] .find_all("div")[-1] .text ) self.assertEqual(zaaktype_procestype, "1 - Instellen en inrichten organisatie") field = form.fields["selectielijstklasse"][0] self.assertEqual(field.tag, "input") self.assertEqual(len(field.options), 1) # first element of JSON response self.assertEqual( field._value, "https://selectielijst.openzaak.nl/api/v1/resultaten/d92e5a77-c523-4273-b8e0-c912115ef156", )