def test_ucs_default_present(self, *args): set_module_args(dict(ucs="/root/bigip.localhost.localdomain.ucs")) 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.create_on_device = Mock(return_value=True) mm.exists = Mock(side_effect=[False, True]) results = mm.exec_module() assert results['changed'] is True
def test_ucs_absent_fails(self, *args): set_module_args( dict(ucs="/root/bigip.localhost.localdomain.ucs", state='absent')) 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.remove_from_device = Mock(return_value=True) mm.exists = Mock(side_effect=[True, True]) with self.assertRaises(F5ModuleError) as res: mm.exec_module() assert 'Failed to delete' in str(res.exception)
def test_ucs_installed(self, *args): set_module_args(dict( ucs="/root/bigip.localhost.localdomain.ucs", state='installed' )) 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.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=True) mm.install_on_device = Mock(return_value='1638418523586009') mm._start_task_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert results['task_id'] == '1638418523586009' assert results['message'] == 'UCS load async task started with id: 1638418523586009'