22
from maasserver.components import (
23
discard_persistent_error,
24
register_persistent_error,
26
from maasserver.enum import COMPONENT
22
from maasserver.components import hide_missing_boot_image_error
27
23
from maasserver.models import (
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')
109
hide_missing_boot_image_error()
110
recorder = self.patch(start_up, 'show_missing_boot_image_error')
120
111
start_up.inner_start_up()
124
MockCalledWith(COMPONENT.IMPORT_PXE_FILES, ANY))
112
self.assertThat(recorder, MockCalledWith())
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')
131
start_up.inner_start_up()
135
Not(MockCalledWith(COMPONENT.IMPORT_PXE_FILES, ANY)))
137
def test__does_not_warn_if_already_warning(self):
138
# If there already is a warning about missing boot resources, it will
140
register_persistent_error(
141
COMPONENT.IMPORT_PXE_FILES, factory.make_string())
142
recorder = self.patch(start_up, 'register_persistent_error')
144
start_up.inner_start_up()
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())