~rvb/maas/bug-1384001-redux-2

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_node_action.py

[r=gmb][bug=1368400][author=julian-edwards] Allow nodes in the READY state to accept a NodeStop action. This is so admins can power down nodes that are erroneously on for some reason.

Show diffs side-by-side

added added

removed removed

Lines of Context:
396
396
 
397
397
class TestStopNodeNodeAction(MAASServerTestCase):
398
398
 
399
 
    def test_StopNode_stops_deployed_node(self):
 
399
    def test__stops_deployed_node(self):
400
400
        user = factory.make_User()
401
401
        params = dict(
402
402
            power_address=factory.make_string(),
412
412
 
413
413
        self.assertThat(node_stop, MockCalledOnceWith(user))
414
414
 
415
 
    def test_StopNode_actionnable_for_failed_states(self):
 
415
    def test__stops_Ready_node(self):
 
416
        admin = factory.make_admin()
 
417
        params = dict(
 
418
            power_address=factory.make_string(),
 
419
            power_user=factory.make_string(),
 
420
            power_pass=factory.make_string())
 
421
        node = factory.make_Node(
 
422
            mac=True, status=NODE_STATUS.READY,
 
423
            power_type='ipmi', power_parameters=params)
 
424
        node_stop = self.patch_autospec(node, 'stop')
 
425
 
 
426
        StopNode(node, admin).execute()
 
427
 
 
428
        self.assertThat(node_stop, MockCalledOnceWith(admin))
 
429
 
 
430
    def test__actionnable_for_failed_states(self):
416
431
        status = random.choice(FAILED_STATUSES)
417
432
        node = factory.make_Node(status=status, power_type='ipmi')
418
433
        actions = compile_node_actions(