def test_ucs_absent_fails(self, *args): set_module_args(dict( ucs="/root/bigip.localhost.localdomain.ucs", state='absent', provider=dict( server='localhost', password='******', user='******' ) )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods to force specific logic in the module to happen mm = ModuleManager(module=module) mm.is_version_v1 = Mock(return_value=False) vm = V1Manager(module=module) vm.remove_from_device = Mock(return_value=True) vm.exists = Mock(side_effect=[True, True]) with pytest.raises(F5ModuleError) as ex: vm.exec_module() assert 'Failed to delete' in str(ex.value)
def test_ucs_absent_exists(self, *args): set_module_args(dict( ucs="/root/bigip.localhost.localdomain.ucs", state='absent', provider=dict( server='localhost', password='******', user='******' ) )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode ) # Override methods to force specific logic in the module to happen mm = ModuleManager(module=module) mm.is_version_v1 = Mock(return_value=False) vm = V1Manager(module=module) vm.remove_from_device = Mock(return_value=True) vm.exists = Mock(side_effect=[True, False]) results = vm.exec_module() assert results['changed'] is True