Skip to content

Commit

Permalink
test default/custom XDG_CONFIG_HOME values
Browse files Browse the repository at this point in the history
  • Loading branch information
chadsr committed May 26, 2024
1 parent fa6637f commit 5ff2985
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions tests/test_waybar_crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
import pytest
from unittest import mock

from waybar_crypto import CLASS_NAME, ResponseQuotesLatest, WaybarCrypto, parse_args
from waybar_crypto import (
CLASS_NAME,
DEFAULT_XDG_CONFIG_HOME_PATH,
XDG_CONFIG_HOME_ENV,
ResponseQuotesLatest,
WaybarCrypto,
parse_args,
)


# Get the absolute path of this script
ABS_DIR = os.path.dirname(os.path.abspath(__file__))
CONFIG_PATH = f"{ABS_DIR}/../config.ini.example"
TEST_CONFIG_PATH = "test_path"


@pytest.fixture()
Expand Down Expand Up @@ -89,7 +97,21 @@ def quotes_latest():
}


TEST_CONFIG_PATH = "test_path"
def test_parse_args_default_path():
with mock.patch("sys.argv", ["waybar_crypto.py"]):
os.environ[XDG_CONFIG_HOME_ENV] = ""
args = parse_args()
assert "config_path" in args
assert os.path.expanduser(DEFAULT_XDG_CONFIG_HOME_PATH) in args["config_path"]


def test_parse_args_custom_xdg_data_home():
with mock.patch("sys.argv", ["waybar_crypto.py"]):
xdg_config_home_path = "/custom"
os.environ[XDG_CONFIG_HOME_ENV] = xdg_config_home_path
args = parse_args()
assert "config_path" in args
assert xdg_config_home_path in args["config_path"]


@mock.patch(
Expand Down

0 comments on commit 5ff2985

Please sign in to comment.