summaryrefslogtreecommitdiffstats
path: root/utils/test/testapi/opnfv_testapi/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'utils/test/testapi/opnfv_testapi/tests/unit')
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/executor.py2
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/__init__.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py)0
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json)0
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json)0
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_base.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py)6
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_pod.py)4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_project.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_project.py)4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_result.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py)8
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py)4
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py)6
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_token.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py)2
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_version.py (renamed from utils/test/testapi/opnfv_testapi/tests/unit/resources/test_version.py)6
-rw-r--r--utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py123
13 files changed, 21 insertions, 144 deletions
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/executor.py b/utils/test/testapi/opnfv_testapi/tests/unit/executor.py
index aa99b9086..743c07615 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/executor.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/executor.py
@@ -14,7 +14,7 @@ import mock
O_get_secure_cookie = (
- 'opnfv_testapi.resources.handlers.GenericApiHandler.get_secure_cookie')
+ 'opnfv_testapi.handlers.base_handlers.GenericApiHandler.get_secure_cookie')
def thread_execute(method, *args, **kwargs):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/__init__.py
index e69de29bb..e69de29bb 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/__init__.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/__init__.py
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json
index 187802215..187802215 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c1.json
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/scenario-c1.json
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json
index 980051c4f..980051c4f 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/scenario-c2.json
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/scenario-c2.json
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
index 89cd7e8ed..b7fabb994 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_base.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_base.py
@@ -14,8 +14,8 @@ from bson.objectid import ObjectId
import mock
from tornado import testing
-from opnfv_testapi.resources import models
-from opnfv_testapi.resources import pod_models
+from opnfv_testapi.models import base_models
+from opnfv_testapi.models import pod_models
from opnfv_testapi.tests.unit import fake_pymongo
@@ -25,7 +25,7 @@ class TestBase(testing.AsyncHTTPTestCase):
def setUp(self):
self._patch_server()
self.basePath = ''
- self.create_res = models.CreateResponse
+ self.create_res = base_models.CreateResponse
self.get_res = None
self.list_res = None
self.update_res = None
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_pod.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
index 5d9da3a86..95ed8bac1 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_pod.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_pod.py
@@ -10,10 +10,10 @@ import httplib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import pod_models
+from opnfv_testapi.models import pod_models
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestPodBase(base.TestBase):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_project.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
index 0622ba8d4..939cc0d07 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_project.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_project.py
@@ -2,9 +2,9 @@ import httplib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import project_models
+from opnfv_testapi.models import project_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestProjectBase(base.TestBase):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
index 6c1a07a91..b9f9ede26 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_result.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_result.py
@@ -15,12 +15,12 @@ import urllib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import project_models
-from opnfv_testapi.resources import result_models
-from opnfv_testapi.resources import testcase_models
+from opnfv_testapi.models import project_models
+from opnfv_testapi.models import result_models
+from opnfv_testapi.models import testcase_models
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class Details(object):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
index 1367fc669..de7777a83 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_scenario.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_scenario.py
@@ -6,8 +6,8 @@ import os
from datetime import datetime
from opnfv_testapi.common import message
-import opnfv_testapi.resources.scenario_models as models
-from opnfv_testapi.tests.unit.resources import test_base as base
+import opnfv_testapi.models.scenario_models as models
+from opnfv_testapi.tests.unit.handlers import test_base as base
def _none_default(check, default):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
index 4f2bc2ad1..e4c668e7a 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_testcase.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_testcase.py
@@ -11,10 +11,10 @@ import httplib
import unittest
from opnfv_testapi.common import message
-from opnfv_testapi.resources import project_models
-from opnfv_testapi.resources import testcase_models
+from opnfv_testapi.models import project_models
+from opnfv_testapi.models import testcase_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestCaseBase(base.TestBase):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_token.py
index bd64723be..e8b746dfc 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_token.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_token.py
@@ -11,7 +11,7 @@ from tornado import web
from opnfv_testapi.common import message
from opnfv_testapi.tests.unit import executor
from opnfv_testapi.tests.unit import fake_pymongo
-from opnfv_testapi.tests.unit.resources import test_result
+from opnfv_testapi.tests.unit.handlers import test_result
class TestTokenCreateResult(test_result.TestResultBase):
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_version.py b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_version.py
index 51fed11ea..6ef810f0e 100644
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_version.py
+++ b/utils/test/testapi/opnfv_testapi/tests/unit/handlers/test_version.py
@@ -9,15 +9,15 @@
import httplib
import unittest
-from opnfv_testapi.resources import models
+from opnfv_testapi.models import base_models
from opnfv_testapi.tests.unit import executor
-from opnfv_testapi.tests.unit.resources import test_base as base
+from opnfv_testapi.tests.unit.handlers import test_base as base
class TestVersionBase(base.TestBase):
def setUp(self):
super(TestVersionBase, self).setUp()
- self.list_res = models.Versions
+ self.list_res = base_models.Versions
self.basePath = '/versions'
diff --git a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py b/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py
deleted file mode 100644
index 1ebc96f3b..000000000
--- a/utils/test/testapi/opnfv_testapi/tests/unit/resources/test_fake_pymongo.py
+++ /dev/null
@@ -1,123 +0,0 @@
-##############################################################################
-# Copyright (c) 2016 ZTE Corporation
-# feng.xiaowei@zte.com.cn
-# 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
-##############################################################################
-import unittest
-
-from tornado import gen
-from tornado import testing
-from tornado import web
-
-from opnfv_testapi.tests.unit import fake_pymongo
-
-
-class MyTest(testing.AsyncHTTPTestCase):
- def setUp(self):
- super(MyTest, self).setUp()
- self.db = fake_pymongo
- self.addCleanup(self._clear)
- self.io_loop.run_sync(self.fixture_setup)
-
- def get_app(self):
- return web.Application()
-
- @gen.coroutine
- def fixture_setup(self):
- self.test1 = {'_id': '1', 'name': 'test1'}
- self.test2 = {'name': 'test2'}
- yield self.db.pods.insert({'_id': '1', 'name': 'test1'})
- yield self.db.pods.insert({'name': 'test2'})
-
- @testing.gen_test
- def test_find_one(self):
- user = yield self.db.pods.find_one({'name': 'test1'})
- self.assertEqual(user, self.test1)
- self.db.pods.remove()
-
- @testing.gen_test
- def test_find(self):
- cursor = self.db.pods.find()
- names = []
- while (yield cursor.fetch_next):
- ob = cursor.next_object()
- names.append(ob.get('name'))
- self.assertItemsEqual(names, ['test1', 'test2'])
-
- @testing.gen_test
- def test_update(self):
- yield self.db.pods.update({'_id': '1'}, {'name': 'new_test1'})
- user = yield self.db.pods.find_one({'_id': '1'})
- self.assertEqual(user.get('name', None), 'new_test1')
-
- def test_update_dot_error(self):
- self._update_assert({'_id': '1', 'name': {'1. name': 'test1'}},
- 'key 1. name must not contain .')
-
- def test_update_dot_no_error(self):
- self._update_assert({'_id': '1', 'name': {'1. name': 'test1'}},
- None,
- check_keys=False)
-
- def test_update_dollar_error(self):
- self._update_assert({'_id': '1', 'name': {'$name': 'test1'}},
- 'key $name must not start with $')
-
- def test_update_dollar_no_error(self):
- self._update_assert({'_id': '1', 'name': {'$name': 'test1'}},
- None,
- check_keys=False)
-
- @testing.gen_test
- def test_remove(self):
- yield self.db.pods.remove({'_id': '1'})
- user = yield self.db.pods.find_one({'_id': '1'})
- self.assertIsNone(user)
-
- def test_insert_dot_error(self):
- self._insert_assert({'_id': '1', '2. name': 'test1'},
- 'key 2. name must not contain .')
-
- def test_insert_dot_no_error(self):
- self._insert_assert({'_id': '1', '2. name': 'test1'},
- None,
- check_keys=False)
-
- def test_insert_dollar_error(self):
- self._insert_assert({'_id': '1', '$name': 'test1'},
- 'key $name must not start with $')
-
- def test_insert_dollar_no_error(self):
- self._insert_assert({'_id': '1', '$name': 'test1'},
- None,
- check_keys=False)
-
- def _clear(self):
- self.db.pods.clear()
-
- def _update_assert(self, docs, error=None, **kwargs):
- self._db_assert('update', error, {'_id': '1'}, docs, **kwargs)
-
- def _insert_assert(self, docs, error=None, **kwargs):
- self._db_assert('insert', error, docs, **kwargs)
-
- @testing.gen_test
- def _db_assert(self, method, error, *args, **kwargs):
- name_error = None
- try:
- yield self._eval_pods_db(method, *args, **kwargs)
- except NameError as err:
- name_error = err.args[0]
- finally:
- self.assertEqual(name_error, error)
-
- def _eval_pods_db(self, method, *args, **kwargs):
- table_obj = vars(self.db)['pods']
- return table_obj.__getattribute__(method)(*args, **kwargs)
-
-
-if __name__ == '__main__':
- unittest.main()