def test_delete(self, *args): set_module_args(dict( name='test-route', state='absent', provider=dict( server='localhost', password='******', user='******' ) )) 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(side_effect=[True, False]) mm.remove_from_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert 'description' not in results
def test_create_with_route_domain(self, *args): set_module_args(dict( name='test-route', state='present', destination='10.10.10.10', netmask='255.255.255.255', route_domain=1, reject='yes', provider=dict( server='localhost', password='******', user='******' ) )) 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_update_description_idempotent(self, *args): set_module_args(dict( name='test-route', state='present', description='asdasd', provider=dict( server='localhost', password='******', user='******' ) )) 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 current = ApiParameters(params=load_fixture('load_net_route_description.json')) 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() # There is no assert for the description, because it should # not have changed assert results['changed'] is False