]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Cosmetic changes to unit tests for client library.
authorSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Thu, 4 Aug 2011 15:56:46 +0000 (16:56 +0100)
committerSalvatore Orlando <salvatore.orlando@eu.citrix.com>
Thu, 4 Aug 2011 15:56:46 +0000 (16:56 +0100)
Pep8 fixes.

quantum/api/__init__.py
quantum/api/views/attachments.py
quantum/api/views/networks.py
quantum/db/api.py
tests/unit/test_clientlib.py [moved from tests/unit/api.py with 83% similarity]

index 0e914dbee703d52e19064f86b171173b88a96563..6abb6bed7805b7a8abf8fc9c749c94a1d37e0cfb 100644 (file)
@@ -61,9 +61,9 @@ class APIRouterV01(wsgi.Router):
                         parent_resource=dict(member_name='network',
                                              collection_name=uri_prefix +\
                                                  'networks'))
-        
+
         attachments_ctrl = attachments.Controller(plugin)
-        
+
         mapper.connect("get_resource",
                        uri_prefix + 'networks/{network_id}/' \
                                     'ports/{id}/attachment{.format}',
index f2d22039b34f521165bb3f368c0c5e5afbfdd52d..955495889652b2cfc2d2dd3a1a270b9a0dcfed07 100644 (file)
@@ -33,5 +33,5 @@ class ViewBuilder(object):
         """Generic method used to generate an attachment entity."""
         if attachment_data['attachment-id']:
             return dict(attachment=dict(id=attachment_data['attachment-id']))
-        else: 
+        else:
             return dict(attachment={})
index 94fac5eddc70fdfbb14d06cbe28a803832082e4f..5efb425eafdeda81bf5e1c93f0f05eb60e0b34c8 100644 (file)
@@ -15,9 +15,6 @@
 #    License for the specific language governing permissions and limitations
 #    under the License.
 
-import logging
-
-LOG = logging.getLogger('quantum.api.views.networks')
 
 def get_view_builder(req):
     base_url = req.application_url
@@ -32,7 +29,8 @@ class ViewBuilder(object):
         """
         self.base_url = base_url
 
-    def build(self, network_data, net_detail=False, ports_data=None, port_detail=False):
+    def build(self, network_data, net_detail=False,
+              ports_data=None, port_detail=False):
         """Generic method used to generate a network entity."""
         if net_detail:
             network = self._build_detail(network_data)
@@ -41,7 +39,6 @@ class ViewBuilder(object):
         if port_detail:
             ports = [self._build_port(port_data) for port_data in ports_data]
             network['network']['ports'] = ports
-        LOG.debug("NETWORK:%s", network)
         return network
 
     def _build_simple(self, network_data):
@@ -59,4 +56,4 @@ class ViewBuilder(object):
                          state=port_data['port-state'])
         if port_data['attachment-id']:
             port_dict['attachment'] = dict(id=port_data['attachment-id'])
-        return port_dict 
+        return port_dict
index 3b065ea65bcf76ed64f676ef3a26194e605cb7f9..ebdc3cb1ae2bac858596a0a77e7353b2855daa1f 100644 (file)
@@ -17,7 +17,7 @@
 # @author: Brad Hall, Nicira Networks, Inc.
 # @author: Dan Wendlandt, Nicira Networks, Inc.
 
-import logging 
+import logging
 
 from sqlalchemy import create_engine
 from sqlalchemy.orm import sessionmaker, exc
@@ -27,7 +27,8 @@ from quantum.db import models
 _ENGINE = None
 _MAKER = None
 BASE = models.BASE
-LOG = logging.getLogger('quantum.plugins.SamplePlugin')
+LOG = logging.getLogger('quantum.db.api')
+
 
 def configure_db(options):
     """
similarity index 83%
rename from tests/unit/api.py
rename to tests/unit/test_clientlib.py
index aed6c4bacf57ad90cf0609cc32eeda31f9ea2fa9..eab58b2bd5369ce0e9222b4b4971a120d76583e0 100644 (file)
@@ -23,7 +23,7 @@ import re
 from quantum.common.wsgi import Serializer
 from quantum.client import Client
 
-LOG = logging.getLogger('quantum.tests.test_api')
+LOG = logging.getLogger('quantum.tests.test_cliet')
 
 # Set a couple tenants to use for testing
 TENANT_1 = 'totore'
@@ -43,7 +43,7 @@ class ServerStub():
             return self.content
 
         def status(self):
-            return status
+            return self.status
 
     # To test error codes, set the host to 10.0.0.1, and the port to the code
     def __init__(self, host, port=9696, key_file="", cert_file=""):
@@ -88,7 +88,7 @@ class ServerStub():
         return res
 
 
-class APITest(unittest.TestCase):
+class ClientLibTest(unittest.TestCase):
 
     def setUp(self):
         """ Setups a test environment for the API client """
@@ -118,8 +118,8 @@ class APITest(unittest.TestCase):
         return data
 
     def _test_list_networks(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_list_networks - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_list_networks - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.list_networks,
                             status,
@@ -128,13 +128,13 @@ class APITest(unittest.TestCase):
                             data=[],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_list_networks - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_list_networks - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
-    def _test_list_network_details(self,
-                                   tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_list_network_details - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+    def _test_list_network_details(self, tenant=TENANT_1,
+                                   format='json', status=200):
+        LOG.debug("_test_list_network_details - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.list_network_details,
                             status,
@@ -143,12 +143,12 @@ class APITest(unittest.TestCase):
                             data=["001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_list_network_details - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_list_network_details - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_create_network(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_create_network - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_create_network - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.create_network,
                             status,
@@ -157,12 +157,12 @@ class APITest(unittest.TestCase):
                             data=[{'network': {'net-name': 'testNetwork'}}],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_create_network - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_create_network - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_update_network(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_update_network - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_update_network - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.update_network,
                             status,
@@ -172,12 +172,12 @@ class APITest(unittest.TestCase):
                                   {'network': {'net-name': 'newName'}}],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_update_network - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_update_network - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_delete_network(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_delete_network - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_delete_network - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.delete_network,
                             status,
@@ -186,12 +186,12 @@ class APITest(unittest.TestCase):
                             data=["001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_delete_network - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_delete_network - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_list_ports(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_list_ports - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_list_ports - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.list_ports,
                             status,
@@ -200,13 +200,13 @@ class APITest(unittest.TestCase):
                             data=["001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_list_ports - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_list_ports - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_list_port_details(self,
                                 tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_list_port_details - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_list_port_details - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.list_port_details,
                             status,
@@ -215,12 +215,12 @@ class APITest(unittest.TestCase):
                             data=["001", "001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_list_port_details - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_list_port_details - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_create_port(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_create_port - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_create_port - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.create_port,
                             status,
@@ -229,12 +229,12 @@ class APITest(unittest.TestCase):
                             data=["001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_create_port - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_create_port - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_delete_port(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_delete_port - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_delete_port - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.delete_port,
                             status,
@@ -243,12 +243,12 @@ class APITest(unittest.TestCase):
                             data=["001", "001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_delete_port - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_delete_port - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_set_port_state(self, tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_set_port_state - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_set_port_state - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.set_port_state,
                             status,
@@ -258,13 +258,13 @@ class APITest(unittest.TestCase):
                                   {'port': {'state': 'ACTIVE'}}],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_set_port_state - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_set_port_state - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_list_port_attachments(self,
                                    tenant=TENANT_1, format='json', status=200):
-        LOG.debug("_test_list_port_attachments - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_list_port_attachments - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.list_port_attachments,
                             status,
@@ -273,13 +273,13 @@ class APITest(unittest.TestCase):
                             data=["001", "001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_list_port_attachments - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_list_port_attachments - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_attach_resource(self, tenant=TENANT_1,
                               format='json', status=200):
-        LOG.debug("_test_attach_resource - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_attach_resource - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.attach_resource,
                             status,
@@ -289,13 +289,13 @@ class APITest(unittest.TestCase):
                                     {'resource': {'id': '1234'}}],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_attach_resource - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_attach_resource - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_detach_resource(self, tenant=TENANT_1,
                               format='json', status=200):
-        LOG.debug("_test_detach_resource - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_detach_resource - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         self._assert_sanity(self.client.detach_resource,
                             status,
@@ -304,13 +304,13 @@ class APITest(unittest.TestCase):
                             data=["001", "001"],
                             params={'tenant': tenant, 'format': format})
 
-        LOG.debug("_test_detach_resource - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_detach_resource - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def _test_ssl_certificates(self, tenant=TENANT_1,
                                format='json', status=200):
-        LOG.debug("_test_ssl_certificates - tenant:%s "\
-                  "- format:%s - START", format, tenant)
+        LOG.debug("_test_ssl_certificates - tenant:%(tenant)s "\
+                  "- format:%(format)s - START" % locals())
 
         # Set SSL, and our cert file
         self.client.use_ssl = True
@@ -327,8 +327,8 @@ class APITest(unittest.TestCase):
         self.assertEquals(data["key_file"], cert_file)
         self.assertEquals(data["cert_file"], cert_file)
 
-        LOG.debug("_test_ssl_certificates - tenant:%s "\
-                  "- format:%s - END", format, tenant)
+        LOG.debug("_test_ssl_certificates - tenant:%(tenant)s "\
+                  "- format:%(format)s - END" % locals())
 
     def test_list_networks_json(self):
         self._test_list_networks(format='json')