def test__doesnt_remove_non_matching_path_from_maas_url_with_slashes(self): self.set_maas_url("http://192.168.122.2/not-matching////") sources = [{"url": "http://localhost///MAAS/images/index.json"}] observed = fix_sources_for_cluster(sources) self.assertEqual( "http://192.168.122.2/not-matching/MAAS/images/index.json", observed[0]['url'])
def test_doesnt_remove_non_matching_path_from_maas_url(self): sources = [{"url": "http://localhost/MAAS/images/index.json"}] observed = fix_sources_for_cluster( sources, "http://192.168.122.2/not-matching/") self.assertEqual( "http://192.168.122.2/not-matching/MAAS/images/index.json", observed[0]["url"], )
def test_update_last_image_sync_end_to_end_import_not_performed(self): fixture = self.useFixture(MockLiveClusterToRegionRPCFixture()) protocol, connecting = fixture.makeEventLoop( region.UpdateLastImageSync) protocol.UpdateLastImageSync.return_value = succeed({}) self.addCleanup((yield connecting)) self.patch_autospec(boot_resources, 'import_images') boot_resources.import_images.return_value = False sources, hosts = make_sources() maas_url = factory.make_simple_http_url() yield boot_images.import_boot_images(sources, maas_url) self.assertThat( boot_resources.import_images, MockCalledOnceWith(fix_sources_for_cluster(sources, maas_url))) self.assertThat(protocol.UpdateLastImageSync, MockNotCalled())
def test_update_last_image_sync_end_to_end(self): get_maas_id = self.patch(boot_images, "get_maas_id") get_maas_id.return_value = factory.make_string() fixture = self.useFixture(MockLiveClusterToRegionRPCFixture()) protocol, connecting = fixture.makeEventLoop( region.UpdateLastImageSync) protocol.UpdateLastImageSync.return_value = succeed({}) self.addCleanup((yield connecting)) self.patch_autospec(boot_resources, "import_images") boot_resources.import_images.return_value = True sources, hosts = make_sources() maas_url = factory.make_simple_http_url() yield boot_images.import_boot_images(sources, maas_url) self.assertThat( boot_resources.import_images, MockCalledOnceWith(fix_sources_for_cluster(sources, maas_url)), ) self.assertThat( protocol.UpdateLastImageSync, MockCalledOnceWith(protocol, system_id=get_maas_id()), )
def test_removes_matching_path_with_extra_slashes_from_maas_url(self): sources = [{"url": "http://localhost///MAAS///images/index.json"}] observed = fix_sources_for_cluster(sources, "http://192.168.122.2/MAAS/") self.assertEqual("http://192.168.122.2/MAAS/images/index.json", observed[0]["url"])
def test__removes_matching_path_from_maas_url(self): self.set_maas_url("http://192.168.122.2/MAAS/") sources = [{"url": "http://localhost/MAAS/images/index.json"}] observed = fix_sources_for_cluster(sources) self.assertEqual("http://192.168.122.2/MAAS/images/index.json", observed[0]['url'])