From 17683934d99ceb9534a3fe012a08d5790e6e6008 Mon Sep 17 00:00:00 2001 From: dosas Date: Mon, 20 May 2024 13:30:20 +0200 Subject: [PATCH] Fix number of imported templates (#14376) Make number of imported templates depending on feature availability The number of total templates and templates containing robottelo should match this repo and branch https://github.com/SatelliteQE/foreman_templates/tree/automation but if puppet module is missing one template is not imported "exception": "unknown input type 'puppet_parameter'" --- robottelo/constants/__init__.py | 8 ++++++++ tests/foreman/api/test_templatesync.py | 18 +++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/robottelo/constants/__init__.py b/robottelo/constants/__init__.py index 2df7c554225..a631de9ab41 100644 --- a/robottelo/constants/__init__.py +++ b/robottelo/constants/__init__.py @@ -1723,6 +1723,14 @@ FOREMAN_SETTINGS_YML = '/etc/foreman/settings.yaml' FOREMAN_TEMPLATE_IMPORT_URL = 'https://github.com/SatelliteQE/foreman_templates.git' +FOREMAN_TEMPLATES_IMPORT_COUNT = { + 'PUPPET_ENABLED': 18, + 'PUPPET_DISABLED': 17, +} +FOREMAN_TEMPLATES_NOT_IMPORTED_COUNT = { + 'PUPPET_ENABLED': 8, + 'PUPPET_DISABLED': 9, +} FOREMAN_TEMPLATE_IMPORT_API_URL = 'http://api.github.com/repos/SatelliteQE/foreman_templates' FOREMAN_TEMPLATE_TEST_TEMPLATE = ( diff --git a/tests/foreman/api/test_templatesync.py b/tests/foreman/api/test_templatesync.py index c19a932cece..fbbe1949194 100644 --- a/tests/foreman/api/test_templatesync.py +++ b/tests/foreman/api/test_templatesync.py @@ -24,6 +24,8 @@ FOREMAN_TEMPLATE_IMPORT_URL, FOREMAN_TEMPLATE_ROOT_DIR, FOREMAN_TEMPLATE_TEST_TEMPLATE, + FOREMAN_TEMPLATES_IMPORT_COUNT, + FOREMAN_TEMPLATES_NOT_IMPORTED_COUNT, ) from robottelo.logging import logger @@ -169,7 +171,12 @@ def test_import_filtered_templates_from_git_with_negate(self, module_org, module not_imported_count = [ template['imported'] for template in filtered_imported_templates['message']['templates'] ].count(False) - assert not_imported_count == 9 + exp_not_imported_count = ( + FOREMAN_TEMPLATES_NOT_IMPORTED_COUNT["PUPPET_ENABLED"] + if "puppet" in module_target_sat.get_features() + else FOREMAN_TEMPLATES_NOT_IMPORTED_COUNT["PUPPET_DISABLED"] + ) + assert not_imported_count == exp_not_imported_count ptemplates = module_target_sat.api.ProvisioningTemplate().search( query={'per_page': '100', 'search': 'name~jenkins', 'organization_id': module_org.id} ) @@ -956,7 +963,12 @@ def test_positive_export_json_output( imported_count = [ template['imported'] for template in imported_templates['message']['templates'] ].count(True) - assert imported_count == 17 # Total Count + exp_count = ( + FOREMAN_TEMPLATES_IMPORT_COUNT["PUPPET_ENABLED"] + if "puppet" in target_sat.get_features() + else FOREMAN_TEMPLATES_IMPORT_COUNT["PUPPET_DISABLED"] + ) + assert imported_count == exp_count # Total Count # Export some filtered templates to local dir _, dir_path = create_import_export_local_dir exported_templates = target_sat.api.Template().exports( @@ -965,7 +977,7 @@ def test_positive_export_json_output( exported_count = [ template['exported'] for template in exported_templates['message']['templates'] ].count(True) - assert exported_count == 17 + assert exported_count == exp_count assert 'name' in exported_templates['message']['templates'][0] assert ( target_sat.execute(