Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve testing of server configuration #11

Merged
merged 8 commits into from
Sep 20, 2020
Prev Previous commit
Reduce test method length in test_start.py
#11

This commit will reduce test_start_server_uvicorn_gunicorn_custom_config
by decreasing code duplication, based on feedback from @sourcery-ai.
Thanks robots!
  • Loading branch information
br3ndonland committed Sep 20, 2020
commit 3c97fdf4917c88eb8f35900e304a0516b4e348d0
14 changes: 0 additions & 14 deletions tests/test_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,26 +494,12 @@ def test_start_server_uvicorn_gunicorn_custom_config(
)
monkeypatch.setenv("LOG_FORMAT", "gunicorn")
monkeypatch.setenv("LOG_LEVEL", "debug")
monkeypatch.setenv("MAX_WORKERS", "1")
monkeypatch.setenv("PROCESS_MANAGER", "gunicorn")
monkeypatch.setenv("WEB_CONCURRENCY", "4")
monkeypatch.setenv("WORKERS_PER_CORE", "0.5")
assert gunicorn_conf_tmp_file_path.parent.exists()
assert os.getenv("GUNICORN_CONF") == str(gunicorn_conf_tmp_file_path)
assert os.getenv("LOG_FORMAT") == "gunicorn"
assert os.getenv("LOG_LEVEL") == "debug"
assert os.getenv("MAX_WORKERS") == "1"
assert os.getenv("PROCESS_MANAGER") == "gunicorn"
assert os.getenv("WEB_CONCURRENCY") == "4"
assert os.getenv("WORKERS_PER_CORE") == "0.5"
assert (
gunicorn_conf.calculate_workers(
str(os.getenv("MAX_WORKERS")),
str(os.getenv("WEB_CONCURRENCY")),
str(os.getenv("WORKERS_PER_CORE")),
)
== 1
)
mock_run = mocker.patch("subprocess.run", autospec=True)
start.start_server(
str(os.getenv("PROCESS_MANAGER")),
Expand Down