Skip to content

Commit

Permalink
feat: Add system config path for Windows
Browse files Browse the repository at this point in the history
Signed-off-by: Robert Luttrell <[email protected]>
  • Loading branch information
roblutt committed Nov 28, 2023
1 parent 7177744 commit 2b2c293
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,17 @@ def create_adaptor_configuration_manager(
adaptor_name,
f"{adaptor_name}.json",
)
)
),
"Windows": os.path.abspath(
os.path.join(
os.path.sep,
os.environ["PROGRAMDATA"],
"openjd",
"adaptors",
adaptor_name,
f"{adaptor_name}.json",
)
),
}
user_config_rel_path = os.path.join(".openjd", "adaptors", adaptor_name, f"{adaptor_name}.json")

Expand Down
4 changes: 3 additions & 1 deletion test/openjd/adaptor_runtime/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
def pytest_collection_modifyitems(items):
if OSName.is_windows():
# Add the tests' paths that we want to enable in Windows
do_not_skip_paths = []
do_not_skip_paths = [
"test\\openjd\\adaptor_runtime\\unit\\adaptors\\configuration\\test_configuration_manager.py"
]
skip_marker = pytest.mark.skip(reason="Skipping tests on Windows")
for item in items:
if not any(not_skip_path in item.fspath.strpath for not_skip_path in do_not_skip_paths):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,18 @@ def test_creates_config_manager(self):
assert result._system_config_path_map["Linux"] == (
f"/etc/openjd/adaptors/{adaptor_name}/{adaptor_name}.json"
)
assert result._system_config_path_map["Windows"] == (
os.path.abspath(
os.path.join(
os.path.sep,
os.environ["PROGRAMDATA"],
"openjd",
"adaptors",
adaptor_name,
f"{adaptor_name}.json",
)
)
)
assert result._user_config_rel_path == os.path.join(
".openjd", "adaptors", adaptor_name, f"{adaptor_name}.json"
)
Expand Down Expand Up @@ -499,6 +511,19 @@ def test_gets_linux_path(self, mock_system: MagicMock):
mock_system.assert_called_once()
assert result == expected

@patch.object(osname.platform, "system")
def test_gets_windows_path(self, mock_system: MagicMock):
# GIVEN
mock_system.return_value = "Windows"
expected = "path\\to\\windows\\system\\config"
manager = ConfigurationManagerMock(system_config_path_map={"Windows": expected})

# WHEN
result = manager.get_system_config_path()

# THEN
assert result == expected

@patch.object(osname.platform, "system")
def test_raises_on_nonvalid_os(self, mock_system: MagicMock):
"""
Expand Down

0 comments on commit 2b2c293

Please sign in to comment.