Skip to content

Commit 6f3ef3e

Browse files
committed
test: fix tests
1 parent a81980f commit 6f3ef3e

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

tests/test_cli.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def test_dev() -> None:
3232
"proxy_headers": True,
3333
"forwarded_allow_ips": None,
3434
"log_config": get_uvicorn_log_config(),
35+
"factory": False,
3536
}
3637
assert "Using import string: single_file_app:app" in result.output
3738
assert "Starting development server 🚀" in result.output
@@ -62,6 +63,7 @@ def test_dev_package() -> None:
6263
"proxy_headers": True,
6364
"forwarded_allow_ips": None,
6465
"log_config": get_uvicorn_log_config(),
66+
"factory": False,
6567
}
6668
assert "Using import string: nested_package.package:app" in result.output
6769
assert "Starting development server 🚀" in result.output
@@ -111,6 +113,7 @@ def test_dev_args() -> None:
111113
"proxy_headers": False,
112114
"forwarded_allow_ips": None,
113115
"log_config": get_uvicorn_log_config(),
116+
"factory": False,
114117
}
115118
assert "Using import string: single_file_app:api" in result.output
116119
assert "Starting development server 🚀" in result.output
@@ -141,6 +144,7 @@ def test_dev_env_vars() -> None:
141144
"proxy_headers": True,
142145
"forwarded_allow_ips": None,
143146
"log_config": get_uvicorn_log_config(),
147+
"factory": False,
144148
}
145149
assert "Using import string: single_file_app:app" in result.output
146150
assert "Starting development server 🚀" in result.output
@@ -178,6 +182,7 @@ def test_dev_env_vars_and_args() -> None:
178182
"proxy_headers": True,
179183
"forwarded_allow_ips": None,
180184
"log_config": get_uvicorn_log_config(),
185+
"factory": False,
181186
}
182187
assert "Using import string: single_file_app:app" in result.output
183188
assert "Starting development server 🚀" in result.output
@@ -206,6 +211,7 @@ def test_run() -> None:
206211
"proxy_headers": True,
207212
"forwarded_allow_ips": None,
208213
"log_config": get_uvicorn_log_config(),
214+
"factory": False,
209215
}
210216
assert "Using import string: single_file_app:app" in result.output
211217
assert "Starting production server 🚀" in result.output
@@ -232,6 +238,7 @@ def test_run_trust_proxy() -> None:
232238
"proxy_headers": True,
233239
"forwarded_allow_ips": "*",
234240
"log_config": get_uvicorn_log_config(),
241+
"factory": False,
235242
}
236243
assert "Using import string: single_file_app:app" in result.output
237244
assert "Starting production server 🚀" in result.output
@@ -278,6 +285,7 @@ def test_run_args() -> None:
278285
"proxy_headers": False,
279286
"forwarded_allow_ips": None,
280287
"log_config": get_uvicorn_log_config(),
288+
"factory": False,
281289
}
282290

283291
assert "Using import string: single_file_app:api" in result.output
@@ -309,6 +317,7 @@ def test_run_env_vars() -> None:
309317
"proxy_headers": True,
310318
"forwarded_allow_ips": None,
311319
"log_config": get_uvicorn_log_config(),
320+
"factory": False,
312321
}
313322
assert "Using import string: single_file_app:app" in result.output
314323
assert "Starting production server 🚀" in result.output
@@ -342,6 +351,7 @@ def test_run_env_vars_and_args() -> None:
342351
"proxy_headers": True,
343352
"forwarded_allow_ips": None,
344353
"log_config": get_uvicorn_log_config(),
354+
"factory": False,
345355
}
346356
assert "Using import string: single_file_app:app" in result.output
347357
assert "Starting production server 🚀" in result.output
@@ -428,6 +438,7 @@ def test_dev_with_import_string() -> None:
428438
"root_path": "",
429439
"proxy_headers": True,
430440
"log_config": get_uvicorn_log_config(),
441+
"factory": False,
431442
}
432443
assert "Using import string: single_file_app:api" in result.output
433444

@@ -449,6 +460,7 @@ def test_run_with_import_string() -> None:
449460
"root_path": "",
450461
"proxy_headers": True,
451462
"log_config": get_uvicorn_log_config(),
463+
"factory": False,
452464
}
453465
assert "Using import string: single_file_app:app" in result.output
454466

tests/test_discover.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def test_get_import_data_from_import_string_valid() -> None:
1515
result = get_import_data_from_import_string("module.submodule:app")
1616

1717
assert isinstance(result, ImportData)
18-
assert result.app_name == "app"
18+
assert result.candidate_name == "app"
1919
assert result.import_string == "module.submodule:app"
2020
assert result.module_data.module_import_str == "module.submodule"
2121
assert result.module_data.extra_sys_path == Path(".").resolve()

tests/test_utils_package.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,8 @@ def test_package_dir_no_app() -> None:
174174
with pytest.raises(FastAPICLIException) as e:
175175
get_import_data(path=Path("package/core/utils.py"))
176176
assert (
177-
"Could not find FastAPI app in module, try using --app" in e.value.args[0]
177+
"Could not find FastAPI app or app factory in module, try using --app"
178+
in e.value.args[0]
178179
)
179180

180181

0 commit comments

Comments
 (0)