Skip to content

Commit

Permalink
tests: check env vars are present before starting tests
Browse files Browse the repository at this point in the history
Previously it would just get None values and try to connect using those.

This can be avoided by checking the env vars are present earlier and not starting.

Closes #60
  • Loading branch information
robvdl committed Mar 28, 2024
1 parent 6eee734 commit cb48bcc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@
@pytest.fixture(scope="session")
def settings():
"""Fixture that returns the Pyramid settings dict."""
# Take a copy before adding keys.
test_settings = dict(sambal.SETTINGS)
test_settings["samba.host"] = os.getenv("SAMBAL_TEST_HOST")
test_settings["samba.username"] = os.getenv("SAMBAL_TEST_USERNAME")
test_settings["samba.password"] = os.getenv("SAMBAL_TEST_PASSWORD")
test_settings["samba.realm"] = os.getenv("SAMBAL_TEST_REALM")
test_settings["http_host"] = "example.com"

# Verify that all env vars are present before starting.
assert test_settings["samba.host"] is not None
assert test_settings["samba.username"] is not None
assert test_settings["samba.password"] is not None
assert test_settings["samba.realm"] is not None
return test_settings


Expand Down

0 comments on commit cb48bcc

Please sign in to comment.