Skip to content

Commit

Permalink
Fix number of imported templates (#14376)
Browse files Browse the repository at this point in the history
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'"
  • Loading branch information
dosas authored May 20, 2024
1 parent 3d9d302 commit 1768393
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
8 changes: 8 additions & 0 deletions robottelo/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = (
Expand Down
18 changes: 15 additions & 3 deletions tests/foreman/api/test_templatesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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}
)
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit 1768393

Please sign in to comment.