Skip to content

Commit

Permalink
test: no API key in config
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed May 27, 2024
1 parent baf36df commit c6a7b2a
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/test_waybar_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,24 @@ def test_read_config_display_invalid():
assert isinstance(e, WaybarCryptoException)


@mock.patch.dict(os.environ, {API_KEY_ENV: ""})
def test_read_config_no_api_key():
with open(TEST_CONFIG_PATH, "r", encoding="utf-8") as f:
cfp = configparser.ConfigParser(allow_no_value=True, interpolation=None)
cfp.read_file(f)
cfp.set("general", "api_key", "")

with tempfile.NamedTemporaryFile(mode="w") as tmp:
cfp.write(tmp)
tmp.flush()
tmp_config_path = tmp.file.name

try:
_ = read_config(tmp_config_path)
except Exception as e:
assert isinstance(e, NoApiKeyException)

Check warning on line 369 in tests/test_waybar_crypto.py

View check run for this annotation

Codecov / codecov/patch

tests/test_waybar_crypto.py#L368-L369

Added lines #L368 - L369 were not covered by tests


class TestWaybarCrypto:
"""Tests for the WaybarCrypto."""

Expand Down

0 comments on commit c6a7b2a

Please sign in to comment.