def test_create_default_device_group(self, *args): set_module_args( dict(name="foo-group", state="present", server='localhost', user='******', password='******')) 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.create_on_device = Mock(return_value=True) mm.exists = Mock(return_value=False) results = mm.exec_module() assert results['changed'] is True
def test_delete_device_group(self, *args): set_module_args( dict(name="foo-group", state="absent", provider=dict(server='localhost', password='******', 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=[True, False]) mm.remove_from_device = Mock(return_value=True) mm.remove_members_in_group_from_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True
def test_update_device_group(self, *args): set_module_args( dict(full_sync=True, name="foo-group", state="present", provider=dict(server='localhost', password='******', user='******'))) current = ApiParameters( params=load_fixture('load_tm_cm_device_group.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.update_on_device = Mock(return_value=True) mm.exists = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is True