def test_create_with_route_domain(self, *args): set_module_args( dict(name='test-route', password='******', server='localhost', user='******', state='present', destination='10.10.10.10', netmask='255.255.255.255', route_domain=1, reject='yes')) module = AnsibleModule( argument_spec=self.spec.argument_spec, mutually_exclusive=self.spec.mutually_exclusive, 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 assert results['route_domain'] == 1 assert results['destination'] == '10.10.10.10%1/32'
def test_create_route_to_vlan(self, *args): set_module_args(dict( name='test-route', password='******', server='localhost', user='******', state='present', destination='10.10.10.10', vlan="test-vlan" )) module = AnsibleModule( argument_spec=self.spec.argument_spec, mutually_exclusive=self.spec.mutually_exclusive, 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 assert results['vlan'] == '/Common/test-vlan'
def test_create_blackhole(self, *args): set_module_args( dict(name='test-route', password='******', server='localhost', user='******', state='present', destination='10.10.10.10', reject='yes')) client = AnsibleF5Client( argument_spec=self.spec.argument_spec, mutually_exclusive=self.spec.mutually_exclusive, 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=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" )) bigip_static_route._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'