Merge "Fix warnings in all snaps-related modules"
[functest-xtesting.git] / functest / tests / unit / openstack / vping / test_vping.py
index a28c61a..42650de 100644 (file)
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
 # Copyright (c) 2017 Cable Television Laboratories, Inc. and others.
 #
 # All rights reserved. This program and the accompanying materials
@@ -6,19 +8,26 @@
 #
 # http://www.apache.org/licenses/LICENSE-2.0
 
+# pylint: disable=missing-docstring
+
+import logging
 import unittest
 
 import mock
 
+from snaps.config.keypair import KeypairConfig
+from snaps.config.network import NetworkConfig, PortConfig, SubnetConfig
+from snaps.config.router import RouterConfig
+from snaps.config.security_group import SecurityGroupConfig
+from snaps.config.vm_inst import VmInstanceConfig
+
 from snaps.openstack.create_image import OpenStackImage
-from snaps.openstack.create_instance import OpenStackVmInstance, \
-    VmInstanceSettings
-from snaps.openstack.create_keypairs import OpenStackKeypair, KeypairSettings
-from snaps.openstack.create_network import OpenStackNetwork, NetworkSettings, \
-    SubnetSettings, PortSettings
-from snaps.openstack.create_router import OpenStackRouter, RouterSettings
-from snaps.openstack.create_security_group import OpenStackSecurityGroup, \
-    SecurityGroupSettings
+from snaps.openstack.create_instance import OpenStackVmInstance
+from snaps.openstack.create_keypairs import OpenStackKeypair
+from snaps.openstack.create_network import OpenStackNetwork
+from snaps.openstack.create_router import OpenStackRouter
+from snaps.openstack.create_security_group import OpenStackSecurityGroup
+
 from snaps.openstack.os_credentials import OSCreds
 
 from functest.core.testcase import TestCase
@@ -40,28 +49,32 @@ class VPingUserdataTesting(unittest.TestCase):
             os_creds=self.os_creds)
 
     @mock.patch('snaps.openstack.utils.deploy_utils.create_vm_instance')
-    @mock.patch('functest.opnfv_tests.openstack.vping.vping_base.os.'
-                'path.exists', return_value=True)
+    @mock.patch('os.path.exists', return_value=True)
     @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
                 return_value=None)
     @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
                 'get_port_ip', return_value='10.0.0.1')
     @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
                 'vm_active', return_value=True)
-    def test_vping_userdata(self, deploy_vm, path_exists, create_flavor,
-                            get_port_ip, vm_active):
+    @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
+                'get_ext_net_name', return_value='foo')
+    def test_vping_userdata(self, *args):
+        # pylint: disable=unused-argument
         with mock.patch('snaps.openstack.utils.deploy_utils.create_image',
                         return_value=OpenStackImage(self.os_creds, None)), \
                 mock.patch('snaps.openstack.utils.deploy_utils.create_network',
                            return_value=OpenStackNetwork(
-                               self.os_creds, NetworkSettings(name='foo'))), \
+                               self.os_creds, NetworkConfig(name='foo'))), \
+                mock.patch('snaps.openstack.utils.deploy_utils.create_router',
+                           return_value=OpenStackRouter(
+                               self.os_creds, RouterConfig(name='foo'))), \
                 mock.patch('snaps.openstack.utils.deploy_utils.'
                            'create_vm_instance',
                            return_value=OpenStackVmInstance(
                                self.os_creds,
-                               VmInstanceSettings(
+                               VmInstanceConfig(
                                    name='foo', flavor='bar',
-                                   port_settings=[PortSettings(
+                                   port_settings=[PortConfig(
                                        name='foo', network_name='bar')]),
                                None)), \
                 mock.patch('snaps.openstack.create_instance.'
@@ -85,8 +98,7 @@ class VPingSSHTesting(unittest.TestCase):
             os_creds=self.os_creds)
 
     @mock.patch('snaps.openstack.utils.deploy_utils.create_vm_instance')
-    @mock.patch('functest.opnfv_tests.openstack.vping.vping_base.os.'
-                'path.exists', return_value=True)
+    @mock.patch('os.path.exists', return_value=True)
     @mock.patch('snaps.openstack.create_flavor.OpenStackFlavor.create',
                 return_value=None)
     @mock.patch('snaps.openstack.create_instance.OpenStackVmInstance.'
@@ -104,10 +116,8 @@ class VPingSSHTesting(unittest.TestCase):
                 'VPingSSH._do_vping_ssh', return_value=TestCase.EX_OK)
     @mock.patch('functest.opnfv_tests.openstack.snaps.snaps_utils.'
                 'get_ext_net_name', return_value='foo')
-    def test_vping_ssh(self, create_vm, path_exists,
-                       flavor_create, get_port_ip, vm_active, ssh_active,
-                       ssh_client, scp_client, trans_script, do_vping_ssh,
-                       ext_net_name):
+    def test_vping_ssh(self, *args):
+        # pylint: disable=unused-argument
         os_vm_inst = mock.MagicMock(name='get_console_output')
         os_vm_inst.get_console_output.return_value = 'vPing OK'
         ssh_client = mock.MagicMock(name='get_transport')
@@ -120,32 +130,32 @@ class VPingSSHTesting(unittest.TestCase):
                 mock.patch('snaps.openstack.utils.deploy_utils.create_network',
                            return_value=OpenStackNetwork(
                                self.os_creds,
-                               NetworkSettings(
+                               NetworkConfig(
                                    name='foo',
                                    subnet_settings=[
-                                       SubnetSettings(
+                                       SubnetConfig(
                                            name='bar',
                                            cidr='10.0.0.1/24')]))), \
                 mock.patch('snaps.openstack.utils.deploy_utils.'
                            'create_vm_instance',
                            return_value=OpenStackVmInstance(
                                self.os_creds,
-                               VmInstanceSettings(
+                               VmInstanceConfig(
                                    name='foo', flavor='bar',
-                                   port_settings=[PortSettings(
+                                   port_settings=[PortConfig(
                                        name='foo', network_name='bar')]),
                                None)), \
                 mock.patch('snaps.openstack.utils.deploy_utils.create_keypair',
                            return_value=OpenStackKeypair(
-                               self.os_creds, KeypairSettings(name='foo'))), \
+                               self.os_creds, KeypairConfig(name='foo'))), \
                 mock.patch('snaps.openstack.utils.deploy_utils.create_router',
                            return_value=OpenStackRouter(
-                               self.os_creds, RouterSettings(name='foo'))), \
+                               self.os_creds, RouterConfig(name='foo'))), \
                 mock.patch('snaps.openstack.utils.deploy_utils.'
                            'create_security_group',
                            return_value=OpenStackSecurityGroup(
                                self.os_creds,
-                               SecurityGroupSettings(name='foo'))), \
+                               SecurityGroupConfig(name='foo'))), \
                 mock.patch('snaps.openstack.create_instance.'
                            'OpenStackVmInstance.'
                            'get_vm_inst', return_value=os_vm_inst), \
@@ -153,3 +163,8 @@ class VPingSSHTesting(unittest.TestCase):
                            'OpenStackVmInstance.'
                            'ssh_client', return_value=ssh_client):
             self.assertEquals(TestCase.EX_OK, self.vping_ssh.run())
+
+
+if __name__ == "__main__":
+    logging.disable(logging.CRITICAL)
+    unittest.main(verbosity=2)