Put test resources into own folder
Centralise all test resources (zonefiles, SSL certs and keys and sample notifications) into a resources folder and update the tests that use them accordinly. Change-Id: If12516a4597df3da04d5c36aaf6262aafaa6cbce
This commit is contained in:
parent
afa1df3341
commit
f4c30e59fd
@ -26,6 +26,7 @@ from designate.openstack.common import importutils
|
||||
from designate.openstack.common import policy
|
||||
from designate.openstack.common import test
|
||||
from designate.context import DesignateContext
|
||||
from designate.tests import resources
|
||||
from designate import storage
|
||||
from designate import exceptions
|
||||
|
||||
@ -255,10 +256,10 @@ class TestCase(test.BaseTestCase):
|
||||
|
||||
def get_zonefile_fixture(self, variant=None):
|
||||
if variant is None:
|
||||
path = 'example.com.zone'
|
||||
f = 'example.com.zone'
|
||||
else:
|
||||
path = '%s_example.com.zone' % variant
|
||||
path = os.path.join(os.path.dirname(__file__), path)
|
||||
f = '%s_example.com.zone' % variant
|
||||
path = os.path.join(resources.path, 'zonefiles', f)
|
||||
with open(path) as zonefile:
|
||||
return zonefile.read()
|
||||
|
||||
|
23
designate/tests/resources/__init__.py
Normal file
23
designate/tests/resources/__init__.py
Normal file
@ -0,0 +1,23 @@
|
||||
# Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
|
||||
#
|
||||
# Author: Artom Lifshitz <artom.lifshitz@enovance.com>
|
||||
#
|
||||
# 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 os
|
||||
|
||||
# The idea here is that anything that needs resources can do:
|
||||
#
|
||||
# from designate.tests import resources
|
||||
# my_resource_path = os.path.join(resources.path, my_resource_folder)
|
||||
path = os.path.dirname(os.path.realpath(__file__))
|
@ -25,6 +25,8 @@ from oslo.config import cfg
|
||||
from designate import exceptions
|
||||
from designate import tests
|
||||
from designate.tests.test_backend import BackendTestMixin
|
||||
from designate.tests import resources
|
||||
|
||||
# impl_nsd4slave needs to register its options before being instanciated.
|
||||
# Import it and pretend to use it to avoid flake8 unused import errors.
|
||||
from designate.backend import impl_nsd4slave
|
||||
@ -34,8 +36,8 @@ impl_nsd4slave
|
||||
class NSD4ServerStub:
|
||||
recved_command = None
|
||||
response = 'ok'
|
||||
keyfile = os.path.join(os.path.dirname(__file__), 'nsd_server.key')
|
||||
certfile = os.path.join(os.path.dirname(__file__), 'nsd_server.pem')
|
||||
keyfile = os.path.join(resources.path, 'ssl', 'nsd_server.key')
|
||||
certfile = os.path.join(resources.path, 'ssl', 'nsd_server.pem')
|
||||
|
||||
def handle(self, client_sock, client_addr):
|
||||
stream = client_sock.makefile()
|
||||
@ -72,8 +74,8 @@ class NSD4Fixture(fixtures.Fixture):
|
||||
cfg.CONF.set_override(
|
||||
'servers', ['127.0.0.1', '127.0.0.1:%d' % self.servers[1].port],
|
||||
'backend:nsd4slave')
|
||||
keyfile = os.path.join(os.path.dirname(__file__), 'nsd_control.key')
|
||||
certfile = os.path.join(os.path.dirname(__file__), 'nsd_control.pem')
|
||||
keyfile = os.path.join(resources.path, 'ssl', 'nsd_control.key')
|
||||
certfile = os.path.join(resources.path, 'ssl', 'nsd_control.pem')
|
||||
cfg.CONF.set_override('keyfile', keyfile, 'backend:nsd4slave')
|
||||
cfg.CONF.set_override('certfile', certfile, 'backend:nsd4slave')
|
||||
cfg.CONF.set_override('pattern', 'test-pattern', 'backend:nsd4slave')
|
||||
|
@ -16,10 +16,9 @@
|
||||
import json
|
||||
import os
|
||||
import testtools
|
||||
from designate.tests import resources
|
||||
|
||||
FIXTURES_PATH = os.path.abspath(os.path.join(os.path.dirname(__file__),
|
||||
'..',
|
||||
'sample_notifications'))
|
||||
FIXTURES_PATH = os.path.join(resources.path, 'sample_notifications')
|
||||
|
||||
|
||||
class NotificationHandlerMixin(object):
|
||||
|
Loading…
Reference in New Issue
Block a user