def function_template_combination(module_hostgroup_and_environment): """Create ProvisioningTemplate and TemplateConfiguration for each test and at the end delete ProvisioningTemplate used on tests """ template = entities.ProvisioningTemplate( snippet=False, template_combinations=[{ 'hostgroup_id': module_hostgroup_and_environment['hostgroup'].id, 'environment_id': module_hostgroup_and_environment['env'].id, }], ) template = template.create() template_combination_dct = template.template_combinations[0] template_combination = entities.TemplateCombination( id=template_combination_dct['id'], environment=module_hostgroup_and_environment['env'], provisioning_template=template, hostgroup=module_hostgroup_and_environment['hostgroup'], ) yield {'template': template, 'template_combination': template_combination} # Clean combination if it is not already deleted try: template_combination.delete() except HTTPError: pass template.delete()
def setUp(self): """Create ConfigTemplate and TemplateConfiguration for each test""" super(TemplateCombinationTestCase, self).setUp() self.template = entities.ConfigTemplate( snippet=False, template_combinations=[ {'hostgroup_id': self.hostgroup.id, 'environment_id': self.env.id} ], ) self.template = self.template.create() template_combination_dct = self.template.template_combinations[0] self.template_combination = entities.TemplateCombination( id=template_combination_dct['id'], environment=self.env, config_template=self.template, hostgroup=self.hostgroup, )