diff options
Diffstat (limited to 'conductor/conductor/tests')
6 files changed, 99 insertions, 1 deletions
diff --git a/conductor/conductor/tests/unit/api/base_api.py b/conductor/conductor/tests/unit/api/base_api.py index f3f6747..ac89a57 100644 --- a/conductor/conductor/tests/unit/api/base_api.py +++ b/conductor/conductor/tests/unit/api/base_api.py @@ -24,8 +24,11 @@ import pecan import pecan.testing from oslo_config import cfg from oslo_config import fixture as config_fixture +from oslo_serialization import jsonutils from oslotest import base as oslo_test_base +from conductor import service + class BaseApiTest(oslo_test_base.BaseTestCase): """Pecan controller functional testing class. @@ -78,4 +81,9 @@ class BaseApiTest(oslo_test_base.BaseTestCase): def _set_config(self): self.cfg_fixture = self.useFixture(config_fixture.Config(cfg.CONF)) self.cfg_fixture.config(keyspace='conductor_rpc', - group='messaging_server')
\ No newline at end of file + group='messaging_server') + + def assertJsonEqual(self, expected, observed): + """Asserts that 2 complex data structures are json equivalent.""" + self.assertEqual(jsonutils.dumps(expected, sort_keys=True), + jsonutils.dumps(observed, sort_keys=True))
\ No newline at end of file diff --git a/conductor/conductor/tests/unit/api/controller/__init__.py b/conductor/conductor/tests/unit/api/controller/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/conductor/conductor/tests/unit/api/controller/__init__.py diff --git a/conductor/conductor/tests/unit/api/controller/test_root.py b/conductor/conductor/tests/unit/api/controller/test_root.py new file mode 100644 index 0000000..3dbb66c --- /dev/null +++ b/conductor/conductor/tests/unit/api/controller/test_root.py @@ -0,0 +1,35 @@ +# +# ------------------------------------------------------------------------- +# Copyright (c) 2018 Intel Corporation Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# +"""Test case for RootController /""" + +import json + +from conductor.tests.unit.api import base_api + + +class TestRoot(base_api.BaseApiTest): + + def test_get_index(self): + actual_response = self.app.get('/') + req_json_file = './conductor/tests/unit/api/controller/versions.json' + expected_response = json.loads(open(req_json_file).read()) + print('GOT:%s' % actual_response) + self.assertJsonEqual(actual_response.status_int, 200) + self.assertJsonEqual(expected_response, + json.loads(actual_response.body)) diff --git a/conductor/conductor/tests/unit/api/controller/v1/__init__.py b/conductor/conductor/tests/unit/api/controller/v1/__init__.py new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/conductor/conductor/tests/unit/api/controller/v1/__init__.py diff --git a/conductor/conductor/tests/unit/api/controller/v1/test_v1_root.py b/conductor/conductor/tests/unit/api/controller/v1/test_v1_root.py new file mode 100644 index 0000000..ade3f2c --- /dev/null +++ b/conductor/conductor/tests/unit/api/controller/v1/test_v1_root.py @@ -0,0 +1,29 @@ +# +# ------------------------------------------------------------------------- +# Copyright (c) 2018 Intel Corporation Intellectual Property +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# ------------------------------------------------------------------------- +# +"""Test case for V1Controller /""" + +from conductor.tests.unit.api import base_api + + +class TestV1Root(base_api.BaseApiTest): + + def test_get_v1_root(self): + actual_response = self.app.get('/v1', expect_errors=True) + print('GOT:%s' % actual_response) + self.assertEqual(actual_response.status_int, 405) diff --git a/conductor/conductor/tests/unit/api/controller/versions.json b/conductor/conductor/tests/unit/api/controller/versions.json new file mode 100644 index 0000000..885ce01 --- /dev/null +++ b/conductor/conductor/tests/unit/api/controller/versions.json @@ -0,0 +1,26 @@ +{ + "versions": [ + { + "id": "v1", + "media-types": [ + { + "type": "application/vnd.onap.has-v1+json", + "base": "application/json" + } + ], + "updated": "2016-11-01T00:00:00Z", + "links": [ + { + "rel": "self", + "href": "http://localhost/v1" + }, + { + "type": "text/html", + "rel": "describedby", + "href": "https://wiki.onap.org/pages/viewpage.action?pageId=16005528" + } + ], + "status": "EXPERIMENTAL" + } + ] +}
\ No newline at end of file |