launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #11376
[Merge] lp:~jtv/maas/maasserver-testcase-docstrings into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/maasserver-testcase-docstrings into lp:maas with lp:~jtv/maas/dns-cosmetics as a prerequisite.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~jtv/maas/maasserver-testcase-docstrings/+merge/121597
Came across this lapse in our willingness to explain what we're doing while looking for mysterious DNS test failures.
Jeroen
--
https://code.launchpad.net/~jtv/maas/maasserver-testcase-docstrings/+merge/121597
Your team MAAS Maintainers is requested to review the proposed merge of lp:~jtv/maas/maasserver-testcase-docstrings into lp:maas.
=== modified file 'src/maasserver/models/config.py'
--- src/maasserver/models/config.py 2012-08-21 10:47:56 +0000
+++ src/maasserver/models/config.py 2012-08-28 12:24:24 +0000
@@ -105,12 +105,11 @@
:param value: The value of the config item to set.
:type value: Any jsonizable object
"""
- try:
- existing = self.get(name=name)
- existing.value = value
- existing.save()
- except Config.DoesNotExist:
- self.create(name=name, value=value)
+ config, freshly_created = self.get_or_create(
+ name=name, defaults=dict(value=value))
+ if not freshly_created:
+ config.value = value
+ config.save()
def config_changed_connect(self, config_name, method):
"""Connect a method to Django's 'update' signal for given config name.
=== modified file 'src/maasserver/testing/testcase.py'
--- src/maasserver/testing/testcase.py 2012-08-24 02:51:42 +0000
+++ src/maasserver/testing/testcase.py 2012-08-28 12:24:24 +0000
@@ -25,6 +25,7 @@
class TestCase(maastesting.djangotestcase.DjangoTestCase):
+ """:class:`TestCase` variant with the basics for maasserver testing."""
def setUp(self):
super(TestCase, self).setUp()
@@ -35,10 +36,15 @@
class TestModelTestCase(TestCase,
maastesting.djangotestcase.TestModelTestCase):
- pass
+ """:class:`TestCase` variant that lets you create testing models."""
class LoggedInTestCase(TestCase):
+ """:class:`TestCase` variant with a logged-in web client.
+
+ :ivar client: Django http test client, logged in for MAAS access.
+ :ivar logged_in_user: User identity that `client` is authenticated for.
+ """
def setUp(self):
super(LoggedInTestCase, self).setUp()
@@ -53,6 +59,7 @@
class AdminLoggedInTestCase(LoggedInTestCase):
+ """:class:`LoggedInTestCase` variant that is logged in as an admin."""
def setUp(self):
super(AdminLoggedInTestCase, self).setUp()
=== modified file 'src/maasserver/tests/test_nodegroup.py'
--- src/maasserver/tests/test_nodegroup.py 2012-08-22 02:07:30 +0000
+++ src/maasserver/tests/test_nodegroup.py 2012-08-28 12:24:24 +0000
@@ -217,6 +217,7 @@
def test_add_dhcp_host_maps_adds_maps_if_managing_dhcp(self):
self.patch(Omshell, 'create', FakeMethod())
nodegroup = factory.make_node_group()
+ self.patch(nodegroup, 'is_dhcp_enabled', FakeMethod(result=True))
leases = factory.make_random_leases()
nodegroup.add_dhcp_host_maps(leases)
self.assertEqual(
Follow ups