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

test: invalid display option #87

Merged
merged 1 commit into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/test_waybar_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,23 @@ def test_read_config_default_display_options():
assert display_options == DEFAULT_DISPLAY_OPTIONS


def test_read_config_display_invalid():
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", "display", "notvalid")

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, WaybarCryptoException)


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

Expand Down
2 changes: 1 addition & 1 deletion waybar_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def read_config(config_path: str) -> Config:

for display_option in display_options:
if display_option not in DEFAULT_DISPLAY_OPTIONS_FORMAT:
raise WaybarCryptoException(f"invalid display option '{display_option}")
raise WaybarCryptoException(f"invalid display option '{display_option}'")

display_options_format = DEFAULT_DISPLAY_OPTIONS_FORMAT
display_format_price = display_options_format["price"]
Expand Down