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_api_parameters(self): args = load_fixture('load_generic_transport_config.json') p = ApiParameters(params=args) assert p.name == 'gen1' assert p.partition == 'Common' assert p.profiles == ['/Common/diametersession', '/Common/tcp'] assert p.snat_type == 'snat' assert p.src_port == 0 assert p.snat_pool == '/Common/test_snat' assert p.rules == ['/Common/test']