Skip to content

Commit

Permalink
remove tags.yaml before test, and change the assert way
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangqq-coder committed Sep 29, 2024
1 parent fbe872c commit 8ec646a
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions integration-tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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

0 comments on commit 8ec646a

Please sign in to comment.