← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~rvb/maas/maas-set_profile into lp:maas

 

Raphaël Badin has proposed merging lp:~rvb/maas/maas-set_profile into lp:maas.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~rvb/maas/maas-set_profile/+merge/107726

This branch adds back some tests that were wrongly removed in https://code.launchpad.net/~rvb/maas/power-job3/+merge/107032.  Profile management is done in a post_save hook so the change to start_nodes didn't impact it.  But the tests were removed.
-- 
https://code.launchpad.net/~rvb/maas/maas-set_profile/+merge/107726
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~rvb/maas/maas-set_profile into lp:maas.
=== modified file 'src/maasserver/tests/test_models.py'
--- src/maasserver/tests/test_models.py	2012-05-28 14:28:46 +0000
+++ src/maasserver/tests/test_models.py	2012-05-29 07:44:32 +0000
@@ -692,6 +692,33 @@
                 fixture.tasks[0]['kwargs']['mac'],
             ))
 
+    def test_start_nodes_sets_commissioning_profile(self):
+        # Starting up a node should always set a profile. Here we test
+        # that a commissioning profile was set for nodes in the
+        # commissioning status.
+        self.useFixture(CeleryFixture())
+        user = factory.make_user()
+        node = factory.make_node(
+            set_hostname=True, status=NODE_STATUS.COMMISSIONING, owner=user)
+        factory.make_mac_address(node=node)
+        output = Node.objects.start_nodes([node.system_id], user)
+        self.assertItemsEqual([node], output)
+        profile = get_provisioning_api_proxy().nodes[node.system_id]['profile']
+        self.assertEqual('maas-precise-i386-commissioning', profile)
+
+    def test_start_nodes_doesnt_set_commissioning_profile(self):
+        # Starting up a node should always set a profile. Complement the
+        # above test to show that a different profile can be set.
+        self.useFixture(CeleryFixture())
+        user = factory.make_user()
+        node = self.make_node(user)
+        factory.make_mac_address(node=node)
+        output = Node.objects.start_nodes([node.system_id], user)
+
+        self.assertItemsEqual([node], output)
+        profile = get_provisioning_api_proxy().nodes[node.system_id]['profile']
+        self.assertEqual('maas-precise-i386', profile)
+
     def test_start_nodes_uses_default_power_type_if_not_node_specific(self):
         # If the node has a power_type set to POWER_TYPE.DEFAULT,
         # NodeManager.start_node(this_node) should use the default