diff --git a/designate/tests/__init__.py b/designate/tests/__init__.py index cc3332982..7e59a6638 100644 --- a/designate/tests/__init__.py +++ b/designate/tests/__init__.py @@ -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() diff --git a/designate/tests/resources/__init__.py b/designate/tests/resources/__init__.py new file mode 100644 index 000000000..3003c7b75 --- /dev/null +++ b/designate/tests/resources/__init__.py @@ -0,0 +1,23 @@ +# Copyright (C) 2013 eNovance SAS +# +# Author: Artom Lifshitz +# +# 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__)) diff --git a/designate/tests/sample_notifications/neutron/floatingip.update.end_associate.json b/designate/tests/resources/sample_notifications/neutron/floatingip.update.end_associate.json similarity index 100% rename from designate/tests/sample_notifications/neutron/floatingip.update.end_associate.json rename to designate/tests/resources/sample_notifications/neutron/floatingip.update.end_associate.json diff --git a/designate/tests/sample_notifications/neutron/floatingip.update.end_disassociate.json b/designate/tests/resources/sample_notifications/neutron/floatingip.update.end_disassociate.json similarity index 100% rename from designate/tests/sample_notifications/neutron/floatingip.update.end_disassociate.json rename to designate/tests/resources/sample_notifications/neutron/floatingip.update.end_disassociate.json diff --git a/designate/tests/sample_notifications/neutron/port.create.end.json b/designate/tests/resources/sample_notifications/neutron/port.create.end.json similarity index 100% rename from designate/tests/sample_notifications/neutron/port.create.end.json rename to designate/tests/resources/sample_notifications/neutron/port.create.end.json diff --git a/designate/tests/sample_notifications/neutron/port.create.start.josn b/designate/tests/resources/sample_notifications/neutron/port.create.start.josn similarity index 100% rename from designate/tests/sample_notifications/neutron/port.create.start.josn rename to designate/tests/resources/sample_notifications/neutron/port.create.start.josn diff --git a/designate/tests/sample_notifications/neutron/port.delete.end.json b/designate/tests/resources/sample_notifications/neutron/port.delete.end.json similarity index 100% rename from designate/tests/sample_notifications/neutron/port.delete.end.json rename to designate/tests/resources/sample_notifications/neutron/port.delete.end.json diff --git a/designate/tests/sample_notifications/neutron/port.delete.start.json b/designate/tests/resources/sample_notifications/neutron/port.delete.start.json similarity index 100% rename from designate/tests/sample_notifications/neutron/port.delete.start.json rename to designate/tests/resources/sample_notifications/neutron/port.delete.start.json diff --git a/designate/tests/sample_notifications/nova/compute.instance.create.end.json b/designate/tests/resources/sample_notifications/nova/compute.instance.create.end.json similarity index 100% rename from designate/tests/sample_notifications/nova/compute.instance.create.end.json rename to designate/tests/resources/sample_notifications/nova/compute.instance.create.end.json diff --git a/designate/tests/sample_notifications/nova/compute.instance.create.start.json b/designate/tests/resources/sample_notifications/nova/compute.instance.create.start.json similarity index 100% rename from designate/tests/sample_notifications/nova/compute.instance.create.start.json rename to designate/tests/resources/sample_notifications/nova/compute.instance.create.start.json diff --git a/designate/tests/sample_notifications/nova/compute.instance.delete.start.json b/designate/tests/resources/sample_notifications/nova/compute.instance.delete.start.json similarity index 100% rename from designate/tests/sample_notifications/nova/compute.instance.delete.start.json rename to designate/tests/resources/sample_notifications/nova/compute.instance.delete.start.json diff --git a/designate/tests/sample_notifications/nova/compute.instance.shutdown.end.json b/designate/tests/resources/sample_notifications/nova/compute.instance.shutdown.end.json similarity index 100% rename from designate/tests/sample_notifications/nova/compute.instance.shutdown.end.json rename to designate/tests/resources/sample_notifications/nova/compute.instance.shutdown.end.json diff --git a/designate/tests/sample_notifications/nova/compute.instance.shutdown.start.json b/designate/tests/resources/sample_notifications/nova/compute.instance.shutdown.start.json similarity index 100% rename from designate/tests/sample_notifications/nova/compute.instance.shutdown.start.json rename to designate/tests/resources/sample_notifications/nova/compute.instance.shutdown.start.json diff --git a/designate/tests/sample_notifications/nova/network.floating_ip.allocate.json b/designate/tests/resources/sample_notifications/nova/network.floating_ip.allocate.json similarity index 100% rename from designate/tests/sample_notifications/nova/network.floating_ip.allocate.json rename to designate/tests/resources/sample_notifications/nova/network.floating_ip.allocate.json diff --git a/designate/tests/sample_notifications/nova/network.floating_ip.associate.json b/designate/tests/resources/sample_notifications/nova/network.floating_ip.associate.json similarity index 100% rename from designate/tests/sample_notifications/nova/network.floating_ip.associate.json rename to designate/tests/resources/sample_notifications/nova/network.floating_ip.associate.json diff --git a/designate/tests/sample_notifications/nova/network.floating_ip.deallocate.json b/designate/tests/resources/sample_notifications/nova/network.floating_ip.deallocate.json similarity index 100% rename from designate/tests/sample_notifications/nova/network.floating_ip.deallocate.json rename to designate/tests/resources/sample_notifications/nova/network.floating_ip.deallocate.json diff --git a/designate/tests/sample_notifications/nova/network.floating_ip.disassociate.json b/designate/tests/resources/sample_notifications/nova/network.floating_ip.disassociate.json similarity index 100% rename from designate/tests/sample_notifications/nova/network.floating_ip.disassociate.json rename to designate/tests/resources/sample_notifications/nova/network.floating_ip.disassociate.json diff --git a/designate/tests/sample_notifications/nova/scheduler.run_instance.end.json b/designate/tests/resources/sample_notifications/nova/scheduler.run_instance.end.json similarity index 100% rename from designate/tests/sample_notifications/nova/scheduler.run_instance.end.json rename to designate/tests/resources/sample_notifications/nova/scheduler.run_instance.end.json diff --git a/designate/tests/sample_notifications/nova/scheduler.run_instance.scheduled.json b/designate/tests/resources/sample_notifications/nova/scheduler.run_instance.scheduled.json similarity index 100% rename from designate/tests/sample_notifications/nova/scheduler.run_instance.scheduled.json rename to designate/tests/resources/sample_notifications/nova/scheduler.run_instance.scheduled.json diff --git a/designate/tests/sample_notifications/nova/scheduler.run_instance.start.json b/designate/tests/resources/sample_notifications/nova/scheduler.run_instance.start.json similarity index 100% rename from designate/tests/sample_notifications/nova/scheduler.run_instance.start.json rename to designate/tests/resources/sample_notifications/nova/scheduler.run_instance.start.json diff --git a/designate/tests/test_backend/nsd_control.key b/designate/tests/resources/ssl/nsd_control.key similarity index 100% rename from designate/tests/test_backend/nsd_control.key rename to designate/tests/resources/ssl/nsd_control.key diff --git a/designate/tests/test_backend/nsd_control.pem b/designate/tests/resources/ssl/nsd_control.pem similarity index 100% rename from designate/tests/test_backend/nsd_control.pem rename to designate/tests/resources/ssl/nsd_control.pem diff --git a/designate/tests/test_backend/nsd_server.key b/designate/tests/resources/ssl/nsd_server.key similarity index 100% rename from designate/tests/test_backend/nsd_server.key rename to designate/tests/resources/ssl/nsd_server.key diff --git a/designate/tests/test_backend/nsd_server.pem b/designate/tests/resources/ssl/nsd_server.pem similarity index 100% rename from designate/tests/test_backend/nsd_server.pem rename to designate/tests/resources/ssl/nsd_server.pem diff --git a/designate/tests/example.com.zone b/designate/tests/resources/zonefiles/example.com.zone similarity index 100% rename from designate/tests/example.com.zone rename to designate/tests/resources/zonefiles/example.com.zone diff --git a/designate/tests/malformed_example.com.zone b/designate/tests/resources/zonefiles/malformed_example.com.zone similarity index 100% rename from designate/tests/malformed_example.com.zone rename to designate/tests/resources/zonefiles/malformed_example.com.zone diff --git a/designate/tests/noorigin_example.com.zone b/designate/tests/resources/zonefiles/noorigin_example.com.zone similarity index 100% rename from designate/tests/noorigin_example.com.zone rename to designate/tests/resources/zonefiles/noorigin_example.com.zone diff --git a/designate/tests/nosoa_example.com.zone b/designate/tests/resources/zonefiles/nosoa_example.com.zone similarity index 100% rename from designate/tests/nosoa_example.com.zone rename to designate/tests/resources/zonefiles/nosoa_example.com.zone diff --git a/designate/tests/test_backend/test_nsd4slave.py b/designate/tests/test_backend/test_nsd4slave.py index 2b3ca03b2..a7751b879 100644 --- a/designate/tests/test_backend/test_nsd4slave.py +++ b/designate/tests/test_backend/test_nsd4slave.py @@ -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') diff --git a/designate/tests/test_notification_handler/__init__.py b/designate/tests/test_notification_handler/__init__.py index dd1cd32f1..f7e6f9fe0 100644 --- a/designate/tests/test_notification_handler/__init__.py +++ b/designate/tests/test_notification_handler/__init__.py @@ -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):