Exemplo n.º 1
0
def test_find_many_settings_precedence(monkeypatch) -> None:
    """test more than one in cwd"""

    expected = os.path.join(os.getcwd(), "ansible-navigator.yml")
    paths = [
        expected,
        os.path.join(os.path.expanduser("~"), ".ansible-navigator.json")
    ]

    def check_path_exists(arg):
        return arg in paths

    monkeypatch.setattr(os.path, "exists", check_path_exists)
    messages, exit_messages, found = utils.find_settings_file()
    assert expected == found
Exemplo n.º 2
0
def test_find_many_settings_cwd(monkeypatch) -> None:
    """test more than one in cwd"""

    paths = [
        os.path.join(os.getcwd(), "ansible-navigator" + ext)
        for ext in EXTENTIONS
    ]

    def check_path_exists(arg):
        return arg in paths

    monkeypatch.setattr(os.path, "exists", check_path_exists)
    messages, exit_messages, found = utils.find_settings_file()
    expected = f"Only one file among {utils.oxfordcomma(paths, 'and')}"
    assert any([expected in exit_msg.message for exit_msg in exit_messages])