Clean up after cnos tests (#45564)

(cherry picked from commit 0b433b3ea9)
(cherry picked from commit 71b3951d09aed385be0771d01ba739348451e720)
pull/45713/merge
Nathaniel Case 6 years ago committed by Toshio Kuratomi
parent 83194a0a99
commit e575f655c1

@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json import json
import os
from ansible.compat.tests.mock import patch from ansible.compat.tests.mock import patch
from ansible.modules.network.cnos import cnos_bgp from ansible.modules.network.cnos import cnos_bgp
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
@ -21,6 +22,7 @@ class TestCnosBgpModule(TestCnosModule):
def tearDown(self): def tearDown(self):
super(TestCnosBgpModule, self).tearDown() super(TestCnosBgpModule, self).tearDown()
self.mock_run_cnos_commands.stop() self.mock_run_cnos_commands.stop()
os.remove('test.log')
def load_fixtures(self, commands=None, transport='cli'): def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_bgp_config.cfg')] self.run_cnos_commands.return_value = [load_fixture('cnos_bgp_config.cfg')]
@ -33,9 +35,6 @@ class TestCnosBgpModule(TestCnosModule):
'bgpArg3': '13', 'bgpArg4': 'address-family', 'bgpArg3': '13', 'bgpArg4': 'address-family',
'bgpArg5': 'ipv4', 'bgpArg6': 'next-hop-self'}) 'bgpArg5': 'ipv4', 'bgpArg6': 'next-hop-self'})
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
file = open('Anil.txt', "a")
file.write(str(result))
file.close()
expected_result = 'BGP configurations accomplished' expected_result = 'BGP configurations accomplished'
self.assertEqual(result['msg'], expected_result) self.assertEqual(result['msg'], expected_result)

@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json import json
import os
from ansible.compat.tests.mock import patch from ansible.compat.tests.mock import patch
from ansible.modules.network.cnos import cnos_interface from ansible.modules.network.cnos import cnos_interface
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
@ -21,6 +22,7 @@ class TestCnosEthernetModule(TestCnosModule):
def tearDown(self): def tearDown(self):
super(TestCnosEthernetModule, self).tearDown() super(TestCnosEthernetModule, self).tearDown()
self.mock_run_cnos_commands.stop() self.mock_run_cnos_commands.stop()
os.remove('test.log')
def load_fixtures(self, commands=None, transport='cli'): def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_ethernet_config.cfg')] self.run_cnos_commands.return_value = [load_fixture('cnos_ethernet_config.cfg')]
@ -31,9 +33,6 @@ class TestCnosEthernetModule(TestCnosModule):
'outputfile': 'test.log', 'interfaceOption': 'ethernet', 'interfaceRange': '33', 'outputfile': 'test.log', 'interfaceOption': 'ethernet', 'interfaceRange': '33',
'interfaceArg1': 'channel-group', 'interfaceArg2': '33', 'interfaceArg3': 'on'}) 'interfaceArg1': 'channel-group', 'interfaceArg2': '33', 'interfaceArg3': 'on'})
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
file = open('Anil.txt', "a")
file.write(str(result))
file.close()
expected_result = 'Interface Configuration is Accomplished' expected_result = 'Interface Configuration is Accomplished'
self.assertEqual(result['msg'], expected_result) self.assertEqual(result['msg'], expected_result)

@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json import json
import os
from ansible.compat.tests.mock import patch from ansible.compat.tests.mock import patch
from ansible.modules.network.cnos import cnos_portchannel from ansible.modules.network.cnos import cnos_portchannel
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
@ -21,6 +22,7 @@ class TestCnosPortchannelModule(TestCnosModule):
def tearDown(self): def tearDown(self):
super(TestCnosPortchannelModule, self).tearDown() super(TestCnosPortchannelModule, self).tearDown()
self.mock_run_cnos_commands.stop() self.mock_run_cnos_commands.stop()
os.remove('test.log')
def load_fixtures(self, commands=None, transport='cli'): def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_portchannel_config.cfg')] self.run_cnos_commands.return_value = [load_fixture('cnos_portchannel_config.cfg')]
@ -31,9 +33,6 @@ class TestCnosPortchannelModule(TestCnosModule):
'outputfile': 'test.log', 'interfaceRange': '33', 'outputfile': 'test.log', 'interfaceRange': '33',
'interfaceArg1': 'channel-group', 'interfaceArg2': '33', 'interfaceArg3': 'on'}) 'interfaceArg1': 'channel-group', 'interfaceArg2': '33', 'interfaceArg3': 'on'})
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
file = open('Anil.txt', "a")
file.write(str(result))
file.close()
expected_result = 'Port Channel Configuration is done' expected_result = 'Port Channel Configuration is done'
self.assertEqual(result['msg'], expected_result) self.assertEqual(result['msg'], expected_result)

@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json import json
import os
from ansible.compat.tests.mock import patch from ansible.compat.tests.mock import patch
from ansible.modules.network.cnos import cnos_vlag from ansible.modules.network.cnos import cnos_vlag
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
@ -21,6 +22,7 @@ class TestCnosVlagModule(TestCnosModule):
def tearDown(self): def tearDown(self):
super(TestCnosVlagModule, self).tearDown() super(TestCnosVlagModule, self).tearDown()
self.mock_run_cnos_commands.stop() self.mock_run_cnos_commands.stop()
os.remove('test.log')
def load_fixtures(self, commands=None, transport='cli'): def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_vlag_config.cfg')] self.run_cnos_commands.return_value = [load_fixture('cnos_vlag_config.cfg')]
@ -30,9 +32,6 @@ class TestCnosVlagModule(TestCnosModule):
'host': '10.241.107.39', 'deviceType': 'g8272_cnos', 'host': '10.241.107.39', 'deviceType': 'g8272_cnos',
'outputfile': 'test.log', 'vlagArg1': 'enable'}) 'outputfile': 'test.log', 'vlagArg1': 'enable'})
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
file = open('Anil.txt', "a")
file.write(str(result))
file.close()
expected_result = 'VLAG configurations accomplished' expected_result = 'VLAG configurations accomplished'
self.assertEqual(result['msg'], expected_result) self.assertEqual(result['msg'], expected_result)

@ -2,6 +2,7 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type __metaclass__ = type
import json import json
import os
from ansible.compat.tests.mock import patch from ansible.compat.tests.mock import patch
from ansible.modules.network.cnos import cnos_vlan from ansible.modules.network.cnos import cnos_vlan
from units.modules.utils import set_module_args from units.modules.utils import set_module_args
@ -21,6 +22,7 @@ class TestCnosVlanModule(TestCnosModule):
def tearDown(self): def tearDown(self):
super(TestCnosVlanModule, self).tearDown() super(TestCnosVlanModule, self).tearDown()
self.mock_run_cnos_commands.stop() self.mock_run_cnos_commands.stop()
os.remove('test.log')
def load_fixtures(self, commands=None, transport='cli'): def load_fixtures(self, commands=None, transport='cli'):
self.run_cnos_commands.return_value = [load_fixture('cnos_vlan_config.cfg')] self.run_cnos_commands.return_value = [load_fixture('cnos_vlan_config.cfg')]
@ -31,9 +33,6 @@ class TestCnosVlanModule(TestCnosModule):
'outputfile': 'test.log', 'vlanArg1': '13', 'outputfile': 'test.log', 'vlanArg1': '13',
'vlanArg2': 'name', 'vlanArg3': 'anil'}) 'vlanArg2': 'name', 'vlanArg3': 'anil'})
result = self.execute_module(changed=True) result = self.execute_module(changed=True)
file = open('Anil.txt', "a")
file.write(str(result))
file.close()
expected_result = 'VLAN configuration is accomplished' expected_result = 'VLAN configuration is accomplished'
self.assertEqual(result['msg'], expected_result) self.assertEqual(result['msg'], expected_result)

Loading…
Cancel
Save