Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
charludo committed Jan 15, 2025
1 parent fb3e119 commit 829577c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
4 changes: 3 additions & 1 deletion integreat_cms/summ_ai_api/summ_ai_api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,10 @@ async def translate_text_field(
# will raise exceptions - so we don't need an else branch.
except (TimeoutError, aiohttp.ClientError, SummAiRuntimeError) as e:
logger.exception(
"SUMM.AI translation of %r failed",
"SUMM.AI translation of %r failed because of %s: %s",
text_field,
type(e), # noqa: TRY401
e, # noqa: TRY401
)
text_field.exception = e
return text_field
Expand Down
3 changes: 1 addition & 2 deletions tests/cms/views/events/test_event_form.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ def test_create_event(
data=data,
)
if role in PRIV_STAFF_ROLES + WRITE_ROLES:
assert response.status_code == 302

assert response.status_code in [200, 302]
if successfully_created:
redirect_url = response.headers.get("location")
assert_message_in_log(
Expand Down
24 changes: 12 additions & 12 deletions tests/pdf/test_pdf_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,18 @@ def test_pdf_export(
)
with open(f"tests/pdf/files/{expected_filename}", "rb") as file:
expected_pdf = PyPDF3.PdfFileReader(file)
# Assert that both documents have same number of pages
assert result_pdf.numPages == expected_pdf.numPages
# Assert that the content is identical
for page_number in range(result_pdf.numPages):
result_page = result_pdf.getPage(page_number)
expected_page = expected_pdf.getPage(page_number)
assert result_page.artBox == expected_page.artBox
assert result_page.bleedBox == expected_page.bleedBox
assert result_page.cropBox == expected_page.cropBox
assert result_page.mediaBox == expected_page.mediaBox
assert result_page.extractText() == expected_page.extractText()
assert result_page.getContents() == expected_page.getContents()
# Assert that both documents have same number of pages
assert result_pdf.numPages == expected_pdf.numPages
# Assert that the content is identical
for page_number in range(result_pdf.numPages):
result_page = result_pdf.getPage(page_number)
expected_page = expected_pdf.getPage(page_number)
assert result_page.artBox == expected_page.artBox
assert result_page.bleedBox == expected_page.bleedBox
assert result_page.cropBox == expected_page.cropBox
assert result_page.mediaBox == expected_page.mediaBox
assert result_page.extractText() == expected_page.extractText()
assert result_page.getContents() == expected_page.getContents()


@pytest.mark.django_db
Expand Down

0 comments on commit 829577c

Please sign in to comment.