Skip to content

Commit

Permalink
add test for templates with puppet
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Dragun committed Jan 31, 2022
1 parent c7b781c commit 7a673d2
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pytest_fixtures/component/puppet.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,12 @@ def module_puppet_classes(
f'and environment = {module_env_search.name}'
}
)


@pytest.fixture(scope='module', params=[True, False], ids=["puppet_enabled", "puppet_disabled"])
def parametrized_puppet_sat(request, default_sat, module_puppet_enabled_sat):
if request.param:
sat = module_puppet_enabled_sat
else:
sat = default_sat
return {'sat': sat, 'enabled': request.param}
38 changes: 38 additions & 0 deletions tests/foreman/api/test_templatesync.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,44 @@ def test_import_filtered_templates_from_git_with_negate(self, module_org):
)
assert len(rtemplates) == 1

@pytest.mark.tier2
def test_import_template_with_puppet(self, parametrized_puppet_sat):
"""Importing puppet templates with enabled/disabled puppet module
:Steps:
1. Have enabled(disabled) puppet module
2. Import template containing puppet
3. Check if template was imported
:expectedresults:
Template was (not) imported
:id: 9ab46883-a3a7-4d2c-9a79-3d574bfd2ad8
:parametrized: yes
:CaseImportance: Medium
"""
prefix = gen_string('alpha')
api_template = parametrized_puppet_sat['sat'].api.Template()
filtered_imported_templates = api_template.imports(
data={
'repo': FOREMAN_TEMPLATE_IMPORT_URL,
'branch': 'automation',
'dirname': 'import/job_templates/',
'filter': 'jenkins Start OpenSCAP scans',
'force': True,
'prefix': prefix,
}
)
not_imported_count = [
template['imported'] for template in filtered_imported_templates['message']['templates']
].count(False)
if parametrized_puppet_sat['enabled']:
assert not_imported_count == 1
else:
assert not_imported_count == 2

@pytest.mark.tier2
def test_positive_import_and_associate(
self,
Expand Down

0 comments on commit 7a673d2

Please sign in to comment.