def test_run_import_sets_proxy_for_loopback(self): fake = self.patch_boot_resources_function() _run_import(sources=[], maas_url=factory.make_simple_http_url()) self.assertEqual( fake.env["no_proxy"], ("localhost,::ffff:127.0.0.1,127.0.0.1,::1," "[::ffff:127.0.0.1],[::1]"), )
def test__run_import_sets_proxy_if_given(self): proxy = 'http://%s.example.com' % factory.make_name('proxy') fake = self.patch_boot_resources_function() _run_import(sources=[], maas_url=factory.make_simple_http_url(), http_proxy=proxy, https_proxy=proxy) self.expectThat(fake.env['http_proxy'], Equals(proxy)) self.expectThat(fake.env['https_proxy'], Equals(proxy))
def test__run_import_sets_proxy_for_source_host(self): host = factory.make_name("host").lower() maas_url = "http://%s/" % host sources, _ = make_sources() fake = self.patch_boot_resources_function() _run_import(sources=sources, maas_url=maas_url) self.assertItemsEqual( fake.env['no_proxy'].split(','), ["localhost", "::ffff:127.0.0.1", "127.0.0.1", "::1"] + [host])
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))
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), )
def test_run_import_calls_reload_boot_images(self): fake_reload = self.patch(boot_images, "reload_boot_images") self.patch(boot_resources, "import_images") sources, _ = make_sources() _run_import(sources=sources, maas_url=factory.make_simple_http_url()) self.assertThat(fake_reload, MockCalledOnceWith())
def test_run_import_accepts_sources_parameter(self): fake = self.patch(boot_resources, "import_images") sources, _ = make_sources() _run_import(sources=sources, maas_url=factory.make_simple_http_url()) self.assertThat(fake, MockCalledOnceWith(sources))
def test_run_import_sets_GPGHOME(self): home = factory.make_name("home") self.patch(boot_images, "get_maas_user_gpghome").return_value = home fake = self.patch_boot_resources_function() _run_import(sources=[], maas_url=factory.make_simple_http_url()) self.assertEqual(home, fake.env["GNUPGHOME"])
def test__run_import_calls_reload_boot_images(self): fake_reload = self.patch(boot_images, 'reload_boot_images') self.patch(boot_resources, 'import_images') sources, _ = make_sources() _run_import(sources=sources) self.assertThat(fake_reload, MockCalledOnceWith())
def test__run_import_accepts_sources_parameter(self): fake = self.patch(boot_resources, 'import_images') sources, _ = make_sources() _run_import(sources=sources) self.assertThat(fake, MockCalledOnceWith(sources))
def test__run_import_sets_proxy_for_loopback(self): fake = self.patch_boot_resources_function() _run_import(sources=[]) self.assertEqual(fake.env['no_proxy'], "localhost,::ffff:127.0.0.1,127.0.0.1,::1")
def test__run_import_sets_GPGHOME(self): home = factory.make_name('home') self.patch(boot_images, 'get_maas_user_gpghome').return_value = home fake = self.patch_boot_resources_function() _run_import(sources=[]) self.assertEqual(home, fake.env['GNUPGHOME'])