diff options
author | SerenaFeng <feng.xiaowei@zte.com.cn> | 2017-07-14 19:27:44 +0800 |
---|---|---|
committer | Serena Feng <feng.xiaowei@zte.com.cn> | 2017-07-21 13:34:38 +0000 |
commit | 08014f8dea875cdfaf4afbaa80fb26073708327a (patch) | |
tree | cbbf7d6f02d52179453d44cc49ccb48fa32adf67 /testapi/opnfv_testapi/tests/unit | |
parent | c0c8260d5b59bc697573c862cc292c1e5f95d1e9 (diff) |
separate db methods from handler.py
db methods are mingled in handler, which is not well structured
Change-Id: I639679d3fc05a0b6528158186b8bf89e0cd10596
Signed-off-by: SerenaFeng <feng.xiaowei@zte.com.cn>
Diffstat (limited to 'testapi/opnfv_testapi/tests/unit')
-rw-r--r-- | testapi/opnfv_testapi/tests/unit/fake_pymongo.py | 3 | ||||
-rw-r--r-- | testapi/opnfv_testapi/tests/unit/resources/test_base.py | 8 |
2 files changed, 4 insertions, 7 deletions
diff --git a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py index d95ff37..0ca83df 100644 --- a/testapi/opnfv_testapi/tests/unit/fake_pymongo.py +++ b/testapi/opnfv_testapi/tests/unit/fake_pymongo.py @@ -6,9 +6,10 @@ # which accompanies this distribution, and is available at # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +from operator import itemgetter + from bson.objectid import ObjectId from concurrent.futures import ThreadPoolExecutor -from operator import itemgetter def thread_execute(method, *args, **kwargs): diff --git a/testapi/opnfv_testapi/tests/unit/resources/test_base.py b/testapi/opnfv_testapi/tests/unit/resources/test_base.py index 67831f5..dcec4e9 100644 --- a/testapi/opnfv_testapi/tests/unit/resources/test_base.py +++ b/testapi/opnfv_testapi/tests/unit/resources/test_base.py @@ -41,18 +41,14 @@ class TestBase(testing.AsyncHTTPTestCase): self.config_patcher = mock.patch( 'argparse.ArgumentParser.parse_known_args', return_value=(argparse.Namespace(config_file=config), None)) - self.db_patcher = mock.patch('opnfv_testapi.cmd.server.get_db', - self._fake_pymongo) + self.db_patcher = mock.patch('opnfv_testapi.db.api.DB', + fake_pymongo) self.config_patcher.start() self.db_patcher.start() def set_config_file(self): self.config_file = 'normal.ini' - @staticmethod - def _fake_pymongo(): - return fake_pymongo - def get_app(self): from opnfv_testapi.cmd import server return server.make_app() |