Skip to content

Commit

Permalink
test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Jun 5, 2024
1 parent 66c7a65 commit 2bc6571
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 25 deletions.
10 changes: 5 additions & 5 deletions tests/integration/actions/inventory/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@


TEST_FIXTURE_DIR = os.path.join(FIXTURES_DIR, "integration", "actions", "inventory")
ANSIBLE_INVENTORY_FIXTURE_DIR = os.path.join(TEST_FIXTURE_DIR, "ansible_inventory", "inventory.yml")
TEST_CONFIG_FILE = os.path.join(TEST_FIXTURE_DIR, "ansible-navigator.yml")
ANSIBLE_INVENTORY_FIXTURE_DIR = Path(TEST_FIXTURE_DIR) / "ansible_inventory" / "inventory.yml"
TEST_CONFIG_FILE = Path(TEST_FIXTURE_DIR) / "ansible-navigator.yml"


base_steps = (
Expand Down Expand Up @@ -73,7 +73,7 @@ def fixture_tmux_session(request: pytest.FixtureRequest) -> Generator[TmuxSessio
],
pane_height=2000,
pane_width=500,
config_path=Path(TEST_CONFIG_FILE),
config_path=TEST_CONFIG_FILE,
request=request,
) as tmux_session:
yield tmux_session
Expand All @@ -92,8 +92,8 @@ def test(
:param step: Step index to use
:raises ValueError: When the test mode is not set
"""
assert Path(ANSIBLE_INVENTORY_FIXTURE_DIR).exists()
assert Path(TEST_CONFIG_FILE).exists()
assert ANSIBLE_INVENTORY_FIXTURE_DIR.exists()
assert TEST_CONFIG_FILE.exists()

if step.search_within_response is SearchFor.HELP:
search_within_response = ":help help"
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/actions/replay/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@


TEST_FIXTURE_DIR = os.path.join(FIXTURES_DIR, "integration/actions/replay")
PLAYBOOK_ARTIFACT = os.path.join(TEST_FIXTURE_DIR, "playbook-artifact.json")
TEST_CONFIG_FILE = os.path.join(TEST_FIXTURE_DIR, "ansible-navigator.yml")
PLAYBOOK_ARTIFACT = Path(TEST_FIXTURE_DIR) / "playbook-artifact.json"
TEST_CONFIG_FILE = Path(TEST_FIXTURE_DIR) / "ansible-navigator.yml"


class BaseClass:
Expand Down Expand Up @@ -62,8 +62,8 @@ def test(
:param comment: Comment to add to the fixture
:param search_within_response: A list of strings or string to find
"""
assert Path(PLAYBOOK_ARTIFACT).exists()
assert Path(TEST_CONFIG_FILE).exists()
assert PLAYBOOK_ARTIFACT.exists()
assert TEST_CONFIG_FILE.exists()

received_output = tmux_session.interaction(user_input, search_within_response)

Expand Down
8 changes: 4 additions & 4 deletions tests/integration/actions/stdout/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@


TEST_FIXTURE_DIR = os.path.join(FIXTURES_DIR, "integration/actions/stdout")
ANSIBLE_PLAYBOOK = os.path.join(TEST_FIXTURE_DIR, "site.yml")
TEST_CONFIG_FILE = os.path.join(TEST_FIXTURE_DIR, "ansible-navigator.yml")
ANSIBLE_PLAYBOOK = Path(TEST_FIXTURE_DIR) / "site.yml"
TEST_CONFIG_FILE = Path(TEST_FIXTURE_DIR) / "ansible-navigator.yml"


class BaseClass:
Expand Down Expand Up @@ -65,8 +65,8 @@ def test(
:param comment: Comment to add to the fixture
:param search_within_response: A list of strings or string to find
"""
assert Path(ANSIBLE_PLAYBOOK).exists()
assert Path(TEST_CONFIG_FILE).exists()
assert ANSIBLE_PLAYBOOK.exists()
assert TEST_CONFIG_FILE.exists()

received_output = tmux_session.interaction(user_input, search_within_response)

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_execution_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,15 @@ def run_test(
:param config_fixture: The settings fixture
:param expected: the expected return value
"""
cfg_path = f"{self.TEST_FIXTURE_DIR}/{config_fixture}"
cfg_path = self.TEST_FIXTURE_DIR / config_fixture
coll_cache_path = tmp_path / "collection_doc_cache.db"

assert Path(cfg_path).exists()
assert cfg_path.exists()

params = shlex.split(cli_entry) + ["--pp", "never"]

monkeypatch.setattr("sys.argv", params)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", cfg_path)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", str(cfg_path))
monkeypatch.setenv("ANSIBLE_NAVIGATOR_COLLECTION_DOC_CACHE_PATH", str(coll_cache_path))
monkeypatch.chdir(tmp_path)

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_execution_environment_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,15 @@ def run_test(
:param config_fixture: The settings fixture
:param expected: the expected return value
"""
cfg_path = f"{self.TEST_FIXTURE_DIR}/{config_fixture}"
cfg_path = self.TEST_FIXTURE_DIR / config_fixture
coll_cache_path = tmp_path / "collection_doc_cache.db"

assert Path(cfg_path).exists()
assert cfg_path.exists()

params = shlex.split(cli_entry) + ["--pp", "never"]

monkeypatch.setattr("sys.argv", params)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", cfg_path)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", str(cfg_path))
monkeypatch.setenv("ANSIBLE_NAVIGATOR_COLLECTION_DOC_CACHE_PATH", str(coll_cache_path))
monkeypatch.chdir(tmp_path)

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_pass_environment_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def run_test(
:param config_fixture: The settings fixture
:param expected: the expected return value
"""
cfg_path = f"{self.TEST_FIXTURE_DIR}/{config_fixture}"
cfg_path = self.TEST_FIXTURE_DIR / config_fixture
coll_cache_path = tmp_path / "collection_doc_cache.db"

assert Path(cfg_path).exists()
assert cfg_path.exists()

params = shlex.split(cli_entry) + ["--pp", "never"]

monkeypatch.setattr("sys.argv", params)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", cfg_path)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", str(cfg_path))
monkeypatch.setenv("ANSIBLE_NAVIGATOR_COLLECTION_DOC_CACHE_PATH", str(coll_cache_path))
monkeypatch.chdir(tmp_path)

Expand Down
6 changes: 3 additions & 3 deletions tests/integration/test_set_environment_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ def run_test(
:param config_fixture: The settings fixture
:param expected: the expected return value
"""
cfg_path = f"{self.TEST_FIXTURE_DIR}/{config_fixture}"
cfg_path = self.TEST_FIXTURE_DIR / config_fixture
coll_cache_path = tmp_path / "collection_doc_cache.db"

assert Path(cfg_path).exists()
assert cfg_path.exists()

params = shlex.split(cli_entry) + ["--pp", "never"]

monkeypatch.setattr("sys.argv", params)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", cfg_path)
monkeypatch.setenv("ANSIBLE_NAVIGATOR_CONFIG", str(cfg_path))
monkeypatch.setenv("ANSIBLE_NAVIGATOR_COLLECTION_DOC_CACHE_PATH", str(coll_cache_path))
monkeypatch.chdir(tmp_path)

Expand Down

0 comments on commit 2bc6571

Please sign in to comment.