def test_create_snat_pool(self, *args): set_module_args(dict( name='my-snat-pool', state='present', members=['10.10.10.10', '20.20.20.20'], provider=dict( server='localhost', password='******', user='******' ) )) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, required_if=self.spec.required_if ) 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 assert len(results['members']) == 2 assert '/Common/10.10.10.10' in results['members'] assert '/Common/20.20.20.20' in results['members']
def test_create_snat_pool(self, *args): set_module_args(dict( name='my-snat-pool', state='present', members=['10.10.10.10', '20.20.20.20'], 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(side_effect=[False, True]) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert len(results['members']) == 2 assert '/Common/10.10.10.10' in results['members'] assert '/Common/20.20.20.20' in results['members']
def test_update_snat_pool(self, *args): set_module_args(dict( name='asdasd', state='present', members=['30.30.30.30'], provider=dict( server='localhost', password='******', user='******' ) )) current = ApiParameters(params=load_fixture('load_ltm_snatpool.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, required_if=self.spec.required_if ) mm = ModuleManager(module=module) # Override methods to force specific logic in the module to happen mm.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) mm.exists = Mock(return_value=True) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert len(results['members']) == 1 assert '/Common/30.30.30.30' in results['members']
def test_update_snat_pool(self, *args): set_module_args(dict( name='asdasd', state='present', members=['30.30.30.30'], password='******', server='localhost', user='******' )) current = Parameters(params=load_fixture('load_ltm_snatpool.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.read_current_from_device = Mock(return_value=current) mm.update_on_device = Mock(return_value=True) mm.exists = Mock(return_value=True) mm.create_on_device = Mock(return_value=True) results = mm.exec_module() assert results['changed'] is True assert len(results['members']) == 1 assert '/Common/30.30.30.30' in results['members']