def test_make_name_includes_prefix_and_separator(self): self.assertThat(factory.make_name("abc"), StartsWith("abc-"))
def test_compose_preseed_for_commissioning_node_has_header(self): node = factory.make_node(status=NODE_STATUS.COMMISSIONING) self.assertThat(compose_preseed(node), StartsWith("#cloud-config\n"))
def test_print_module_named_with_dashes_help_for_valid_plugin(self): result = self.run_command(["help", "plainbox-provider", "--base", "core18"]) expected = "Displaying help for the 'plainbox-provider' plugin for 'core18'." self.assertThat(result.output, StartsWith(expected))
def setUp(self): super(TestContextMenuImageAndLink, self).setUp(path="/imagelink") self.assertThat(self.menu.get_title_label().text, StartsWith(self.data_uri_prefix))
def test_get_png_from_rgba_file_returns_png_file(self): with _single_pixel_rgba_data_file() as filepath: png_image_data = _ss._get_png_from_rgba_file(filepath, (1, 1)) self.assertEqual(0, png_image_data.tell()) self.assertThat(png_image_data.read(), StartsWith(b'\x89PNG\r\n'))
def test_mismatch_returns_does_not_start_with(self): matcher = StartsWith("bar") self.assertIsInstance(matcher.match("foo"), DoesNotStartWith)
def test_mismatch_sets_expected(self): matcher = StartsWith("bar") mismatch = matcher.match("foo") self.assertEqual("bar", mismatch.expected)
def test_makeDistribution_created_name_starts_with_distribution(self): distribution = self.factory.makeDistribution() self.assertThat(distribution.name, StartsWith("distribution"))
def test_makeDistribution_created_display_name_starts_Distribution(self): distribution = self.factory.makeDistribution() self.assertThat(distribution.displayname, StartsWith("Distribution"))
def test_bootloader_path_does_not_include_tftp_root(self): tftproot = self.make_tftp_root() method = S390XBootMethod() self.assertThat(method.bootloader_path, Not(StartsWith(tftproot.path)))
def test_uses_prefix(self): prefix = factory.make_string(3) with tempdir(prefix=prefix) as directory: pass self.assertThat(os.path.basename(directory), StartsWith(prefix))
def test_compose_config_path_does_not_include_tftp_root(self): tftproot = self.make_tftp_root().asBytesMode() mac = factory.make_mac_address("-") self.assertThat(compose_config_path(mac), Not(StartsWith(tftproot.path)))
def test_make_name_does_not_require_prefix(self): size = randint(1, 99) unprefixed_name = factory.make_name(sep="-", size=size) self.assertEqual(size, len(unprefixed_name)) self.assertThat(unprefixed_name, Not(StartsWith("-")))
def test_make_name_uses_configurable_separator(self): sep = "SEPARATOR" prefix = factory.make_string(3) self.assertThat(factory.make_name(prefix, sep=sep), StartsWith(prefix + sep))
def test_str_with_unicode(self): u = _u("\xA7") matcher = StartsWith(u) self.assertEqual("StartsWith(%r)" % (u, ), str(matcher))
def test_makeDistroSeries_created_name_starts_with_distroseries(self): distroseries = self.factory.makeDistroSeries() self.assertThat(distroseries.name, StartsWith("distroseries"))
def test_match(self): matcher = StartsWith("bar") self.assertIs(None, matcher.match("barf"))
def test_makeDistroSeries_created_display_name_starts_Distroseries(self): distroseries = self.factory.makeDistroSeries() self.assertThat(distroseries.displayname, StartsWith("Distroseries"))
def test_mismatch_sets_matchee(self): matcher = StartsWith("bar") mismatch = matcher.match("foo") self.assertEqual("foo", mismatch.matchee)
def test_compose_enlistment_preseed_url_returns_absolute_link(self): url = 'http://%s' % factory.make_name('host') self.patch(settings, 'DEFAULT_MAAS_URL', url) self.assertThat(compose_enlistment_preseed_url(), StartsWith(url))
def test_print_module_named_with_dashes_help_for_valid_plugin(self): result = self.run_command(["help", "plainbox-provider"]) expected = " Create parts" self.assertThat(result.output, StartsWith(expected))
def test_compose_preseed_url_returns_absolute_link(self): self.assertThat(compose_preseed_url(factory.make_node()), StartsWith('http://'))
def test_error(self): soname_cache = elf.SonameCache() raised = self.assertRaises(EnvironmentError, soname_cache.__setitem__, self.key, '/soname.so') self.assertThat(str(raised), StartsWith(self.partial_message))
def test_returns_absolute_path(self): self.set_root(".") self.patch(provisioningserver.path, "makedirs") self.assertThat(self.get_path_function(), StartsWith("/")) self.assertEqual(getcwd(), self.get_path_function())
def test_take_screenshot_filepath_is_in_tmp_dir(self): with patch.object(_ss.subprocess, 'check_call'): self.assertThat(_ss._take_mirscreencast_screenshot(), StartsWith(tempfile.gettempdir()))
def test_str(self): matcher = StartsWith("bar") self.assertEqual("StartsWith('bar')", str(matcher))
def test_under_dir(self): root = self.useFixture(TempDir()).path fixture = TempDir(root) fixture.setUp() with fixture: self.assertThat(fixture.path, StartsWith(root))
def test_str_with_bytes(self): b = _b("\xA7") matcher = StartsWith(b) self.assertEqual("StartsWith(%r)" % (b, ), str(matcher))
def test_get_time_string_ends_with_suffix(self): now = time.time() self.assertThat(get_time_string(now), StartsWith(key_prefix))
def setUp(self): super(TestContextMenuImageAndLinkOverlayWebView, self).setUp() self._setup_overlay_webview_context_menu("imagelink") self.assertThat(self.menu.get_title_label().text, StartsWith(self.data_uri_prefix))