~gmb/maas/backports

« back to all changes in this revision

Viewing changes to src/maasserver/tests/test_start_up.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:
19
19
    locks,
20
20
    start_up,
21
21
    )
22
 
from maasserver.components import (
23
 
    discard_persistent_error,
24
 
    register_persistent_error,
25
 
    )
26
 
from maasserver.enum import COMPONENT
 
22
from maasserver.components import hide_missing_boot_image_error
27
23
from maasserver.models import (
28
24
    BootSource,
29
25
    NodeGroup,
36
32
    MockCalledOnceWith,
37
33
    MockCalledWith,
38
34
    )
39
 
from mock import ANY
40
 
from testtools.matchers import (
41
 
    HasLength,
42
 
    Not,
43
 
    )
 
35
from testtools.matchers import HasLength
44
36
 
45
37
 
46
38
class LockChecker:
114
106
    def test__warns_about_missing_boot_resources(self):
115
107
        # If no boot resources have been created, then the user has not
116
108
        # performed the import process.
117
 
        discard_persistent_error(COMPONENT.IMPORT_PXE_FILES)
118
 
        recorder = self.patch(start_up, 'register_persistent_error')
119
 
 
 
109
        hide_missing_boot_image_error()
 
110
        recorder = self.patch(start_up, 'show_missing_boot_image_error')
120
111
        start_up.inner_start_up()
121
 
 
122
 
        self.assertThat(
123
 
            recorder,
124
 
            MockCalledWith(COMPONENT.IMPORT_PXE_FILES, ANY))
 
112
        self.assertThat(recorder, MockCalledWith())
125
113
 
126
114
    def test__does_not_warn_if_boot_resources_are_known(self):
127
115
        # If boot resources are known, there is no warning.
128
116
        factory.make_BootResource()
129
 
        recorder = self.patch(start_up, 'register_persistent_error')
130
 
 
131
 
        start_up.inner_start_up()
132
 
 
133
 
        self.assertThat(
134
 
            recorder,
135
 
            Not(MockCalledWith(COMPONENT.IMPORT_PXE_FILES, ANY)))
136
 
 
137
 
    def test__does_not_warn_if_already_warning(self):
138
 
        # If there already is a warning about missing boot resources, it will
139
 
        # not be replaced.
140
 
        register_persistent_error(
141
 
            COMPONENT.IMPORT_PXE_FILES, factory.make_string())
142
 
        recorder = self.patch(start_up, 'register_persistent_error')
143
 
 
144
 
        start_up.inner_start_up()
145
 
 
146
 
        self.assertThat(
147
 
            recorder,
148
 
            Not(MockCalledWith(COMPONENT.IMPORT_PXE_FILES, ANY)))
 
117
        recorder = self.patch(start_up, 'hide_missing_boot_image_error')
 
118
        start_up.inner_start_up()
 
119
        self.assertThat(recorder, MockCalledWith())