From 8ec646a06356abe09074cbf878bc15c9c0bdc570 Mon Sep 17 00:00:00 2001 From: QianqianZhang Date: Sat, 28 Sep 2024 23:03:10 -0400 Subject: [PATCH] remove tags.yaml before test, and change the assert way --- integration-tests/test_tags.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/integration-tests/test_tags.py b/integration-tests/test_tags.py index 9c2e40d8..704d59ab 100644 --- a/integration-tests/test_tags.py +++ b/integration-tests/test_tags.py @@ -27,14 +27,14 @@ def test_tags(insights_client, external_inventory, test_config): 3. The new tag shows on inventory by modifying tags.yaml """ - # Register insights - insights_client.register() - assert conftest.loop_until(lambda: insights_client.is_registered) - # Remove the tags.yaml if it exists with contextlib.suppress(FileNotFoundError): os.remove("/etc/insights-client/tags.yaml") + # Register insights + insights_client.register() + assert conftest.loop_until(lambda: insights_client.is_registered) + # When test env is satellite, check the tags from branch_info # the tags from satellite are not generated by tags.yaml if "satellite" in test_config.environment: @@ -54,9 +54,11 @@ def test_tags(insights_client, external_inventory, test_config): # Check new tag from inventory system_tags = external_inventory.this_system_tags() - assert system_tags[-1]["namespace"] == "insights-client" - assert system_tags[-1]["key"] == "group" - assert system_tags[-1]["value"] == "first_tag" + assert { + "namespace": "insights-client", + "key": "group", + "value": "first_tag", + } in system_tags # Add new tag in tags.yaml file and check on inventory with open("/etc/insights-client/tags.yaml", "r") as tags_yaml: @@ -66,6 +68,8 @@ def test_tags(insights_client, external_inventory, test_config): yaml.dump(data_loaded, tags_yaml, default_flow_style=False) insights_client.run() system_tags = external_inventory.this_system_tags() - assert system_tags[-1]["namespace"] == "insights-client" - assert system_tags[-1]["key"] == "add_by_file" - assert system_tags[-1]["value"] == "second_tag" + assert { + "namespace": "insights-client", + "key": "add_by_file", + "value": "second_tag", + } in system_tags