~ubuntu-branches/ubuntu/utopic/maas/utopic-updates

« back to all changes in this revision

Viewing changes to src/provisioningserver/driver/tests/test_registries.py

  • Committer: Package Import Robot
  • Author(s): Julian Edwards, Julian Edwards, Andres Rodriguez
  • Date: 2014-08-21 18:38:27 UTC
  • mfrom: (1.2.34)
  • Revision ID: package-import@ubuntu.com-20140821183827-9xyb5u2o4l8g3zxj
Tags: 1.6.1+bzr2550-0ubuntu1
* New upstream bugfix release:
  - Auto-link node MACs to Networks (LP: #1341619)

[ Julian Edwards ]
* debian/maas-region-controller.postinst: Don't restart RabbitMQ on
  upgrades, just ensure it's running.  Should prevent a race with the
  cluster celery restarting.
* debian/rules: Pull upstream branch from the right place.

[ Andres Rodriguez ]
* debian/maas-region-controller.postinst: Ensure cluster celery is
  started if it also runs on the region.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright 2014 Canonical Ltd.  This software is licensed under the
2
 
# GNU Affero General Public License version 3 (see the file LICENSE).
3
 
 
4
 
"""Tests for the driver registries."""
5
 
 
6
 
from __future__ import (
7
 
    absolute_import,
8
 
    print_function,
9
 
    unicode_literals,
10
 
    )
11
 
 
12
 
str = None
13
 
 
14
 
__metaclass__ = type
15
 
__all__ = []
16
 
 
17
 
from maastesting.testcase import MAASTestCase
18
 
from mock import sentinel
19
 
from provisioningserver.driver import (
20
 
    Architecture,
21
 
    ArchitectureRegistry,
22
 
    BootResourceRegistry,
23
 
    PowerTypeRegistry,
24
 
    )
25
 
from provisioningserver.utils.testing import RegistryFixture
26
 
 
27
 
 
28
 
class TestRegistries(MAASTestCase):
29
 
 
30
 
    def setUp(self):
31
 
        super(TestRegistries, self).setUp()
32
 
        # Ensure the global registry is empty for each test run.
33
 
        self.useFixture(RegistryFixture())
34
 
 
35
 
    def test_bootresource_registry(self):
36
 
        self.assertItemsEqual([], BootResourceRegistry)
37
 
        BootResourceRegistry.register_item("resource", sentinel.resource)
38
 
        self.assertIn(
39
 
            sentinel.resource,
40
 
            (item for name, item in BootResourceRegistry))
41
 
 
42
 
    def test_architecture_registry(self):
43
 
        self.assertItemsEqual([], ArchitectureRegistry)
44
 
        ArchitectureRegistry.register_item("resource", sentinel.resource)
45
 
        self.assertIn(
46
 
            sentinel.resource,
47
 
            (item for name, item in ArchitectureRegistry))
48
 
 
49
 
    def test_get_by_pxealias_returns_valid_arch(self):
50
 
        arch1 = Architecture(
51
 
            name="arch1", description="arch1",
52
 
            pxealiases=["archibald", "reginald"])
53
 
        arch2 = Architecture(
54
 
            name="arch2", description="arch2",
55
 
            pxealiases=["fake", "foo"])
56
 
        ArchitectureRegistry.register_item("arch1", arch1)
57
 
        ArchitectureRegistry.register_item("arch2", arch2)
58
 
        self.assertEqual(
59
 
            arch1, ArchitectureRegistry.get_by_pxealias("archibald"))
60
 
 
61
 
    def test_get_by_pxealias_returns_None_if_none_matching(self):
62
 
        arch1 = Architecture(
63
 
            name="arch1", description="arch1",
64
 
            pxealiases=["archibald", "reginald"])
65
 
        arch2 = Architecture(name="arch2", description="arch2")
66
 
        ArchitectureRegistry.register_item("arch1", arch1)
67
 
        ArchitectureRegistry.register_item("arch2", arch2)
68
 
        self.assertEqual(
69
 
            None, ArchitectureRegistry.get_by_pxealias("stinkywinky"))
70
 
 
71
 
    def test_power_type_registry(self):
72
 
        self.assertItemsEqual([], PowerTypeRegistry)
73
 
        PowerTypeRegistry.register_item("resource", sentinel.resource)
74
 
        self.assertIn(
75
 
            sentinel.resource,
76
 
            (item for name, item in PowerTypeRegistry))