def test_update_generic_transport(self, *args): set_module_args( dict(name='gen1', src_port=1024, rules=['/Common/barfoo'], provider=dict(server='localhost', password='******', user='******'))) current = ApiParameters( params=load_fixture('load_generic_transport_config.json')) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode, ) # Override methods in the specific type of manager gm = GenericModuleManager(module=module) gm.exists = Mock(return_value=True) gm.update_on_device = Mock(return_value=True) gm.read_current_from_device = Mock(return_value=current) mm = ModuleManager(module=module) mm.version_less_than_14 = Mock(return_value=False) mm.get_manager = Mock(return_value=gm) results = mm.exec_module() assert results['changed'] is True assert results['src_port'] == 1024 assert results['rules'] == ['/Common/barfoo']
def test_create_generic_transport(self, *args): set_module_args( dict(name='foo', partition='foobar', description='my description', profiles=['genericmsg', 'foo_udp'], src_addr_translation=dict(type='snat', pool='some_pool1'), src_port=1023, rules=['rule1', 'rule2'], provider=dict(server='localhost', password='******', user='******'))) module = AnsibleModule( argument_spec=self.spec.argument_spec, supports_check_mode=self.spec.supports_check_mode) # Override methods in the specific type of manager gm = GenericModuleManager(module=module) gm.exists = Mock(return_value=False) gm.create_on_device = Mock(return_value=True) mm = ModuleManager(module=module) mm.version_less_than_14 = Mock(return_value=False) mm.get_manager = Mock(return_value=gm) results = mm.exec_module() assert results['changed'] is True assert results['description'] == 'my description' assert results['src_addr_translation'] == dict( type='snat', pool='/foobar/some_pool1') assert results['src_port'] == 1023 assert results['rules'] == ['/foobar/rule1', '/foobar/rule2'] assert results['profiles'] == ['/foobar/genericmsg', '/foobar/foo_udp']