def test_update_agent_status_traps(self, *args): parameters = load_fixture( 'update_iapp_service_parameters_f5_http.json') set_module_args( dict(name='foo', template='f5.http', parameters=parameters, state='present', password='******', server='localhost', user='******')) # Configure the parameters that would be returned by querying the # remote device parameters = load_fixture( 'create_iapp_service_parameters_f5_http.json') current = Parameters(parameters) client = AnsibleF5Client( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, f5_product_name=self.spec.f5_product_name) mm = ModuleManager(client) # Override methods to force specific logic in the module to happen mm.exists = Mock(return_value=True) mm.update_on_device = Mock(return_value=True) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is True
def test_update_description_idempotent(self): set_module_args( dict(name='test-route', password='******', server='localhost', user='******', state='present', description='asdasd')) mut._CONNECTION = True module = F5AnsibleModule() obj = ModuleManager(module=module) # Override methods to force specific logic in the module to happen current = load_fixture('load_net_route_description.json') obj.exists = lambda: True obj.update_on_device = lambda x: True obj.exit_json = lambda x: True obj.read_current_from_device = lambda x: current results = obj.apply_changes() # There is no assert for the description, because it should # not have changed assert results['changed'] is False assert results['partition'] == 'Common'
def test_delete(self): set_module_args( dict(name='test-route', password='******', server='localhost', user='******', state='absent')) mut._CONNECTION = True module = F5AnsibleModule() obj = ModuleManager(module=module) # Override methods to force specific logic in the module to happen obj.exists = Mock() obj.exists.side_effect = [True, False] obj.remove_from_device = lambda: True obj.exit_json = lambda x: True results = obj.apply_changes() assert results['changed'] is True assert 'description' not in results
def test_create_service(self, *args): parameters = load_fixture( 'create_iapp_service_parameters_f5_http.json') set_module_args( dict(name='foo', template='f5.http', parameters=parameters, state='present', 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(return_value=False) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True
def test_create_route_to_pool(self): set_module_args( dict(name='test-route', password='******', server='localhost', user='******', state='present', destination='10.10.10.10', pool="test-pool")) mut._CONNECTION = True module = F5AnsibleModule() obj = ModuleManager(module=module) # Override methods to force specific logic in the module to happen obj.exists = lambda: False obj.create_on_device = lambda x: True obj.exit_json = lambda x: True results = obj.apply_changes() assert results['changed'] is True assert results['pool'] == 'test-pool' assert results['partition'] == 'Common'
def test_create_service_from_file(self): parameters = load_fixture('load_net_route_description.json') set_module_args( dict(name='test-route', password='******', server='localhost', user='******', state='present', template='f5.http', parameters=parameters)) mut._CONNECTION = True module = F5AnsibleModule() obj = ModuleManager(module=module) # Override methods to force specific logic in the module to happen obj.exists = lambda: False obj.create_on_device = lambda x: True obj.exit_json = lambda x: True results = obj.apply_changes() assert results['changed'] is True assert results['reject'] == 'yes' assert results['partition'] == 'Common'