From f44300cec5fc002903139e8d5ee2f88f9d540262 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Keil?= Date: Thu, 10 Jun 2021 22:05:04 +0200 Subject: [PATCH] add inventory plugin unit test `test_verify_file` (#2773) * add inventory plugin unit test `test_verify_file` * fix typos in `test_verify_file_bad_config` unit test --- tests/unit/plugins/inventory/test_cobbler.py | 8 +++++++- tests/unit/plugins/inventory/test_linode.py | 8 +++++++- tests/unit/plugins/inventory/test_lxd.py | 6 ++++++ tests/unit/plugins/inventory/test_proxmox.py | 6 ++++++ tests/unit/plugins/inventory/test_stackpath_compute.py | 6 ++++++ 5 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/unit/plugins/inventory/test_cobbler.py b/tests/unit/plugins/inventory/test_cobbler.py index 477a3039f7..e184d166dc 100644 --- a/tests/unit/plugins/inventory/test_cobbler.py +++ b/tests/unit/plugins/inventory/test_cobbler.py @@ -37,5 +37,11 @@ def test_init_cache(inventory): assert inventory._cache[inventory.cache_key] == {} +def test_verify_file(tmp_path, inventory): + file = tmp_path / "foobar.cobbler.yml" + file.touch() + assert inventory.verify_file(str(file)) is True + + def test_verify_file_bad_config(inventory): - assert inventory.verify_file('foobar.cobber.yml') is False + assert inventory.verify_file('foobar.cobbler.yml') is False diff --git a/tests/unit/plugins/inventory/test_linode.py b/tests/unit/plugins/inventory/test_linode.py index 427a7c69b3..ab75c6c9fc 100644 --- a/tests/unit/plugins/inventory/test_linode.py +++ b/tests/unit/plugins/inventory/test_linode.py @@ -74,5 +74,11 @@ def test_conig_query_options(inventory): assert tags == ['web-server'] +def test_verify_file(tmp_path, inventory): + file = tmp_path / "foobar.linode.yml" + file.touch() + assert inventory.verify_file(str(file)) is True + + def test_verify_file_bad_config(inventory): - assert inventory.verify_file('foobar.linde.yml') is False + assert inventory.verify_file('foobar.linode.yml') is False diff --git a/tests/unit/plugins/inventory/test_lxd.py b/tests/unit/plugins/inventory/test_lxd.py index 8a98af6e71..04cea0af71 100644 --- a/tests/unit/plugins/inventory/test_lxd.py +++ b/tests/unit/plugins/inventory/test_lxd.py @@ -51,6 +51,12 @@ def inventory(): return inv +def test_verify_file(tmp_path, inventory): + file = tmp_path / "foobar.lxd.yml" + file.touch() + assert inventory.verify_file(str(file)) is True + + def test_verify_file_bad_config(inventory): assert inventory.verify_file('foobar.lxd.yml') is False diff --git a/tests/unit/plugins/inventory/test_proxmox.py b/tests/unit/plugins/inventory/test_proxmox.py index e248fb05e3..c2b0408138 100644 --- a/tests/unit/plugins/inventory/test_proxmox.py +++ b/tests/unit/plugins/inventory/test_proxmox.py @@ -21,6 +21,12 @@ def inventory(): return r +def test_verify_file(tmp_path, inventory): + file = tmp_path / "foobar.proxmox.yml" + file.touch() + assert inventory.verify_file(str(file)) is True + + def test_verify_file_bad_config(inventory): assert inventory.verify_file('foobar.proxmox.yml') is False diff --git a/tests/unit/plugins/inventory/test_stackpath_compute.py b/tests/unit/plugins/inventory/test_stackpath_compute.py index 9359cd680f..8a409becd6 100644 --- a/tests/unit/plugins/inventory/test_stackpath_compute.py +++ b/tests/unit/plugins/inventory/test_stackpath_compute.py @@ -66,6 +66,12 @@ def test_get_stack_slugs(inventory): ] +def test_verify_file(tmp_path, inventory): + file = tmp_path / "foobar.stackpath_compute.yml" + file.touch() + assert inventory.verify_file(str(file)) is True + + def test_verify_file_bad_config(inventory): assert inventory.verify_file('foobar.stackpath_compute.yml') is False