launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #06665
[Merge] lp:~jtv/maas/testcase into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/testcase into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/testcase/+merge/97146
This is a mind-numbingly boring branch.
Only one thing changes: all the various TestCase classes we define in __init__.py files move out into respective testcase.py files.
This avoids some false-sharing problems where the provisioning server can't import a silly little helper that happens to be in maasserver.testing just because src/maasserver/testing/__init__.py imports something from django for its test-case classes.
IMHO it's also nice to avoid the pile-up of miscellaneous un-indexed “stuff” in __init__.py (where you usually don't even look because it's so often an empty file).
--
https://code.launchpad.net/~jtv/maas/testcase/+merge/97146
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/testcase into lp:maas.
=== modified file 'src/maasserver/testing/__init__.py'
--- src/maasserver/testing/__init__.py 2012-03-05 12:36:13 +0000
+++ src/maasserver/testing/__init__.py 2012-03-13 05:40:25 +0000
@@ -13,15 +13,10 @@
"get_fake_provisioning_api_proxy",
"reload_object",
"reload_objects",
- "LoggedInTestCase",
- "TestCase",
]
from uuid import uuid1
-from fixtures import MonkeyPatch
-from maasserver.testing.factory import factory
-import maastesting
from provisioningserver.testing import fakeapi
@@ -36,30 +31,6 @@
return papi_fake
-class TestCase(maastesting.TestCase):
-
- def setUp(self):
- super(TestCase, self).setUp()
- papi_fake = get_fake_provisioning_api_proxy()
- papi_fake_fixture = MonkeyPatch(
- "maasserver.provisioning.get_provisioning_api_proxy",
- lambda: papi_fake)
- self.useFixture(papi_fake_fixture)
-
-
-class TestModelTestCase(TestCase, maastesting.TestModelTestCase):
- pass
-
-
-class LoggedInTestCase(TestCase):
-
- def setUp(self):
- super(LoggedInTestCase, self).setUp()
- self.logged_in_user = factory.make_user(password='test')
- self.client.login(
- username=self.logged_in_user.username, password='test')
-
-
def reload_object(model_object):
"""Reload `obj` from the database.
=== added file 'src/maasserver/testing/testcase.py'
--- src/maasserver/testing/testcase.py 1970-01-01 00:00:00 +0000
+++ src/maasserver/testing/testcase.py 2012-03-13 05:40:25 +0000
@@ -0,0 +1,45 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Custom test-case classes."""
+
+from __future__ import (
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = [
+ 'LoggedInTestCase',
+ 'TestCase',
+ 'TestModelTestCase',
+ ]
+
+from fixtures import MonkeyPatch
+from maasserver.testing import get_fake_provisioning_api_proxy
+from maasserver.testing.factory import factory
+import maastesting.testcase
+
+
+class TestCase(maastesting.testcase.TestCase):
+
+ def setUp(self):
+ super(TestCase, self).setUp()
+ papi_fake = get_fake_provisioning_api_proxy()
+ papi_fake_fixture = MonkeyPatch(
+ "maasserver.provisioning.get_provisioning_api_proxy",
+ lambda: papi_fake)
+ self.useFixture(papi_fake_fixture)
+
+
+class TestModelTestCase(TestCase, maastesting.testcase.TestModelTestCase):
+ pass
+
+
+class LoggedInTestCase(TestCase):
+
+ def setUp(self):
+ super(LoggedInTestCase, self).setUp()
+ self.logged_in_user = factory.make_user(password='test')
+ self.client.login(
+ username=self.logged_in_user.username, password='test')
=== modified file 'src/maasserver/testing/tests/test_enum.py'
--- src/maasserver/testing/tests/test_enum.py 2012-03-05 08:11:51 +0000
+++ src/maasserver/testing/tests/test_enum.py 2012-03-13 05:40:25 +0000
@@ -12,7 +12,7 @@
__all__ = []
from maasserver.testing.enum import map_enum
-from maastesting import TestCase
+from maastesting.testcase import TestCase
class TestEnum(TestCase):
=== modified file 'src/maasserver/testing/tests/test_factory.py'
--- src/maasserver/testing/tests/test_factory.py 2012-03-05 06:04:49 +0000
+++ src/maasserver/testing/tests/test_factory.py 2012-03-13 05:40:25 +0000
@@ -14,7 +14,7 @@
from random import randint
from maasserver.testing.factory import factory
-from maastesting import TestCase
+from maastesting.testcase import TestCase
class TestFactory(TestCase):
=== modified file 'src/maasserver/testing/tests/test_module.py'
--- src/maasserver/testing/tests/test_module.py 2012-03-05 16:25:45 +0000
+++ src/maasserver/testing/tests/test_module.py 2012-03-13 05:40:25 +0000
@@ -15,10 +15,12 @@
from maasserver.testing import (
reload_object,
reload_objects,
+ )
+from maasserver.testing.models import TestModel
+from maasserver.testing.testcase import (
TestCase,
TestModelTestCase,
)
-from maasserver.testing.models import TestModel
from provisioningserver.testing import fakeapi
# Horrible kludge. Works around a bug where delete() does not work on
=== modified file 'src/maasserver/tests/test_api.py'
--- src/maasserver/tests/test_api.py 2012-03-12 15:04:08 +0000
+++ src/maasserver/tests/test_api.py 2012-03-13 05:40:25 +0000
@@ -26,14 +26,16 @@
NODE_STATUS,
)
from maasserver.testing import (
- LoggedInTestCase,
reload_object,
reload_objects,
- TestCase,
)
from maasserver.testing.enum import map_enum
from maasserver.testing.factory import factory
from maasserver.testing.oauthclient import OAuthAuthenticatedClient
+from maasserver.testing.testcase import (
+ LoggedInTestCase,
+ TestCase,
+ )
from metadataserver.models import (
NodeKey,
NodeUserData,
=== modified file 'src/maasserver/tests/test_auth.py'
--- src/maasserver/tests/test_auth.py 2012-02-29 11:33:07 +0000
+++ src/maasserver/tests/test_auth.py 2012-03-13 05:40:25 +0000
@@ -19,8 +19,8 @@
Node,
NODE_STATUS,
)
-from maasserver.testing import TestCase
from maasserver.testing.factory import factory
+from maasserver.testing.testcase import TestCase
from metadataserver.nodeinituser import get_node_init_user
=== modified file 'src/maasserver/tests/test_commands.py'
--- src/maasserver/tests/test_commands.py 2012-03-08 14:20:37 +0000
+++ src/maasserver/tests/test_commands.py 2012-03-13 05:40:25 +0000
@@ -19,7 +19,7 @@
from django.core.management import call_command
from maasserver.models import FileStorage
from maasserver.testing.factory import factory
-from maastesting import TestCase
+from maastesting.testcase import TestCase
class TestCommands(TestCase):
=== modified file 'src/maasserver/tests/test_configuration.py'
--- src/maasserver/tests/test_configuration.py 2012-03-12 10:57:03 +0000
+++ src/maasserver/tests/test_configuration.py 2012-03-13 05:40:25 +0000
@@ -13,7 +13,7 @@
from django.conf import settings
-from maasserver.testing import TestCase
+from maasserver.testing.testcase import TestCase
class TestConfiguration(TestCase):
=== modified file 'src/maasserver/tests/test_fields.py'
--- src/maasserver/tests/test_fields.py 2012-02-29 13:44:30 +0000
+++ src/maasserver/tests/test_fields.py 2012-03-13 05:40:25 +0000
@@ -14,11 +14,11 @@
from django.core.exceptions import ValidationError
from maasserver.fields import validate_mac
from maasserver.models import MACAddress
-from maasserver.testing import (
+from maasserver.testing.factory import factory
+from maasserver.testing.testcase import (
TestCase,
TestModelTestCase,
)
-from maasserver.testing.factory import factory
from maasserver.tests.models import JSONFieldModel
=== modified file 'src/maasserver/tests/test_forms.py'
--- src/maasserver/tests/test_forms.py 2012-03-12 10:45:35 +0000
+++ src/maasserver/tests/test_forms.py 2012-03-13 05:40:25 +0000
@@ -26,10 +26,8 @@
Config,
DEFAULT_CONFIG,
)
-from maasserver.testing import (
- factory,
- TestCase,
- )
+from maasserver.testing.factory import factory
+from maasserver.testing.testcase import TestCase
class NodeWithMACAddressesFormTest(TestCase):
=== modified file 'src/maasserver/tests/test_middleware.py'
--- src/maasserver/tests/test_middleware.py 2012-03-12 14:44:22 +0000
+++ src/maasserver/tests/test_middleware.py 2012-03-13 05:40:25 +0000
@@ -27,10 +27,8 @@
ExceptionLoggerMiddleware,
ExceptionMiddleware,
)
-from maasserver.testing import (
- factory,
- TestCase,
- )
+from maasserver.testing.factory import factory
+from maasserver.testing.testcase import TestCase
def fake_request(base_path):
=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py 2012-03-12 15:04:08 +0000
+++ src/maasserver/tests/test_models.py 2012-03-13 05:40:25 +0000
@@ -42,8 +42,8 @@
SYSTEM_USERS,
UserProfile,
)
-from maasserver.testing import TestCase
from maasserver.testing.factory import factory
+from maasserver.testing.testcase import TestCase
from metadataserver.models import NodeUserData
from piston.models import (
Consumer,
=== modified file 'src/maasserver/tests/test_provisioning.py'
--- src/maasserver/tests/test_provisioning.py 2012-03-12 10:45:35 +0000
+++ src/maasserver/tests/test_provisioning.py 2012-03-13 05:40:25 +0000
@@ -26,9 +26,9 @@
get_metadata_server_url,
select_profile_for_node,
)
-from maasserver.testing import TestCase
from maasserver.testing.enum import map_enum
from maasserver.testing.factory import factory
+from maasserver.testing.testcase import TestCase
from metadataserver.models import NodeKey
=== modified file 'src/maasserver/tests/test_runserver.py'
--- src/maasserver/tests/test_runserver.py 2012-02-16 11:51:13 +0000
+++ src/maasserver/tests/test_runserver.py 2012-03-13 05:40:25 +0000
@@ -12,7 +12,7 @@
__all__ = []
from maasserver.management.commands.runserver import render_error
-from maasserver.testing import TestCase
+from maasserver.testing.testcase import TestCase
class TestRunServer(TestCase):
=== modified file 'src/maasserver/tests/test_views.py'
--- src/maasserver/tests/test_views.py 2012-03-07 16:37:05 +0000
+++ src/maasserver/tests/test_views.py 2012-03-13 05:40:25 +0000
@@ -23,8 +23,8 @@
SSHKeys,
UserProfile,
)
-from maasserver.testing import (
- factory,
+from maasserver.testing.factory import factory
+from maasserver.testing.testcase import (
LoggedInTestCase,
TestCase,
)
=== added file 'src/maastesting/__init__.py'
=== renamed file 'src/maastesting/__init__.py' => 'src/maastesting/testcase.py'
=== modified file 'src/maastesting/tests/test_rabbit.py'
--- src/maastesting/tests/test_rabbit.py 2012-01-24 12:44:48 +0000
+++ src/maastesting/tests/test_rabbit.py 2012-03-13 05:40:25 +0000
@@ -11,8 +11,8 @@
__metaclass__ = type
__all__ = []
-from maastesting import TestCase
from maastesting.rabbit import RabbitServerResource
+from maastesting.testcase import TestCase
from rabbitfixture.server import RabbitServer
=== modified file 'src/metadataserver/tests/test_api.py'
--- src/metadataserver/tests/test_api.py 2012-02-29 10:31:49 +0000
+++ src/metadataserver/tests/test_api.py 2012-03-13 05:40:25 +0000
@@ -19,7 +19,7 @@
from maasserver.exceptions import Unauthorized
from maasserver.testing.factory import factory
from maasserver.testing.oauthclient import OAuthAuthenticatedClient
-from maastesting import TestCase
+from maastesting.testcase import TestCase
from metadataserver.api import (
check_version,
extract_oauth_key,
=== modified file 'src/metadataserver/tests/test_fields.py'
--- src/metadataserver/tests/test_fields.py 2012-02-29 11:40:46 +0000
+++ src/metadataserver/tests/test_fields.py 2012-03-13 05:40:25 +0000
@@ -11,7 +11,7 @@
__metaclass__ = type
__all__ = []
-from maasserver.testing import (
+from maasserver.testing.testcase import (
TestCase,
TestModelTestCase,
)
=== modified file 'src/metadataserver/tests/test_models.py'
--- src/metadataserver/tests/test_models.py 2012-02-29 10:31:49 +0000
+++ src/metadataserver/tests/test_models.py 2012-03-13 05:40:25 +0000
@@ -12,7 +12,7 @@
__all__ = []
from maasserver.testing.factory import factory
-from maastesting import TestCase
+from maastesting.testcase import TestCase
from metadataserver.models import (
NodeKey,
NodeUserData,
=== modified file 'src/metadataserver/tests/test_nodeinituser.py'
--- src/metadataserver/tests/test_nodeinituser.py 2012-02-16 13:45:37 +0000
+++ src/metadataserver/tests/test_nodeinituser.py 2012-03-13 05:40:25 +0000
@@ -13,7 +13,7 @@
from django.contrib.auth.models import User
from maasserver.models import UserProfile
-from maastesting import TestCase
+from maastesting.testcase import TestCase
from metadataserver.nodeinituser import (
get_node_init_user,
user_name,
=== modified file 'templates/test_module.py'
--- templates/test_module.py 2012-02-20 11:02:48 +0000
+++ templates/test_module.py 2012-03-13 05:40:25 +0000
@@ -11,7 +11,7 @@
__metaclass__ = type
__all__ = []
-from maastesting import TestCase
+from maastesting.testcase import TestCase
class TestSomething(TestCase):