pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/fastapi/fastapi-cli/pull/119.diff

ging_dir(assets_path): + with patch.object(uvicorn, "run") as mock_run: + result = runner.invoke( + app, ["dev", "single_file_docs.py", "--app", "no_redoc"] + ) + assert result.exit_code == 0, result.output + assert mock_run.called + + assert "http://127.0.0.1:8000/docs" in result.output + assert "http://127.0.0.1:8000/redocs" not in result.output + + +def test_full_docs() -> None: + with changing_dir(assets_path): + with patch.object(uvicorn, "run") as mock_run: + result = runner.invoke( + app, ["dev", "single_file_docs.py", "--app", "full_docs"] + ) + assert result.exit_code == 0, result.output + assert mock_run.called + + assert "http://127.0.0.1:8000/docs" in result.output + assert "http://127.0.0.1:8000/redoc" in result.output + + +def test_custom_docs() -> None: + with changing_dir(assets_path): + with patch.object(uvicorn, "run") as mock_run: + result = runner.invoke( + app, ["dev", "single_file_docs.py", "--app", "custom_docs"] + ) + assert result.exit_code == 0, result.output + assert mock_run.called + + assert "http://127.0.0.1:8000/custom-docs-url" in result.output + assert "http://127.0.0.1:8000/custom-redoc-url" in result.output + + def test_run_error() -> None: with changing_dir(assets_path): result = runner.invoke(app, ["run", "non_existing_file.py"]) diff --git a/tests/test_discover.py b/tests/test_discover.py index b1052050..99b5a4fe 100644 --- a/tests/test_discover.py +++ b/tests/test_discover.py @@ -7,18 +7,20 @@ get_import_data_from_import_string, ) from fastapi_cli.exceptions import FastAPICLIException +from tests.utils import changing_dir assets_path = Path(__file__).parent / "assets" def test_get_import_data_from_import_string_valid() -> None: - result = get_import_data_from_import_string("module.submodule:app") + with changing_dir(assets_path): + result = get_import_data_from_import_string("package.mod.app:app") assert isinstance(result, ImportData) assert result.app_name == "app" - assert result.import_string == "module.submodule:app" - assert result.module_data.module_import_str == "module.submodule" - assert result.module_data.extra_sys_path == Path(".").resolve() + assert result.import_string == "package.mod.app:app" + assert result.module_data.module_import_str == "package.mod.app" + assert result.module_data.extra_sys_path == Path(assets_path).resolve() assert result.module_data.module_paths == [] pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy