Move tests: unit/apiserver/ 71/48271/6
authorEmma Foley <emma.l.foley@intel.com>
Wed, 29 Nov 2017 23:01:33 +0000 (23:01 +0000)
committerRoss Brattain <ross.b.brattain@intel.com>
Thu, 11 Jan 2018 20:55:26 +0000 (20:55 +0000)
* Fix pylint errors
* Add TODOs

Some errors are ignored locally, as they were a symptom of other problems.
These issues have been flagged with a TODO, and should be fixed later.

JIRA: YARDSTICK-837
Signed-off-by: Emma Foley <emma.l.foley@intel.com>
Change-Id: I30d3f61e5ea479758f9a2f39cf415da18e49b9d6

yardstick/tests/unit/apiserver/__init__.py [moved from tests/unit/apiserver/__init__.py with 65% similarity]
yardstick/tests/unit/apiserver/resources/__init__.py [moved from tests/unit/apiserver/resources/__init__.py with 100% similarity]
yardstick/tests/unit/apiserver/resources/test_env_action.py [moved from tests/unit/apiserver/resources/test_env_action.py with 92% similarity]
yardstick/tests/unit/apiserver/utils/test_influx.py [moved from tests/unit/apiserver/utils/test_influx.py with 91% similarity]

similarity index 65%
rename from tests/unit/apiserver/__init__.py
rename to yardstick/tests/unit/apiserver/__init__.py
index 5e1ed2e..44d1634 100644 (file)
@@ -1,3 +1,12 @@
+##############################################################################
+# Copyright (c) 2017
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+"""Tests for yardstick/api/server.py"""
 from __future__ import absolute_import
 
 import mock
@@ -12,14 +21,16 @@ from yardstick.common import constants as consts
 
 
 class APITestCase(unittest.TestCase):
-
+    """Tests for the YardStick API server"""
     def setUp(self):
         self.db_fd, self.db_path = tempfile.mkstemp()
         consts.SQLITE = 'sqlite:///{}'.format(self.db_path)
 
-        # server calls gethostbyname which takes 4 seconds, and we should mock it anyway
+        # server calls gethostbyname which takes 4 seconds, and we should mock
+        # it anyway
         self.socket_mock = mock.patch.dict("sys.modules", {"socket": mock.MagicMock(
-            **{"gethostbyname.return_value": "127.0.0.1", "gethostname.return_value": "localhost"})})
+            **{"gethostbyname.return_value": "127.0.0.1",
+               "gethostname.return_value": "localhost"})})
         self.socket_mock.start()
         try:
             from api import server
@@ -6,12 +6,11 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-from __future__ import absolute_import
 
 import time
 import unittest
 
-from tests.unit.apiserver import APITestCase
+from yardstick.tests.unit.apiserver import APITestCase
 
 
 class EnvTestCase(APITestCase):
@@ -6,13 +6,11 @@
 # which accompanies this distribution, and is available at
 # http://www.apache.org/licenses/LICENSE-2.0
 ##############################################################################
-from __future__ import absolute_import
 import unittest
 import mock
 
 from api.utils import influx
-
-import six.moves.configparser as ConfigParser
+from six.moves import configparser as ConfigParser
 
 
 class GetDataDbClientTestCase(unittest.TestCase):
@@ -25,7 +23,7 @@ class GetDataDbClientTestCase(unittest.TestCase):
         mock_parser.NoOptionError = ConfigParser.NoOptionError
         try:
             influx.get_data_db_client()
-        except Exception as e:
+        except Exception as e:  # pylint: disable=broad-except
             self.assertIsInstance(e, RuntimeError)
 
 
@@ -50,7 +48,7 @@ class QueryTestCase(unittest.TestCase):
         try:
             sql = 'select * form tasklist'
             influx.query(sql)
-        except Exception as e:
+        except Exception as e:  # pylint: disable=broad-except
             self.assertIsInstance(e, RuntimeError)