def test_update_iapp_template(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args( dict(content=load_fixture('basic-iapp.tmpl'), password='******', server='localhost', user='******')) current1 = Parameters(params=load_fixture( 'load_sys_application_template_w_new_checksum.json')) current2 = Parameters(params=load_fixture( 'load_sys_application_template_w_old_checksum.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[True, True]) mm.create_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current1) mm.template_in_use = Mock(return_value=False) mm._get_temporary_template = Mock(return_value=current2) mm._remove_iapp_checksum = Mock(return_value=None) mm._generate_template_checksum_on_device = Mock(return_value=None) results = mm.exec_module() assert results['changed'] is True
def test_update_iapp_template(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args(dict( content=load_fixture('basic-iapp.tmpl'), password='******', server='localhost', user='******' )) current1 = Parameters(params=load_fixture('load_sys_application_template_w_new_checksum.json')) current2 = Parameters(params=load_fixture('load_sys_application_template_w_old_checksum.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[True, True]) mm.create_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current1) mm.template_in_use = Mock(return_value=False) mm._get_temporary_template = Mock(return_value=current2) mm._remove_iapp_checksum = Mock(return_value=None) mm._generate_template_checksum_on_device = Mock(return_value=None) results = mm.exec_module() assert results['changed'] is True
def test_delete_iapp_template_idempotent(self, *args): set_module_args( dict(content=load_fixture('basic-iapp.tmpl'), password='******', server='localhost', user='******', state='absent')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[False, False]) results = mm.exec_module() assert results['changed'] is False
def test_create_iapp_template(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args( dict(content=load_fixture('basic-iapp.tmpl'), password='******', server='localhost', user='******')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[False, True]) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True
def test_delete_iapp_template_idempotent(self, *args): set_module_args(dict( content=load_fixture('basic-iapp.tmpl'), password='******', server='localhost', user='******', state='absent' )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[False, False]) results = mm.exec_module() assert results['changed'] is False
def test_create_iapp_template(self, *args): # Configure the arguments that would be sent to the Ansible module set_module_args(dict( content=load_fixture('basic-iapp.tmpl'), password='******', server='localhost', user='******' )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.exists = Mock(side_effect=[False, True]) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True