From d0bf625af002fde4ece6df9e0b7fe85cb33a19fd Mon Sep 17 00:00:00 2001 From: Sven van de Scheur Date: Thu, 23 Nov 2023 16:57:23 +0100 Subject: [PATCH] :shirt: #1795 - black. --- src/open_inwoner/cms/cases/tests/test_htmx.py | 58 +++++++++++-------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/src/open_inwoner/cms/cases/tests/test_htmx.py b/src/open_inwoner/cms/cases/tests/test_htmx.py index ee4413b643..38c445d63c 100644 --- a/src/open_inwoner/cms/cases/tests/test_htmx.py +++ b/src/open_inwoner/cms/cases/tests/test_htmx.py @@ -504,17 +504,21 @@ def mock_list(request, context): Mock GET "zaakinformatieobjecten" endpoint (schemas/ZaakInformatieObject array). Creates schemas/ZaakInformatieObject dict for each item in uploads. """ - items = [generate_oas_component( - "zrc", - "schemas/ZaakInformatieObject", - url=f"{ZAKEN_ROOT}zaakinformatieobjecten/e55153aa-ad2c-4a07-ae75-15add57d6", - informatieobject=upload["url"], - zaak=self.zaak["url"], - ) for upload in uploads] + items = [ + generate_oas_component( + "zrc", + "schemas/ZaakInformatieObject", + url=f"{ZAKEN_ROOT}zaakinformatieobjecten/e55153aa-ad2c-4a07-ae75-15add57d6", + informatieobject=upload["url"], + zaak=self.zaak["url"], + ) + for upload in uploads + ] return json.dumps(items) m.get( - f"{ZAKEN_ROOT}zaakinformatieobjecten?zaak={self.zaak['url']}", text=mock_list + f"{ZAKEN_ROOT}zaakinformatieobjecten?zaak={self.zaak['url']}", + text=mock_list, ), # Upload mock. @@ -529,7 +533,7 @@ def mock_upload(request, context): # Create a UUID based on a seed derived from the file name. # This makes sure the two test cases have unique entries. - seed = file_name.ljust(16, '0').encode("utf-8") + seed = file_name.ljust(16, "0").encode("utf-8") uuid = UUID(bytes=seed) uploaded_informatie_object = generate_oas_component( @@ -552,18 +556,22 @@ def mock_upload(request, context): m.post( f"{DOCUMENTEN_ROOT}enkelvoudiginformatieobjecten", status_code=201, - text=mock_upload + text=mock_upload, ), # Setup. context = self.browser.new_context(storage_state=self.user_login_state) page = context.new_page() - page.goto(self.live_reverse("cases:case_detail", kwargs={"object_id": self.zaak["uuid"]})) + page.goto( + self.live_reverse( + "cases:case_detail", kwargs={"object_id": self.zaak["uuid"]} + ) + ) upload_form = page.locator("#document-upload") - file_input = upload_form.get_by_label('Sleep of selecteer bestanden') + file_input = upload_form.get_by_label("Sleep of selecteer bestanden") submit_button = upload_form.get_by_role("button", name=_("Upload documenten")) - notification_list = page.get_by_role('alert').get_by_role("list") + notification_list = page.get_by_role("alert").get_by_role("list") notification_list_items = notification_list.get_by_role("listitem") file_list = page.get_by_role("list").last file_list_items = file_list.get_by_role("listitem") @@ -578,24 +586,28 @@ def mock_upload(request, context): { "name": "document_1.txt", "mimeType": "text/plain", - "buffer": "test12345".encode("utf8") + "buffer": "test12345".encode("utf8"), }, { "name": "document_two.pdf", "mimeType": "application/pdf", - "buffer": "test67890".encode("utf8") - } + "buffer": "test67890".encode("utf8"), + }, ], ) submit_button.click() - page.wait_for_url(self.live_reverse("cases:case_detail", kwargs={"object_id": self.zaak["uuid"]})) + page.wait_for_url( + self.live_reverse( + "cases:case_detail", kwargs={"object_id": self.zaak["uuid"]} + ) + ) # Check that the case does now have two uploaded documents. expect(notification_list_items).to_have_count(2) - expect(notification_list_items.first).to_contain_text('document_1.txt') - expect(notification_list_items.last).to_contain_text('document_two.pdf') + expect(notification_list_items.first).to_contain_text("document_1.txt") + expect(notification_list_items.last).to_contain_text("document_two.pdf") expect(file_list_items).to_have_count(2) - expect(file_list_items.first).to_contain_text('document_1') - expect(file_list_items.first).to_contain_text('(txt, 9 bytes)') - expect(file_list_items.last).to_contain_text('document_two') - expect(file_list_items.last).to_contain_text('(pdf, 9 bytes)') + expect(file_list_items.first).to_contain_text("document_1") + expect(file_list_items.first).to_contain_text("(txt, 9 bytes)") + expect(file_list_items.last).to_contain_text("document_two") + expect(file_list_items.last).to_contain_text("(pdf, 9 bytes)")