Skip to content

Commit

Permalink
More fixes: part 1
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Jun 14, 2024
1 parent 4630601 commit 88d8793
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 25 deletions.
16 changes: 8 additions & 8 deletions tests/integration/_tmux_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,15 +158,15 @@ def __enter__(self) -> TmuxSession: # noqa: PYI034
tmux_common.append(f"export ANSIBLE_NAVIGATOR_CONFIG='{self._config_path}'")
tmux_common.append("export ANSIBLE_NAVIGATOR_LOG_LEVEL=debug")

log_file = os.path.join(self._test_log_dir, "ansible-navigator.log")
tmux_common.append(f"export ANSIBLE_NAVIGATOR_LOG_FILE='{log_file}'")
playbook_artifact = os.path.join(self._test_log_dir, "playbook-artifact.log")
log_file = self._test_log_dir / "ansible-navigator.log"
tmux_common.append(f"export ANSIBLE_NAVIGATOR_LOG_FILE='{log_file!s}'")
playbook_artifact = self._test_log_dir / "playbook-artifact.log"
tmux_common.append(
f"export ANSIBLE_NAVIGATOR_PLAYBOOK_ARTIFACT_SAVE_AS='{playbook_artifact}'",
f"export ANSIBLE_NAVIGATOR_PLAYBOOK_ARTIFACT_SAVE_AS='{playbook_artifact!s}'",
)
collection_doc_cache = os.path.join(self._test_log_dir, "collection_doc_cache.db")
collection_doc_cache = self._test_log_dir / "collection_doc_cache.db"
tmux_common.append(
f"export ANSIBLE_NAVIGATOR_COLLECTION_DOC_CACHE_PATH='{collection_doc_cache}'",
f"export ANSIBLE_NAVIGATOR_COLLECTION_DOC_CACHE_PATH='{collection_doc_cache!s}'",
)
tmux_common.append(f"export ANSIBLE_NAVIGATOR_PULL_POLICY='{self._pull_policy}'")

Expand Down Expand Up @@ -310,8 +310,8 @@ def interaction(
return showing
time.sleep(0.1)

setup_capture_path = Path(os.path.join(self._test_log_dir, "showing_setup.txt"))
timeout_capture_path = Path(os.path.join(self._test_log_dir, "showing_timeout.txt"))
setup_capture_path = self._test_log_dir / "showing_setup.txt"
timeout_capture_path = self._test_log_dir / "showing_timeout.txt"

ok_to_return = False
err_message = "RESPONSE"
Expand Down
8 changes: 3 additions & 5 deletions tests/unit/configuration_subsystem/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from __future__ import annotations

import os

from copy import deepcopy
from pathlib import Path
from typing import TYPE_CHECKING
Expand Down Expand Up @@ -77,22 +75,22 @@ def _generate_config(
params = []

if settings_file_name:
settings_file_path = os.path.join(TEST_FIXTURE_DIR, settings_file_name)
settings_file_path = TEST_FIXTURE_DIR / settings_file_name
with Path(settings_file_path).open(encoding="utf-8") as fh:
try:
settings_contents = yaml.load(fh, Loader=Loader)
except yaml.parser.ParserError:
# let the configuration subsystem catch the invalid yaml file
settings_contents = {}
else:
settings_file_path = ""
settings_file_path = "" # type:ignore[assignment]
settings_contents = {}

# make a deep copy here to ensure we do not modify the original
application_configuration = deepcopy(NavigatorConfiguration)
application_configuration.internals.initializing = initial
application_configuration.application_version = "test"
application_configuration.internals.settings_file_path = settings_file_path or None
application_configuration.internals.settings_file_path = str(settings_file_path) or None
configurator = Configurator(
application_configuration=application_configuration,
params=params,
Expand Down
6 changes: 1 addition & 5 deletions tests/unit/configuration_subsystem/test_fixture_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
entries for for all entries.
"""

import os

from pathlib import Path

from ansible_navigator.configuration_subsystem import NavigatorConfiguration
from ansible_navigator.utils.serialize import Loader
from ansible_navigator.utils.serialize import yaml
Expand All @@ -25,7 +21,7 @@ def test_data_no_missing_env_var_data() -> None:

def test_full_settings_file() -> None:
"""Test using a full settings file."""
settings_file_path = Path(os.path.join(TEST_FIXTURE_DIR, "ansible-navigator.yml"))
settings_file_path = TEST_FIXTURE_DIR / "ansible-navigator.yml"
with settings_file_path.open(encoding="utf-8") as fh:
settings_contents = yaml.load(fh, Loader=Loader)
for entry in NavigatorConfiguration.entries:
Expand Down
12 changes: 5 additions & 7 deletions tests/unit/configuration_subsystem/test_internals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Test the internals of a NavigatorConfiguration."""

import os

from copy import deepcopy
from pathlib import Path

Expand Down Expand Up @@ -30,7 +28,7 @@ def test_settings_file_path_file_system(monkeypatch: pytest.MonkeyPatch) -> None
functionality in tests
"""
settings_file = "ansible-navigator.yml"
settings_file_path = os.path.join(TEST_FIXTURE_DIR, settings_file)
settings_file_path = TEST_FIXTURE_DIR / settings_file
args = deepcopy(NavigatorConfiguration)
args.internals.initializing = True
args.application_version = "test"
Expand All @@ -40,7 +38,7 @@ def getcwd() -> Path:

monkeypatch.setattr(Path, "cwd", getcwd)
parse_and_update(params=[], args=args)
assert args.internals.settings_file_path == settings_file_path
assert args.internals.settings_file_path == str(settings_file_path)
assert args.internals.settings_source == Constants.SEARCH_PATH


Expand All @@ -51,11 +49,11 @@ def test_settings_file_path_environment_variable(monkeypatch: pytest.MonkeyPatch
functionality in tests
"""
settings_file = "ansible-navigator.yml"
settings_file_path = os.path.join(TEST_FIXTURE_DIR, settings_file)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", settings_file_path)
settings_file_path = TEST_FIXTURE_DIR / settings_file
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", str(settings_file_path))
args = deepcopy(NavigatorConfiguration)
args.internals.initializing = True
args.application_version = "test"
parse_and_update(params=[], args=args)
assert args.internals.settings_file_path == settings_file_path
assert args.internals.settings_file_path == str(settings_file_path)
assert args.internals.settings_source == Constants.ENVIRONMENT_VARIABLE

0 comments on commit 88d8793

Please sign in to comment.