Skip to content

Commit 2342aeb

Browse files
authored
Verify cloned-from-id metadata via hammer (#20734)
1 parent 05b34f8 commit 2342aeb

File tree

3 files changed

+77
-6
lines changed

3 files changed

+77
-6
lines changed

tests/foreman/cli/test_jobtemplate.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ def test_positive_clone_job_template(module_org, module_target_sat):
235235
:steps:
236236
1. Create a job template
237237
2. Clone the job template
238-
3. assert dump of the data of the cloned job template is working
239-
4. update job template to unlocked
240-
5. Delete the cloned job template
241-
6. Delete the original job template
238+
3. Get cloned template info and verify the cloned-from-id metadata.
239+
4. Assert dump of the data of the cloned job template is working
240+
5. Update job template to unlocked
241+
6. Delete the original and cloned job template
242242
243243
:expectedresults: The job template is cloned successfully
244244
@@ -265,7 +265,9 @@ def test_positive_clone_job_template(module_org, module_target_sat):
265265
'id': template['id'],
266266
}
267267
)
268-
assert module_target_sat.cli.JobTemplate.info({'name': clone_name})['name'] == clone_name
268+
cloned_template = module_target_sat.cli.JobTemplate.info({'name': clone_name})
269+
assert cloned_template['name'] == clone_name
270+
assert cloned_template['cloned-from-id'] == template['id']
269271
# assert dump of the data of the cloned job template is working
270272
dump = module_target_sat.cli.JobTemplate.dump({'name': clone_name})
271273
assert len(dump) > 0

tests/foreman/cli/test_provisioningtemplate.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,32 @@ def test_positive_clone(module_target_sat):
209209
)
210210
new_template = module_target_sat.cli.Template.info({'id': result[0]['id']})
211211
assert new_template['name'] == cloned_template_name
212+
213+
214+
def test_positive_clone_provisioning_template(module_target_sat):
215+
"""Validate provisioning template clone with metadata
216+
217+
:id: e9003c96-ab78-49a8-86cb-3981fd3d11c1
218+
219+
:steps:
220+
1. Select an existing provisioning template.
221+
2. Clone the template with a new name using hammer.
222+
3. Verify the clone message and the cloned-from-id metadata.
223+
4. Delete the cloned template and confirm it no longer exists.
224+
225+
:expectedresults: Report template is cloned with correct metadata and can be deleted.
226+
"""
227+
clone_name = gen_string('alpha', 7)
228+
template = random.choice(module_target_sat.cli.Template.list())
229+
result = module_target_sat.cli.Template.clone(
230+
{'new-name': clone_name, 'id': template['id'], 'name': template['name']}
231+
)
232+
assert 'Provisioning template cloned.' in result[0]['message']
233+
cloned_template = module_target_sat.cli.Template.info(
234+
{'name': clone_name},
235+
output_format='json',
236+
)
237+
assert cloned_template['name'] == clone_name
238+
assert cloned_template['cloned-from-id'] == template['id']
239+
module_target_sat.cli.Template.delete({'name': clone_name})
240+
assert not module_target_sat.cli.Template.exists(search=('name', clone_name))

tests/foreman/cli/test_reporttemplates.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
1212
"""
1313

14+
import random
15+
1416
from broker import Broker
15-
from fauxfactory import gen_alpha
17+
from fauxfactory import gen_alpha, gen_string
1618
import pytest
1719

1820
from robottelo.config import settings
@@ -30,6 +32,7 @@
3032
)
3133
from robottelo.exceptions import CLIFactoryError, CLIReturnCodeError
3234
from robottelo.hosts import ContentHost
35+
from robottelo.utils.issue_handlers import is_open
3336

3437

3538
@pytest.fixture(scope='module')
@@ -1012,3 +1015,40 @@ def test_positive_generate_with_no_rex_interface(
10121015
}
10131016
)
10141017
assert rex_contenthost.hostname in result_html
1018+
1019+
1020+
def test_positive_clone_report_template(module_target_sat):
1021+
"""Validate report template clone along with metadata
1022+
1023+
:id: 27f7826d-bd86-4ebc-be64-684e909961da
1024+
1025+
:steps:
1026+
1. Select an existing report template.
1027+
2. Clone the template with a new name using hammer.
1028+
3. Verify the clone message and the cloned-from-id metadata.
1029+
4. Delete the cloned template and confirm it no longer exists.
1030+
1031+
:expectedresults: Report template is cloned with correct metadata and can be deleted.
1032+
"""
1033+
clone_name = gen_string('alpha', 7)
1034+
template = random.choice(module_target_sat.cli.ReportTemplate.list())
1035+
result = module_target_sat.cli.ReportTemplate.clone(
1036+
{'new-name': clone_name, 'id': template['id'], 'name': template['name']}
1037+
)
1038+
assert result.strip() == 'Report template cloned.'
1039+
cloned_template = module_target_sat.cli.ReportTemplate.info({'name': clone_name})
1040+
assert cloned_template['name'] == clone_name
1041+
assert cloned_template['cloned-from-id'] == template['id']
1042+
if is_open('SAT-42163'):
1043+
module_target_sat.cli.ReportTemplate.update(
1044+
{'id': cloned_template['id'], 'locked': 'false'}
1045+
)
1046+
assert (
1047+
module_target_sat.cli.ReportTemplate.info({'name': cloned_template['name']}).get(
1048+
'locked'
1049+
)
1050+
== 'no'
1051+
)
1052+
module_target_sat.cli.ReportTemplate.delete({'name': clone_name})
1053+
with pytest.raises(CLIReturnCodeError):
1054+
module_target_sat.cli.ReportTemplate.info({'name': clone_name})

0 commit comments

Comments
 (0)