Refactor test cases for improved readability and consistency
Some checks failed
Run Tests / e2e tests (push) Failing after 1m27s
Run Tests / lint tests (push) Failing after 6s
Run Tests / unit tests (push) Failing after 7s

- Updated test functions in various test files to enhance code clarity by formatting long lines and improving indentation.
- Adjusted assertions to use multi-line formatting for better readability.
- Added new test cases for theme settings API to ensure proper functionality.
- Ensured consistent use of line breaks and spacing across test files for uniformity.
This commit is contained in:
2025-10-27 10:32:55 +01:00
parent e8a86b15e4
commit 97b1c0360b
78 changed files with 2327 additions and 650 deletions

View File

@@ -14,7 +14,13 @@ def _cleanup_currencies(db_session):
db_session.commit()
def _assert_currency(payload: Dict[str, object], code: str, name: str, symbol: str | None, is_active: bool) -> None:
def _assert_currency(
payload: Dict[str, object],
code: str,
name: str,
symbol: str | None,
is_active: bool,
) -> None:
assert payload["code"] == code
assert payload["name"] == name
assert payload["is_active"] is is_active
@@ -47,13 +53,21 @@ def test_create_currency_success(api_client, db_session):
def test_create_currency_conflict(api_client, db_session):
api_client.post(
"/api/currencies/",
json={"code": "CAD", "name": "Canadian Dollar",
"symbol": "$", "is_active": True},
json={
"code": "CAD",
"name": "Canadian Dollar",
"symbol": "$",
"is_active": True,
},
)
duplicate = api_client.post(
"/api/currencies/",
json={"code": "CAD", "name": "Canadian Dollar",
"symbol": "$", "is_active": True},
json={
"code": "CAD",
"name": "Canadian Dollar",
"symbol": "$",
"is_active": True,
},
)
assert duplicate.status_code == 409
@@ -61,8 +75,12 @@ def test_create_currency_conflict(api_client, db_session):
def test_update_currency_fields(api_client, db_session):
api_client.post(
"/api/currencies/",
json={"code": "GBP", "name": "British Pound",
"symbol": "£", "is_active": True},
json={
"code": "GBP",
"name": "British Pound",
"symbol": "£",
"is_active": True,
},
)
response = api_client.put(
@@ -77,8 +95,12 @@ def test_update_currency_fields(api_client, db_session):
def test_toggle_currency_activation(api_client, db_session):
api_client.post(
"/api/currencies/",
json={"code": "AUD", "name": "Australian Dollar",
"symbol": "A$", "is_active": True},
json={
"code": "AUD",
"name": "Australian Dollar",
"symbol": "A$",
"is_active": True,
},
)
response = api_client.patch(
@@ -97,5 +119,7 @@ def test_default_currency_cannot_be_deactivated(api_client, db_session):
json={"is_active": False},
)
assert response.status_code == 400
assert response.json()[
"detail"] == "The default currency cannot be deactivated."
assert (
response.json()["detail"]
== "The default currency cannot be deactivated."
)