Move transport v1 tests out of tests/

This moves tests for wsgi v1 out of the tests directory. This finishes
the transport unit tests.

blueprint tests-refactoring

Change-Id: Id9cbd64a7c4f49870f767d1427f7de4a0ada3846
This commit is contained in:
Thomas Herve 2015-06-05 09:19:36 +02:00
parent 0b121ffdb2
commit 379c2d4cd8
11 changed files with 78 additions and 246 deletions

View File

@ -6,11 +6,7 @@ test_command=OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} $JIT_FLAG -m subunit.run discover -s ./zaqar/tests/unit/transport/wsgi/v2_0 $LISTOPT $IDOPTION
OS_STDOUT_CAPTURE=${OS_STDOUT_CAPTURE:-1} \
OS_STDERR_CAPTURE=${OS_STDERR_CAPTURE:-1} \
OS_TEST_TIMEOUT=${OS_TEST_TIMEOUT:-60} \
${PYTHON:-python} $JIT_FLAG -m subunit.run discover -s ./zaqar/tests/unit/transport/wsgi/v1_1 $LISTOPT $IDOPTION
${PYTHON:-python} $JIT_FLAG -m subunit.run discover -s ./zaqar/tests/unit/transport/wsgi $LISTOPT $IDOPTION
test_id_option=--load-list $IDFILE

View File

@ -1,105 +0,0 @@
# 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.
import falcon
from zaqar.tests.unit.transport.wsgi import base
from zaqar.tests.unit.transport.wsgi import v1
# --------------------------------------------------------------------------
# Identical or just minor variations across versions
# --------------------------------------------------------------------------
URL_PREFIX = '/v1'
class TestAuth(v1.TestAuth):
url_prefix = URL_PREFIX
class TestClaimsFaultyDriver(v1.TestClaimsFaultyDriver):
url_prefix = URL_PREFIX
class TestClaimsMongoDB(v1.TestClaimsMongoDB):
url_prefix = URL_PREFIX
class TestDefaultLimits(v1.TestDefaultLimits):
url_prefix = URL_PREFIX
class TestHomeDocument(v1.TestHomeDocument):
url_prefix = URL_PREFIX
class TestMediaType(v1.TestMediaType):
url_prefix = URL_PREFIX
class TestMessagesFaultyDriver(v1.TestMessagesFaultyDriver):
url_prefix = URL_PREFIX
class TestMessagesMongoDB(v1.TestMessagesMongoDB):
url_prefix = URL_PREFIX
class TestMessagesMongoDBPooled(v1.TestMessagesMongoDBPooled):
url_prefix = URL_PREFIX
class TestQueueFaultyDriver(v1.TestQueueFaultyDriver):
url_prefix = URL_PREFIX
class TestQueueLifecycleMongoDB(v1.TestQueueLifecycleMongoDB):
url_prefix = URL_PREFIX
# NOTE(flaper87): We'll need this later on
# class TestQueueLifecycleSqlalchemy(v1.TestQueueLifecycleSqlalchemy):
# url_prefix = URL_PREFIX
class TestPoolsMongoDB(v1.TestPoolsMongoDB):
url_prefix = URL_PREFIX
# class TestPoolsSqlalchemy(v1.TestPoolsSqlalchemy):
# url_prefix = URL_PREFIX
class TestValidation(v1.TestValidation):
url_prefix = URL_PREFIX
# --------------------------------------------------------------------------
# v1.0 only
# --------------------------------------------------------------------------
class TestHealth(base.V1Base):
config_file = 'wsgi_mongodb.conf'
def test_get(self):
response = self.simulate_get('/v1/health')
self.assertEqual(self.srmock.status, falcon.HTTP_204)
self.assertEqual(response, [])
def test_head(self):
response = self.simulate_head('/v1/health')
self.assertEqual(self.srmock.status, falcon.HTTP_204)
self.assertEqual(response, [])

View File

@ -126,7 +126,7 @@ class V1Base(TestBase):
Should contain methods specific to V1 of the API
"""
pass
url_prefix = '/v1'
class V1BaseFaulty(TestBaseFaulty):
@ -134,7 +134,7 @@ class V1BaseFaulty(TestBaseFaulty):
Should contain methods specific to V1 exception testing
"""
pass
url_prefix = '/v1'
class V1_1Base(TestBase):

View File

@ -1,39 +0,0 @@
# 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 zaqar.tests.unit.transport.wsgi.v1 import test_auth
from zaqar.tests.unit.transport.wsgi.v1 import test_claims
from zaqar.tests.unit.transport.wsgi.v1 import test_default_limits
from zaqar.tests.unit.transport.wsgi.v1 import test_home
from zaqar.tests.unit.transport.wsgi.v1 import test_media_type
from zaqar.tests.unit.transport.wsgi.v1 import test_messages
from zaqar.tests.unit.transport.wsgi.v1 import test_pools
from zaqar.tests.unit.transport.wsgi.v1 import test_queue_lifecycle as l
from zaqar.tests.unit.transport.wsgi.v1 import test_validation
TestAuth = test_auth.TestAuth
TestClaimsFaultyDriver = test_claims.TestClaimsFaultyDriver
TestClaimsMongoDB = test_claims.TestClaimsMongoDB
TestDefaultLimits = test_default_limits.TestDefaultLimits
TestHomeDocument = test_home.TestHomeDocument
TestMediaType = test_media_type.TestMediaType
TestMessagesFaultyDriver = test_messages.TestMessagesFaultyDriver
TestMessagesMongoDB = test_messages.TestMessagesMongoDB
TestMessagesMongoDBPooled = test_messages.TestMessagesMongoDBPooled
TestQueueFaultyDriver = l.TestQueueLifecycleFaultyDriver
TestQueueLifecycleMongoDB = l.TestQueueLifecycleMongoDB
TestQueueLifecycleSqlalchemy = l.TestQueueLifecycleSqlalchemy
TestPoolsMongoDB = test_pools.TestPoolsMongoDB
TestPoolsSqlalchemy = test_pools.TestPoolsSqlalchemy
TestValidation = test_validation.TestValidation

View File

@ -28,10 +28,13 @@ from zaqar.tests.unit.transport.wsgi import base
@ddt.ddt
class ClaimsBaseTest(base.V1Base):
class TestClaimsMongoDB(base.V1Base):
config_file = 'wsgi_mongodb.conf'
@testing.requires_mongodb
def setUp(self):
super(ClaimsBaseTest, self).setUp()
super(TestClaimsMongoDB, self).setUp()
self.project_id = '480924'
self.queue_path = self.url_prefix + '/queues/fizbit'
@ -49,9 +52,17 @@ class ClaimsBaseTest(base.V1Base):
self.assertEqual(self.srmock.status, falcon.HTTP_201)
def tearDown(self):
storage = self.boot.storage._storage
control = self.boot.control
connection = storage.connection
connection.drop_database(control.queues_database)
for db in storage.message_databases:
connection.drop_database(db)
self.simulate_delete(self.queue_path, self.project_id)
super(ClaimsBaseTest, self).tearDown()
super(TestClaimsMongoDB, self).tearDown()
@ddt.data(None, '[', '[]', '{}', '.', '"fail"')
def test_bad_claim(self, doc):
@ -223,27 +234,6 @@ class ClaimsBaseTest(base.V1Base):
self.assertEqual(self.srmock.status, falcon.HTTP_404)
class TestClaimsMongoDB(ClaimsBaseTest):
config_file = 'wsgi_mongodb.conf'
@testing.requires_mongodb
def setUp(self):
super(TestClaimsMongoDB, self).setUp()
def tearDown(self):
storage = self.boot.storage._storage
control = self.boot.control
connection = storage.connection
connection.drop_database(control.queues_database)
for db in storage.message_databases:
connection.drop_database(db)
super(TestClaimsMongoDB, self).tearDown()
class TestClaimsFaultyDriver(base.V1BaseFaulty):
config_file = 'wsgi_faulty.conf'

View File

@ -0,0 +1,33 @@
# Copyright (c) 2015 Red Hat, 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.
import falcon
from zaqar.tests.unit.transport.wsgi import base
class TestHealth(base.V1Base):
config_file = 'wsgi_mongodb.conf'
def test_get(self):
response = self.simulate_get('/v1/health')
self.assertEqual(self.srmock.status, falcon.HTTP_204)
self.assertEqual(response, [])
def test_head(self):
response = self.simulate_head('/v1/health')
self.assertEqual(self.srmock.status, falcon.HTTP_204)
self.assertEqual(response, [])

View File

@ -30,10 +30,13 @@ from zaqar.transport import validation
@ddt.ddt
class MessagesBaseTest(base.V1Base):
class TestMessagesMongoDB(base.V1Base):
config_file = 'wsgi_mongodb.conf'
@testing.requires_mongodb
def setUp(self):
super(MessagesBaseTest, self).setUp()
super(TestMessagesMongoDB, self).setUp()
if self.conf.pooling:
for i in range(4):
uri = "%s/%s" % ('mongodb://localhost:27017', str(i))
@ -70,7 +73,7 @@ class MessagesBaseTest(base.V1Base):
for i in range(4):
self.simulate_delete(self.url_prefix + '/pools/' + str(i))
super(MessagesBaseTest, self).tearDown()
super(TestMessagesMongoDB, self).tearDown()
def _test_post(self, sample_messages):
sample_doc = jsonutils.dumps(sample_messages)
@ -468,29 +471,10 @@ class MessagesBaseTest(base.V1Base):
return headers['location'].rsplit('=', 1)[-1].split(',')
class TestMessagesMongoDB(MessagesBaseTest):
config_file = 'wsgi_mongodb.conf'
@testing.requires_mongodb
def setUp(self):
super(TestMessagesMongoDB, self).setUp()
def tearDown(self):
super(TestMessagesMongoDB, self).tearDown()
class TestMessagesMongoDBPooled(MessagesBaseTest):
class TestMessagesMongoDBPooled(TestMessagesMongoDB):
config_file = 'wsgi_mongodb_pooled.conf'
@testing.requires_mongodb
def setUp(self):
super(TestMessagesMongoDBPooled, self).setUp()
def tearDown(self):
super(TestMessagesMongoDBPooled, self).tearDown()
# TODO(cpp-cabrera): remove this skipTest once pooled queue
# listing is implemented
def test_list(self):

View File

@ -80,17 +80,20 @@ def pools(test, count, uri):
@ddt.ddt
class PoolsBaseTest(base.V1Base):
class TestPoolsMongoDB(base.V1Base):
config_file = 'wsgi_mongodb_pooled.conf'
@testing.requires_mongodb
def setUp(self):
super(PoolsBaseTest, self).setUp()
super(TestPoolsMongoDB, self).setUp()
self.doc = {'weight': 100, 'uri': 'mongodb://localhost:27017'}
self.pool = self.url_prefix + '/pools/' + str(uuid.uuid1())
self.simulate_put(self.pool, body=jsonutils.dumps(self.doc))
self.assertEqual(self.srmock.status, falcon.HTTP_201)
def tearDown(self):
super(PoolsBaseTest, self).tearDown()
super(TestPoolsMongoDB, self).tearDown()
self.simulate_delete(self.pool)
self.assertEqual(self.srmock.status, falcon.HTTP_204)
@ -328,20 +331,3 @@ class PoolsBaseTest(base.V1Base):
self.assertEqual(len(pool_list), 6)
path, weight = expected[4][:2]
self._pool_expect(pool_list[0], path, weight, self.doc['uri'])
class TestPoolsMongoDB(PoolsBaseTest):
config_file = 'wsgi_mongodb_pooled.conf'
@testing.requires_mongodb
def setUp(self):
super(TestPoolsMongoDB, self).setUp()
class TestPoolsSqlalchemy(PoolsBaseTest):
config_file = 'wsgi_sqlalchemy_pooled.conf'
def setUp(self):
super(TestPoolsSqlalchemy, self).setUp()

View File

@ -22,18 +22,30 @@ from zaqar.tests.unit.transport.wsgi import base
@ddt.ddt
class QueueLifecycleBaseTest(base.V1Base):
class TestQueueLifecycleMongoDB(base.V1BaseFaulty):
config_file = None
config_file = 'wsgi_mongodb.conf'
@testing.requires_mongodb
def setUp(self):
super(QueueLifecycleBaseTest, self).setUp()
super(TestQueueLifecycleMongoDB, self).setUp()
self.queue_path = self.url_prefix + '/queues'
self.gumshoe_queue_path = self.queue_path + '/gumshoe'
self.fizbat_queue_path = self.queue_path + '/fizbat'
self.fizbat_queue_path_metadata = self.fizbat_queue_path + '/metadata'
def tearDown(self):
storage = self.boot.storage._storage
connection = storage.connection
connection.drop_database(self.boot.control.queues_database)
for db in storage.message_databases:
connection.drop_database(db)
super(TestQueueLifecycleMongoDB, self).tearDown()
def test_empty_project_id(self):
self.simulate_get(self.gumshoe_queue_path, '')
self.assertEqual(self.srmock.status, falcon.HTTP_400)
@ -336,31 +348,6 @@ class QueueLifecycleBaseTest(base.V1Base):
self.assertEqual(self.srmock.status, falcon.HTTP_204)
class TestQueueLifecycleMongoDB(QueueLifecycleBaseTest):
config_file = 'wsgi_mongodb.conf'
@testing.requires_mongodb
def setUp(self):
super(TestQueueLifecycleMongoDB, self).setUp()
def tearDown(self):
storage = self.boot.storage._storage
connection = storage.connection
connection.drop_database(self.boot.control.queues_database)
for db in storage.message_databases:
connection.drop_database(db)
super(TestQueueLifecycleMongoDB, self).tearDown()
class TestQueueLifecycleSqlalchemy(QueueLifecycleBaseTest):
config_file = 'wsgi_sqlalchemy.conf'
class TestQueueLifecycleFaultyDriver(base.V1BaseFaulty):
config_file = 'wsgi_faulty.conf'