launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #09388
[Merge] lp:~jtv/maas/migrate-nodekey-tests into lp:maas
Jeroen T. Vermeulen has proposed merging lp:~jtv/maas/migrate-nodekey-tests into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~jtv/maas/migrate-nodekey-tests/+merge/112716
As per the migration plan. In this case, it's the tests for NodeKey (or rather its manager, since NodeKey itself doesn't amount to much code-wise).
Nice, uneventful move. No code changes apart from removing the migration announcement, and top-of-file boilerplate.
This is scheduled to land on Monday (2012-07-02). I won't be in that day, so this may land a little early, or late, or somebody else may have to push the button.
Jeroen
--
https://code.launchpad.net/~jtv/maas/migrate-nodekey-tests/+merge/112716
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~jtv/maas/migrate-nodekey-tests into lp:maas.
=== modified file 'src/metadataserver/tests/test_models.py'
--- src/metadataserver/tests/test_models.py 2012-06-27 04:11:16 +0000
+++ src/metadataserver/tests/test_models.py 2012-06-29 07:09:38 +0000
@@ -16,57 +16,7 @@
from django.http import Http404
from maasserver.testing.factory import factory
from maastesting.djangotestcase import DjangoTestCase
-from metadataserver.models import (
- NodeCommissionResult,
- NodeKey,
- )
-
-
-class TestNodeKeyManager(DjangoTestCase):
-# Scheduled for model migration on 2012-07-04
- """Test NodeKeyManager."""
-
- def test_get_token_for_node_registers_node_key(self):
- node = factory.make_node()
- token = NodeKey.objects.get_token_for_node(node)
- nodekey = NodeKey.objects.get(node=node, key=token.key)
- self.assertNotEqual(None, nodekey)
- self.assertEqual(token, nodekey.token)
-
- def test_get_node_for_key_finds_node(self):
- node = factory.make_node()
- token = NodeKey.objects.get_token_for_node(node)
- self.assertEqual(node, NodeKey.objects.get_node_for_key(token.key))
-
- def test_get_node_for_key_raises_DoesNotExist_if_key_not_found(self):
- non_key = factory.getRandomString()
- self.assertRaises(
- NodeKey.DoesNotExist, NodeKey.objects.get_node_for_key, non_key)
-
- def test_get_token_for_node_creates_token(self):
- node = factory.make_node()
- token = NodeKey.objects.get_token_for_node(node)
- self.assertEqual(node, NodeKey.objects.get_node_for_key(token.key))
-
- def test_get_token_for_node_returns_existing_token(self):
- node = factory.make_node()
- original_token = NodeKey.objects.get_token_for_node(node)
- repeated_token = NodeKey.objects.get_token_for_node(node)
- self.assertEqual(original_token, repeated_token)
-
- def test_get_token_for_node_inverts_get_node_for_key(self):
- node = factory.make_node()
- self.assertEqual(
- node,
- NodeKey.objects.get_node_for_key(
- NodeKey.objects.get_token_for_node(node).key))
-
- def test_get_node_for_key_inverts_get_token_for_node(self):
- key = NodeKey.objects.get_token_for_node(factory.make_node()).key
- self.assertEqual(
- key,
- NodeKey.objects.get_token_for_node(
- NodeKey.objects.get_node_for_key(key)).key)
+from metadataserver.models import NodeCommissionResult
class TestNodeCommissionResult(DjangoTestCase):
=== added file 'src/metadataserver/tests/test_nodekey.py'
--- src/metadataserver/tests/test_nodekey.py 1970-01-01 00:00:00 +0000
+++ src/metadataserver/tests/test_nodekey.py 2012-06-29 07:09:38 +0000
@@ -0,0 +1,63 @@
+# Copyright 2012 Canonical Ltd. This software is licensed under the
+# GNU Affero General Public License version 3 (see the file LICENSE).
+
+"""Tests for :class:`NodeKey` model and manager."""
+
+from __future__ import (
+ absolute_import,
+ print_function,
+ unicode_literals,
+ )
+
+__metaclass__ = type
+__all__ = []
+
+from maasserver.testing.factory import factory
+from maastesting.djangotestcase import DjangoTestCase
+from metadataserver.models import NodeKey
+
+
+class TestNodeKeyManager(DjangoTestCase):
+ """Test NodeKeyManager."""
+
+ def test_get_token_for_node_registers_node_key(self):
+ node = factory.make_node()
+ token = NodeKey.objects.get_token_for_node(node)
+ nodekey = NodeKey.objects.get(node=node, key=token.key)
+ self.assertNotEqual(None, nodekey)
+ self.assertEqual(token, nodekey.token)
+
+ def test_get_node_for_key_finds_node(self):
+ node = factory.make_node()
+ token = NodeKey.objects.get_token_for_node(node)
+ self.assertEqual(node, NodeKey.objects.get_node_for_key(token.key))
+
+ def test_get_node_for_key_raises_DoesNotExist_if_key_not_found(self):
+ non_key = factory.getRandomString()
+ self.assertRaises(
+ NodeKey.DoesNotExist, NodeKey.objects.get_node_for_key, non_key)
+
+ def test_get_token_for_node_creates_token(self):
+ node = factory.make_node()
+ token = NodeKey.objects.get_token_for_node(node)
+ self.assertEqual(node, NodeKey.objects.get_node_for_key(token.key))
+
+ def test_get_token_for_node_returns_existing_token(self):
+ node = factory.make_node()
+ original_token = NodeKey.objects.get_token_for_node(node)
+ repeated_token = NodeKey.objects.get_token_for_node(node)
+ self.assertEqual(original_token, repeated_token)
+
+ def test_get_token_for_node_inverts_get_node_for_key(self):
+ node = factory.make_node()
+ self.assertEqual(
+ node,
+ NodeKey.objects.get_node_for_key(
+ NodeKey.objects.get_token_for_node(node).key))
+
+ def test_get_node_for_key_inverts_get_token_for_node(self):
+ key = NodeKey.objects.get_token_for_node(factory.make_node()).key
+ self.assertEqual(
+ key,
+ NodeKey.objects.get_token_for_node(
+ NodeKey.objects.get_node_for_key(key)).key)