Test multiple nxos versions at once (#25595)
* Extend tests to have multiple device representations * Move filepath munging to nxos_module * Device needs to be kwarg so we can leave it off * Update other nxos tests * Update tests that fell through
This commit is contained in:
parent
79b2897462
commit
3d6d428bbc
30 changed files with 86 additions and 72 deletions
|
@ -0,0 +1,2 @@
|
||||||
|
nxapi enabled
|
||||||
|
HTTP Listen on port 80
|
|
@ -36,8 +36,10 @@ fixture_path = os.path.join(os.path.dirname(__file__), 'fixtures')
|
||||||
fixture_data = {}
|
fixture_data = {}
|
||||||
|
|
||||||
|
|
||||||
def load_fixture(name):
|
def load_fixture(module_name, name, device=''):
|
||||||
path = os.path.join(fixture_path, name)
|
path = os.path.join(fixture_path, module_name, device, name)
|
||||||
|
if not os.path.exists(path):
|
||||||
|
path = os.path.join(fixture_path, module_name, name)
|
||||||
|
|
||||||
if path in fixture_data:
|
if path in fixture_data:
|
||||||
return fixture_data[path]
|
return fixture_data[path]
|
||||||
|
@ -64,9 +66,27 @@ class AnsibleFailJson(Exception):
|
||||||
|
|
||||||
class TestNxosModule(unittest.TestCase):
|
class TestNxosModule(unittest.TestCase):
|
||||||
|
|
||||||
def execute_module(self, failed=False, changed=False, commands=None, sort=True, defaults=False):
|
def execute_module_devices(self, failed=False, changed=False, commands=None, sort=True, defaults=False):
|
||||||
|
module_name = self.module.__name__.rsplit('.', 1)[1]
|
||||||
|
local_fixture_path = os.path.join(fixture_path, module_name)
|
||||||
|
|
||||||
self.load_fixtures(commands)
|
models = []
|
||||||
|
for path in os.listdir(local_fixture_path):
|
||||||
|
path = os.path.join(local_fixture_path, path)
|
||||||
|
if os.path.isdir(path):
|
||||||
|
models.append(os.path.basename(path))
|
||||||
|
if not models:
|
||||||
|
models = ['']
|
||||||
|
|
||||||
|
retvals = {}
|
||||||
|
for model in models:
|
||||||
|
retvals[model] = self.execute_module(failed, changed, commands, sort, device=model)
|
||||||
|
|
||||||
|
return retvals
|
||||||
|
|
||||||
|
def execute_module(self, failed=False, changed=False, commands=None, sort=True, device=''):
|
||||||
|
|
||||||
|
self.load_fixtures(commands, device=device)
|
||||||
|
|
||||||
if failed:
|
if failed:
|
||||||
result = self.failed()
|
result = self.failed()
|
||||||
|
@ -110,5 +130,5 @@ class TestNxosModule(unittest.TestCase):
|
||||||
self.assertEqual(result['changed'], changed, result)
|
self.assertEqual(result['changed'], changed, result)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestNxosAclModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
@ -52,9 +52,8 @@ class TestNxosAclModule(TestNxosModule):
|
||||||
command = obj['command']
|
command = obj['command']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
command = item
|
command = item
|
||||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
filename = '%s.txt' % str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = 'nxos_acl/%s.txt' % filename
|
output.append(load_fixture('nxos_acl', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestNxosAclInterfaceModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
@ -52,9 +52,8 @@ class TestNxosAclInterfaceModule(TestNxosModule):
|
||||||
command = obj['command']
|
command = obj['command']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
command = item
|
command = item
|
||||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
filename = '%s.txt' % str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = 'nxos_acl_interface/%s.txt' % filename
|
output.append(load_fixture('nxos_acl_interface', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
|
|
@ -39,7 +39,7 @@ class TestNxosBannerModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = dict(diff=None, session='session')
|
self.load_config.return_value = dict(diff=None, session='session')
|
||||||
|
|
||||||
def test_nxos_banner_create(self):
|
def test_nxos_banner_create(self):
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TestNxosBgpModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_bgp_config.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_bgp_config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_bgp(self):
|
def test_nxos_bgp(self):
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TestNxosBgpAfModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_bgp_config.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_bgp_config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_bgp_af(self):
|
def test_nxos_bgp_af(self):
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TestNxosBgpNeighborModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_bgp_config.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_bgp_config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_bgp_neighbor(self):
|
def test_nxos_bgp_neighbor(self):
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TestNxosBgpNeighborAfModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_bgp_config.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_bgp_config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_bgp_neighbor_af(self):
|
def test_nxos_bgp_neighbor_af(self):
|
||||||
|
|
|
@ -37,7 +37,7 @@ class TestNxosCommandModule(TestNxosModule):
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
@ -48,9 +48,8 @@ class TestNxosCommandModule(TestNxosModule):
|
||||||
command = obj['command']
|
command = obj['command']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
command = item['command']
|
command = item['command']
|
||||||
filename = str(command).replace(' ', '_')
|
filename = '%s.txt' % str(command).replace(' ', '_')
|
||||||
filename = 'nxos_command/%s.txt' % filename
|
output.append(load_fixture('nxos_command', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
|
|
@ -43,8 +43,8 @@ class TestNxosConfigModule(TestNxosModule):
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_config/config.cfg')
|
self.get_config.return_value = load_fixture('nxos_config', 'config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_config_no_change(self):
|
def test_nxos_config_no_change(self):
|
||||||
|
@ -53,7 +53,7 @@ class TestNxosConfigModule(TestNxosModule):
|
||||||
result = self.execute_module()
|
result = self.execute_module()
|
||||||
|
|
||||||
def test_nxos_config_src(self):
|
def test_nxos_config_src(self):
|
||||||
args = dict(src=load_fixture('nxos_config/candidate.cfg'))
|
args = dict(src=load_fixture('nxos_config', 'candidate.cfg'))
|
||||||
set_module_args(args)
|
set_module_args(args)
|
||||||
|
|
||||||
result = self.execute_module(changed=True)
|
result = self.execute_module(changed=True)
|
||||||
|
|
|
@ -41,15 +41,15 @@ class TestNxosEvpnGlobalModule(TestNxosModule):
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def start_configured(self, *args, **kwargs):
|
def start_configured(self, *args, **kwargs):
|
||||||
self.get_config.return_value = load_fixture('nxos_evpn_global/configured.cfg')
|
self.get_config.return_value = load_fixture('nxos_evpn_global', 'configured.cfg')
|
||||||
return self.execute_module(*args, **kwargs)
|
return self.execute_module(*args, **kwargs)
|
||||||
|
|
||||||
def start_unconfigured(self, *args, **kwargs):
|
def start_unconfigured(self, *args, **kwargs):
|
||||||
self.get_config.return_value = load_fixture('nxos_evpn_global/unconfigured.cfg')
|
self.get_config.return_value = load_fixture('nxos_evpn_global', 'unconfigured.cfg')
|
||||||
return self.execute_module(*args, **kwargs)
|
return self.execute_module(*args, **kwargs)
|
||||||
|
|
||||||
def test_nxos_evpn_global_enable(self):
|
def test_nxos_evpn_global_enable(self):
|
||||||
|
|
|
@ -45,8 +45,8 @@ class TestNxosEvpnVniModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_evpn_vni_config.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_evpn_vni_config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_evpn_vni_present(self):
|
def test_nxos_evpn_vni_present(self):
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestNxosFeatureModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
@ -52,9 +52,8 @@ class TestNxosFeatureModule(TestNxosModule):
|
||||||
command = obj['command']
|
command = obj['command']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
command = item['command']
|
command = item['command']
|
||||||
filename = str(command).replace(' ', '_')
|
filename = '%s.txt' % str(command).replace(' ', '_')
|
||||||
filename = 'nxos_feature/%s.txt' % filename
|
output.append(load_fixture('nxos_feature', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestNxosHsrpModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_hsrp(self):
|
def test_nxos_hsrp(self):
|
||||||
|
|
|
@ -45,7 +45,7 @@ class TestNxosInterfaceModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_interface_up(self):
|
def test_nxos_interface_up(self):
|
||||||
|
|
|
@ -47,9 +47,9 @@ class TestNxosIPInterfaceModule(TestNxosModule):
|
||||||
self.mock_send_show_command.stop()
|
self.mock_send_show_command.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_interface_mode.return_value = 'layer3'
|
self.get_interface_mode.return_value = 'layer3'
|
||||||
self.send_show_command.return_value = [load_fixture('nxos_ip_interface.cfg')]
|
self.send_show_command.return_value = [load_fixture('', 'nxos_ip_interface.cfg')]
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_ip_interface_ip_present(self):
|
def test_nxos_ip_interface_ip_present(self):
|
||||||
|
|
|
@ -42,15 +42,15 @@ class TestNxosNxapiModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
module_name = self.module.__name__.rsplit('.', 1)[1]
|
||||||
|
|
||||||
|
output = list()
|
||||||
for command in commands:
|
for command in commands:
|
||||||
filename = str(command).replace(' ', '_')
|
filename = str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = os.path.join('nxos_nxapi', filename)
|
output.append(load_fixture(module_name, filename, device))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
@ -58,12 +58,12 @@ class TestNxosNxapiModule(TestNxosModule):
|
||||||
|
|
||||||
def test_nxos_nxapi_no_change(self):
|
def test_nxos_nxapi_no_change(self):
|
||||||
set_module_args(dict(http=True, https=False, http_port=80, https_port=443, sandbox=False))
|
set_module_args(dict(http=True, https=False, http_port=80, https_port=443, sandbox=False))
|
||||||
self.execute_module(changed=False, commands=[])
|
self.execute_module_devices(changed=False, commands=[])
|
||||||
|
|
||||||
def test_nxos_nxapi_disable(self):
|
def test_nxos_nxapi_disable(self):
|
||||||
set_module_args(dict(state='absent'))
|
set_module_args(dict(state='absent'))
|
||||||
self.execute_module(changed=True, commands=['no feature nxapi'])
|
self.execute_module_devices(changed=True, commands=['no feature nxapi'])
|
||||||
|
|
||||||
def test_nxos_nxapi_no_http(self):
|
def test_nxos_nxapi_no_http(self):
|
||||||
set_module_args(dict(https=True, http=False, https_port=8443))
|
set_module_args(dict(https=True, http=False, https_port=8443))
|
||||||
self.execute_module(changed=True, commands=['no nxapi http', 'nxapi https port 8443'])
|
self.execute_module_devices(changed=True, commands=['no nxapi http', 'nxapi https port 8443'])
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestNxosOspfModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_ospf_present(self):
|
def test_nxos_ospf_present(self):
|
||||||
|
|
|
@ -41,7 +41,7 @@ class TestNxosOspfVrfModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_ospf_vrf_present(self):
|
def test_nxos_ospf_vrf_present(self):
|
||||||
|
|
|
@ -45,7 +45,7 @@ class TestNxosPortchannelModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_portchannel(self):
|
def test_nxos_portchannel(self):
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TestNxosStaticRouteModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_static_route.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_static_route.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_static_route_present(self):
|
def test_nxos_static_route_present(self):
|
||||||
|
|
|
@ -41,8 +41,8 @@ class TestNxosSystemModule(TestNxosModule):
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_system_config.cfg')
|
self.get_config.return_value = load_fixture('', 'nxos_system_config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_system_hostname_changed(self):
|
def test_nxos_system_hostname_changed(self):
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TestNxosVlanModule(TestNxosModule):
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
@ -55,9 +55,8 @@ class TestNxosVlanModule(TestNxosModule):
|
||||||
command = obj['command']
|
command = obj['command']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
command = item
|
command = item
|
||||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
filename = '%s.txt' % str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = 'nxos_vlan/%s.txt' % filename
|
output.append(load_fixture('nxos_vlan', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
|
|
@ -41,15 +41,14 @@ class TestNxosVpcModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
|
||||||
for command in commands:
|
for command in commands:
|
||||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
filename = str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = os.path.join('nxos_vpc', filename)
|
output.append(load_fixture('nxos_vpc', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
|
@ -45,14 +45,13 @@ class TestNxosVpcModule(TestNxosModule):
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
for command in commands:
|
for command in commands:
|
||||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
filename = str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = os.path.join('nxos_vpc_interface', filename)
|
output.append(load_fixture('nxos_vpc_interface', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.run_commands.side_effect = load_from_file
|
self.run_commands.side_effect = load_from_file
|
||||||
|
|
|
@ -41,15 +41,14 @@ class TestNxosVrfModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_run_commands.stop()
|
self.mock_run_commands.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
def load_from_file(*args, **kwargs):
|
def load_from_file(*args, **kwargs):
|
||||||
module, commands = args
|
module, commands = args
|
||||||
output = list()
|
output = list()
|
||||||
|
|
||||||
for command in commands:
|
for command in commands:
|
||||||
filename = str(command).split(' | ')[0].replace(' ', '_')
|
filename = str(command).split(' | ')[0].replace(' ', '_')
|
||||||
filename = os.path.join('nxos_vrf', filename)
|
output.append(load_fixture('nxos_vrf', filename))
|
||||||
output.append(load_fixture(filename))
|
|
||||||
return output
|
return output
|
||||||
|
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
|
@ -44,7 +44,7 @@ class TestNxosVrfafModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
self.mock_get_config.stop()
|
self.mock_get_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_vrf_af_present(self):
|
def test_nxos_vrf_af_present(self):
|
||||||
|
|
|
@ -42,7 +42,7 @@ class TestNxosVxlanVtepVniModule(TestNxosModule):
|
||||||
self.mock_load_config.stop()
|
self.mock_load_config.stop()
|
||||||
|
|
||||||
def load_fixtures(self, commands=None, device=''):
|
def load_fixtures(self, commands=None, device=''):
|
||||||
self.get_config.return_value = load_fixture('nxos_vxlan_vtep/config.cfg')
|
self.get_config.return_value = load_fixture('nxos_vxlan_vtep', 'config.cfg')
|
||||||
self.load_config.return_value = None
|
self.load_config.return_value = None
|
||||||
|
|
||||||
def test_nxos_vxlan_vtep(self):
|
def test_nxos_vxlan_vtep(self):
|
||||||
|
|
Loading…
Reference in a new issue