Files
poppy/tests/api/base.py
Malini Kamalambal 0d93b9819f Remove poppy server from api tests base
This patch removes the poppy server startup from the API test code.
This is to isolate the server from the tests and avoid any potential
issues during cleanup. The plan is to create a separate script that
can be triggered as part of tox to start/stop the server.

Change-Id: I18d20e8768043213f3c7465663e7e66ef817e409
2014-10-14 16:02:31 -04:00

68 lines
2.2 KiB
Python

# Copyright (c) 2014 Rackspace, Inc.
#
# 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.
from cafe.drivers.unittest import fixtures
import jsonschema
from tests.api.utils import client
from tests.api.utils import config
class TestBase(fixtures.BaseTestFixture):
"""Child class of fixtures.BaseTestFixture for testing CDN.
Inherit from this and write your test methods. If the child class defines
a prepare(self) method, this method will be called before executing each
test method.
"""
@classmethod
def setUpClass(cls):
super(TestBase, cls).setUpClass()
cls.auth_config = config.AuthConfig()
if cls.auth_config.auth_enabled:
cls.auth_client = client.AuthClient()
auth_token, project_id = cls.auth_client.authenticate_user(
cls.auth_config.base_url,
cls.auth_config.user_name,
cls.auth_config.api_key)
else:
auth_token = 'dummy'
project_id = 'dummy'
cls.config = config.PoppyConfig()
cls.url = cls.config.base_url
cls.client = client.PoppyClient(cls.url, auth_token, project_id,
serialize_format='json',
deserialize_format='json')
cls.test_config = config.TestConfig()
def assertSchema(self, response_json, expected_schema):
"""Verify response schema aligns with the expected schema."""
try:
jsonschema.validate(response_json, expected_schema)
except jsonschema.ValidationError as message:
assert False, message
@classmethod
def tearDownClass(cls):
"""Deletes the added resources."""
super(TestBase, cls).tearDownClass()