예제 #1
0
    def test_warns_if_no_boot_resources_found(self):
        # The import code used to crash when no resources were found in the
        # Simplestreams repositories (bug 1305758).  This could happen easily
        # with mistakes in the sources.  Now, you just get a logged warning.
        sources_fixture = self.useFixture(
            BootSourcesFixture([{
                "url":
                self.make_dir(),
                "keyring":
                factory.make_name("keyring"),
                "selections": [{
                    "release": factory.make_name("release")
                }],
            }]))
        self.patch(boot_resources, "download_all_image_descriptions")
        boot_resources.download_all_image_descriptions.return_value = (
            BootImageMapping())
        self.patch_maaslog()
        self.patch(boot_resources, "RepoWriter")
        args = self.make_args(sources_file=sources_fixture.filename)

        boot_resources.main(args)

        self.assertThat(
            boot_resources.maaslog.warning,
            MockAnyCall(
                "Finished importing boot images, the region does not have "
                "any boot images available."),
        )
예제 #2
0
 def test__run_import_integrates_with_boot_resources_function(self):
     # If the config specifies no sources, nothing will be imported.  But
     # the task succeeds without errors.
     fixture = self.useFixture(BootSourcesFixture([]))
     self.patch(boot_resources, 'logger')
     self.patch(boot_resources,
                'locate_config').return_value = (fixture.filename)
     self.assertThat(_run_import(sources=[]), Is(False))
예제 #3
0
    def test_warns_if_no_sources_selected(self):
        self.patch_maaslog()
        sources_fixture = self.useFixture(BootSourcesFixture([]))
        args = self.make_args(sources_file=sources_fixture.filename)

        boot_resources.main(args)

        self.assertThat(
            boot_resources.maaslog.warning,
            MockAnyCall("Can't import: region did not provide a source."))
예제 #4
0
 def test_run_import_integrates_with_boot_resources_function(self):
     # If the config specifies no sources, nothing will be imported.  But
     # the task succeeds without errors.
     fixture = self.useFixture(BootSourcesFixture([]))
     self.patch(boot_resources, "logger")
     self.patch(boot_resources,
                "locate_config").return_value = fixture.filename
     self.assertThat(
         _run_import(sources=[], maas_url=factory.make_simple_http_url()),
         Is(False),
     )