Skip to content

Commit

Permalink
Issue #350: Fix unit tests that failed on Windows because of differen…
Browse files Browse the repository at this point in the history
…ce in config paths.
  • Loading branch information
JohanKJSchreurs committed Dec 15, 2022
1 parent 01f5256 commit d3c555c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
5 changes: 3 additions & 2 deletions tests/rest/auth/test_cli.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import logging
from unittest import mock
import os

import pytest

Expand Down Expand Up @@ -37,8 +38,8 @@ def refresh_token_store(tmp_openeo_config_home) -> RefreshTokenStore:
def test_paths(capsys):
cli.main(["paths"])
out = capsys.readouterr().out
assert "/auth-config.json" in out
assert "/refresh-tokens.json" in out
assert os.sep + "auth-config.json" in out
assert os.sep + "refresh-tokens.json" in out


def test_config_dump(capsys, auth_config):
Expand Down
17 changes: 15 additions & 2 deletions tests/test_config.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import contextlib
import logging
import os
import platform
import random
import re
import textwrap
Expand All @@ -15,11 +16,23 @@


def test_get_user_config_dir():
assert get_user_config_dir() == Path(__file__).parent / "data/user_dirs/config/openeo-python-client"
# For Linux/Mac we configure the config and data directories in conftest.py
# via the environment variables XDG_CONFIG_HOME and XDG_DATA_HOME.
# But on Windows we need to set APPDATA instead, and we don't have separate
# variables for config and data.
if platform.system() == "Windows":
os.environ["APPDATA"] = str(Path(__file__).parent / Path("data/user_dirs/config"))
assert get_user_config_dir() == Path(__file__).parent / Path("data/user_dirs/config/openeo-python-client")


def test_get_user_data_dir():
assert get_user_data_dir() == Path(__file__).parent / "data/user_dirs/data/openeo-python-client"
# For Linux/Mac we configure the config and data directories in conftest.py
# via the environment variables XDG_CONFIG_HOME and XDG_DATA_HOME.
# But on Windows we need to set APPDATA instead, and we don't have separate
# variables for config and data.
if platform.system() == "Windows":
os.environ["APPDATA"] = str(Path(__file__).parent / Path("data/user_dirs/data"))
assert get_user_data_dir() == Path(__file__).parent / Path("data/user_dirs/data/openeo-python-client")


class TestClientConfig:
Expand Down

0 comments on commit d3c555c

Please sign in to comment.