Skip to content

Commit 4200fdd

Browse files
committed
chore(tasks): enable formatting of server unit test files
1 parent 9a88a85 commit 4200fdd

9 files changed

Lines changed: 40 additions & 55 deletions

File tree

tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,7 @@ def lint_ruff_format(context):
582582
strictdoc/
583583
tools/ecss
584584
tests/unit/
585+
tests/unit_server/
585586
tests/integration/*.py
586587
tests/end2end/
587588
""",

tests/unit_server/conftest.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33

44
STRICTDOC_ROOT_PATH = os.path.abspath(os.path.join(__file__, "../../.."))
5-
assert os.path.exists(
6-
STRICTDOC_ROOT_PATH
7-
), f"does not exist: {STRICTDOC_ROOT_PATH}"
5+
assert os.path.exists(STRICTDOC_ROOT_PATH), (
6+
f"does not exist: {STRICTDOC_ROOT_PATH}"
7+
)
88
sys.path.append(STRICTDOC_ROOT_PATH)

tests/unit_server/strictdoc/server/01_hello_world/test_case.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ def test_get_document():
2222
)
2323
project_config: ProjectConfig = ProjectConfig.default_config()
2424
project_config.integrate_server_config(server_config)
25-
client = TestClient(
26-
create_app(
27-
project_config=project_config
28-
)
29-
)
25+
client = TestClient(create_app(project_config=project_config))
3026
response = client.get("/01_hello_world/sample.html")
3127
assert response.status_code == 200

tests/unit_server/strictdoc/server/02_export_document_to_reqif/test_case.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,7 @@ def test_export_document_to_reqif():
3333
project_config.project_features.append(ProjectFeature.REQIF)
3434
project_config.integrate_server_config(server_config)
3535

36-
client = TestClient(
37-
create_app(
38-
project_config=project_config
39-
)
40-
)
36+
client = TestClient(create_app(project_config=project_config))
4137
response = client.get("/02_export_document_to_reqif/sample.html")
4238
assert response.status_code == 200
4339

tests/unit_server/strictdoc/server/03_http_404_for_non_existing_resources/test_case.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@ def project_config():
2626
project_config.integrate_server_config(server_config)
2727
return project_config
2828

29+
2930
def test_get_non_existing_resource(project_config: ProjectConfig):
30-
client = TestClient(
31-
create_app(
32-
project_config=project_config
33-
)
34-
)
31+
client = TestClient(create_app(project_config=project_config))
3532
response = client.get("/does_not_exist/sample.html")
3633
assert response.status_code == 404

tests/unit_server/strictdoc/server/04_http_412_for_non_activated_features/test_case.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ def project_config():
2626
project_config.integrate_server_config(server_config)
2727
return project_config
2828

29+
2930
def test(project_config: ProjectConfig):
30-
client = TestClient(
31-
create_app(
32-
project_config=project_config
33-
)
34-
)
31+
client = TestClient(create_app(project_config=project_config))
3532
response = client.get("/traceability_matrix.html")
3633
assert response.status_code == 412
3734

tests/unit_server/strictdoc/server/05_http_304_non_modified_for_documents_and_assets/test_case.py

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,27 @@ def project_config():
3232
project_config.integrate_server_config(server_config)
3333
return project_config
3434

35+
3536
def test(project_config: ProjectConfig):
36-
client = TestClient(
37-
create_app(
38-
project_config=project_config
39-
)
40-
)
37+
client = TestClient(create_app(project_config=project_config))
4138

4239
path_to_index = os.path.join(PATH_TO_OUTPUT_FOLDER, "html", "index.html")
43-
path_to_turbo = os.path.join(PATH_TO_OUTPUT_FOLDER, "html", "_static", "turbo.min.js")
40+
path_to_turbo = os.path.join(
41+
PATH_TO_OUTPUT_FOLDER, "html", "_static", "turbo.min.js"
42+
)
4443

4544
#
4645
# Test getting the index.html.
4746
#
4847
response = client.get("/")
4948
assert response.status_code == 200
5049

51-
response = client.get("/", headers={
52-
"if-none-match": get_etag(path_to_index)
53-
})
50+
response = client.get(
51+
"/", headers={"if-none-match": get_etag(path_to_index)}
52+
)
5453
assert response.status_code == 304
5554

56-
response = client.get("/", headers={
57-
"if-none-match": "INVALID_ETAG"
58-
})
55+
response = client.get("/", headers={"if-none-match": "INVALID_ETAG"})
5956
assert response.status_code == 200
6057

6158
#
@@ -64,12 +61,13 @@ def test(project_config: ProjectConfig):
6461
response = client.get("/_static/turbo.min.js")
6562
assert response.status_code == 200
6663

67-
response = client.get("/_static/turbo.min.js", headers={
68-
"if-none-match": get_etag(path_to_turbo)
69-
})
64+
response = client.get(
65+
"/_static/turbo.min.js",
66+
headers={"if-none-match": get_etag(path_to_turbo)},
67+
)
7068
assert response.status_code == 304
7169

72-
response = client.get("/_static/turbo.min.js", headers={
73-
"if-none-match": "INVALID_ETAG"
74-
})
70+
response = client.get(
71+
"/_static/turbo.min.js", headers={"if-none-match": "INVALID_ETAG"}
72+
)
7573
assert response.status_code == 200

tests/unit_server/strictdoc/server/10_redirect_to_uid/test_case.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,15 @@ def project_config():
2626
project_config.integrate_server_config(server_config)
2727
return project_config
2828

29-
def test_redirect_to_existing_and_non_existing_uid(project_config: ProjectConfig):
30-
client = TestClient(
31-
create_app(
32-
project_config=project_config
33-
)
34-
)
29+
30+
def test_redirect_to_existing_and_non_existing_uid(
31+
project_config: ProjectConfig,
32+
):
33+
client = TestClient(create_app(project_config=project_config))
3534
response = client.get("/UID/REQ-1", follow_redirects=False)
3635
assert response.status_code == 302
3736

38-
response = client.get("/UID/MID_THAT_DOES_NOT_EXIST", follow_redirects=False)
37+
response = client.get(
38+
"/UID/MID_THAT_DOES_NOT_EXIST", follow_redirects=False
39+
)
3940
assert response.status_code == 404

tests/unit_server/strictdoc/server/20_feature_diff/test_case.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,17 @@ def project_config():
2828
host="127.0.0.1",
2929
port=8001,
3030
)
31-
project_config: ProjectConfig = ProjectConfigLoader.load_from_path_or_get_default(
32-
path_to_config=PATH_TO_CONFIG,
31+
project_config: ProjectConfig = (
32+
ProjectConfigLoader.load_from_path_or_get_default(
33+
path_to_config=PATH_TO_CONFIG,
34+
)
3335
)
3436
project_config.integrate_server_config(server_config)
3537
return project_config
3638

39+
3740
def test(project_config: ProjectConfig):
38-
client = TestClient(
39-
create_app(
40-
project_config=project_config
41-
)
42-
)
41+
client = TestClient(create_app(project_config=project_config))
4342
response = client.get("/diff?tab=foo")
4443
assert response.status_code == 400
4544

0 commit comments

Comments
 (0)