def test_create_selfip(self, *args): set_module_args(dict( address='10.10.10.10', allow_service=[ 'tcp:80', 'udp:53', 'gre' ], name='net1', netmask='255.255.255.0', partition='Common', route_domain='1', state='present', traffic_group='traffic-group-local-only', vlan='net1', 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=[False, True]) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True
def test_create_selfip_idempotent(self, *args): set_module_args(dict( address='10.10.10.10', allow_service=[ 'tcp:80', 'udp:53', 'gre' ], name='net1', netmask='255.255.255.0', partition='Common', route_domain='1', state='present', traffic_group='traffic-group-local-only', vlan='net1', password='******', server='localhost', user='******' )) current = ApiParameters(params=load_fixture('load_tm_net_self.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.exists = Mock(side_effect=[True, True]) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is False