chore: use parametrized tests for input and output tests (#194)

This commit is contained in:
Robert Kaussow 2022-03-30 21:34:35 +02:00 committed by GitHub
parent d5d00e849b
commit 99e20663a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -50,39 +50,29 @@ def test_exclude_tags(discovery, qemus):
assert len(filtered) == 2
def test_include_tags(discovery, qemus):
discovery.config.config["include_tags"] = ["monitored"]
@pytest.mark.parametrize(
"testinput,expected", [
(["monitored"], 1),
(["monitored", "postgres"], 2),
([], 3),
]
)
def test_include_tags(discovery, qemus, testinput, expected):
discovery.config.config["include_tags"] = testinput
filtered = discovery._filter(qemus)
assert len(filtered) == 1
assert len(filtered) == expected
def test_include_tags_multiple(discovery, qemus):
discovery.config.config["include_tags"] = ["monitored", "postgres"]
@pytest.mark.parametrize("testinput,expected", [
(["101", "100"], 2),
([], 3),
])
def test_include_vmid(discovery, qemus, testinput, expected):
discovery.config.config["include_vmid"] = testinput
filtered = discovery._filter(qemus)
assert len(filtered) == 2
def test_include_tags_empty(discovery, qemus):
discovery.config.config["include_tags"] = []
filtered = discovery._filter(qemus)
assert len(filtered) == 3
def test_include_vmid(discovery, qemus):
discovery.config.config["include_vmid"] = ["101", "100"]
filtered = discovery._filter(qemus)
assert len(filtered) == 2
def test_include_vmid_empty(discovery, qemus):
discovery.config.config["include_vmid"] = []
filtered = discovery._filter(qemus)
assert len(filtered) == 3
assert len(filtered) == expected
def test_include_and_exclude_tags(discovery, qemus):