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='******' )) 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(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_idempotent(self, *args): set_module_args(dict( name='asdasd', state='present', members=['1.1.1.1', '2.2.2.2'], password='******', server='localhost', user='******' )) current = Parameters(load_fixture('load_ltm_snatpool.json')) 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(side_effect=[True, True]) mm.read_current_from_device = Mock(return_value=current) results = mm.exec_module() assert results['changed'] is False
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(load_fixture('load_ltm_snatpool.json')) 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.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']