~gmb/maas/backports

« back to all changes in this revision

Viewing changes to src/maasserver/api/tests/test_enlistment.py

  • Committer: Gavin Panella
  • Date: 2014-09-29 15:26:08 UTC
  • mfrom: (3124 maas)
  • mto: This revision was merged to the branch mainline in revision 3125.
  • Revision ID: gavin.panella@canonical.com-20140929152608-73b1soyzub5dhe6w
Merge trunk, resolving conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
    )
28
28
from maasserver.models import (
29
29
    Node,
 
30
    node as node_module,
30
31
    NodeGroup,
31
32
    )
32
33
from maasserver.testing.api import MultipleUsersScenarios
48
49
        ('admin', dict(userfactory=factory.make_admin)),
49
50
        ]
50
51
 
 
52
    def setUp(self):
 
53
        super(EnlistmentAPITest, self).setUp()
 
54
        self.patch_autospec(node_module, 'wait_for_power_commands')
 
55
 
51
56
    def test_POST_new_creates_node(self):
52
57
        architecture = make_usable_architecture(self)
53
58
        response = self.client.post(
346
351
class NodeHostnameEnlistmentTest(MultipleUsersScenarios,
347
352
                                 MAASServerTestCase):
348
353
 
 
354
    def setUp(self):
 
355
        super(NodeHostnameEnlistmentTest, self).setUp()
 
356
        self.patch_autospec(node_module, 'wait_for_power_commands')
 
357
 
349
358
    scenarios = [
350
359
        ('anon', dict(userfactory=lambda: AnonymousUser())),
351
360
        ('user', dict(userfactory=factory.make_User)),
451
460
        ('user', dict(userfactory=factory.make_User)),
452
461
        ]
453
462
 
 
463
    def setUp(self):
 
464
        super(NonAdminEnlistmentAPITest, self).setUp()
 
465
        self.patch_autospec(node_module, 'wait_for_power_commands')
 
466
 
454
467
    def test_POST_non_admin_creates_node_in_declared_state(self):
455
468
        # Upon non-admin enlistment, a node goes into the New
456
469
        # state.  Deliberate approval is required before we start
474
487
class AnonymousEnlistmentAPITest(MAASServerTestCase):
475
488
    # Enlistment tests specific to anonymous users.
476
489
 
 
490
    def setUp(self):
 
491
        super(AnonymousEnlistmentAPITest, self).setUp()
 
492
        self.patch_autospec(node_module, 'wait_for_power_commands')
 
493
 
477
494
    def test_POST_accept_not_allowed(self):
478
495
        # An anonymous user is not allowed to accept an anonymously
479
496
        # enlisted node.  That would defeat the whole purpose of holding
524
541
class SimpleUserLoggedInEnlistmentAPITest(MAASServerTestCase):
525
542
    """Enlistment tests from the perspective of regular, non-admin users."""
526
543
 
 
544
    def setUp(self):
 
545
        super(SimpleUserLoggedInEnlistmentAPITest, self).setUp()
 
546
        self.patch_autospec(node_module, 'wait_for_power_commands')
 
547
 
527
548
    def test_POST_accept_not_allowed(self):
528
549
        # An non-admin user is not allowed to accept an anonymously
529
550
        # enlisted node.  That would defeat the whole purpose of holding
614
635
class AdminLoggedInEnlistmentAPITest(MAASServerTestCase):
615
636
    """Enlistment tests from the perspective of admin users."""
616
637
 
 
638
    def setUp(self):
 
639
        super(AdminLoggedInEnlistmentAPITest, self).setUp()
 
640
        self.patch_autospec(node_module, 'wait_for_power_commands')
 
641
 
617
642
    def test_POST_new_sets_power_type_if_admin(self):
618
643
        self.client_log_in(as_admin=True)
619
644
        response = self.client.post(