Python testtools.matchers.StartsWith() Examples
The following are 30
code examples of testtools.matchers.StartsWith().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
testtools.matchers
, or try the search function
.
Example #1
Source File: test_boot.py From maas with GNU Affero General Public License v3.0 | 6 votes |
def test_preseed_url_for_known_node_local_ip_no_subnet(self): rack_url = "http://%s" % factory.make_name("host") network = IPNetwork("10.1.1/24") local_ip = factory.pick_ip_in_network(network) remote_ip = factory.make_ip_address() self.patch(server_address, "resolve_hostname").return_value = { local_ip } rack_controller = factory.make_RackController(url=rack_url) node = self.make_node(primary_rack=rack_controller) mac = node.get_boot_interface().mac_address self.patch_autospec(boot_module, "event_log_pxe_request") observed_config = get_config( rack_controller.system_id, local_ip, remote_ip, mac=mac ) self.assertThat( observed_config["preseed_url"], StartsWith("http://%s:5248" % local_ip), )
Example #2
Source File: test_boot.py From maas with GNU Affero General Public License v3.0 | 6 votes |
def test_preseed_url_for_known_node_local_ip_subnet_with_dns(self): rack_url = "http://%s" % factory.make_name("host") subnet = factory.make_Subnet() local_ip = factory.pick_ip_in_Subnet(subnet) remote_ip = factory.make_ip_address() self.patch(server_address, "resolve_hostname").return_value = { local_ip } rack_controller = factory.make_RackController(url=rack_url) node = self.make_node(primary_rack=rack_controller) mac = node.get_boot_interface().mac_address self.patch_autospec(boot_module, "event_log_pxe_request") observed_config = get_config( rack_controller.system_id, local_ip, remote_ip, mac=mac ) self.assertThat( observed_config["preseed_url"], StartsWith("http://%s:5248" % local_ip), )
Example #3
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_capitalized_headers_partial(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit('Sem-ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #4
Source File: test_tftppath.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def test_compose_image_path_does_not_include_tftp_root(self): osystem = factory.make_name("osystem") arch = factory.make_name("arch") subarch = factory.make_name("subarch") release = factory.make_name("release") label = factory.make_name("label") self.assertThat( compose_image_path(osystem, arch, subarch, release, label), Not(StartsWith(self.tftproot)), )
Example #5
Source File: test_boot.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def test_preseed_url_for_known_node_internal_domain(self): rack_url = "http://%s" % factory.make_name("host") rack_controller = factory.make_RackController(url=rack_url) vlan = factory.make_VLAN(dhcp_on=True, primary_rack=rack_controller) subnet = factory.make_Subnet(vlan=vlan) subnet.dns_servers = [] subnet.save() local_ip = factory.pick_ip_in_Subnet(subnet) remote_ip = factory.make_ip_address() self.patch(server_address, "resolve_hostname").return_value = { local_ip } node = self.make_node(primary_rack=rack_controller) mac = node.get_boot_interface().mac_address self.patch_autospec(boot_module, "event_log_pxe_request") observed_config = get_config( rack_controller.system_id, local_ip, remote_ip, mac=mac ) self.assertThat( observed_config["preseed_url"], StartsWith( "http://%s.%s:5248" % ( get_resource_name_for_subnet(subnet), Config.objects.get_config("maas_internal_domain"), ) ), )
Example #6
Source File: test_sslkey.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def test_sslkey_display_is_HTML_safe(self): self.patch( sslkey_module, "find_ssl_common_name" ).return_value = "<escape>" key_string = get_data("data/test_x509_0.pem") user = factory.make_User() key = SSLKey(key=key_string, user=user) display = key.display_html() self.assertThat(display, StartsWith("<escape>")) self.assertNotIn("<", display) self.assertNotIn(">", display)
Example #7
Source File: test_nonces_cleanup.py From maas with GNU Affero General Public License v3.0 | 5 votes |
def test_get_time_string_ends_with_suffix(self): now = time.time() self.assertThat(get_time_string(now), StartsWith(key_prefix))
Example #8
Source File: test_context.py From neutron-lib with Apache License 2.0 | 5 votes |
def test_neutron_context_create(self): ctx = context.Context('user_id', 'tenant_id') self.assertEqual('user_id', ctx.user_id) self.assertEqual('tenant_id', ctx.project_id) self.assertEqual('tenant_id', ctx.tenant_id) request_id = ctx.request_id if isinstance(request_id, bytes): request_id = request_id.decode('utf-8') self.assertThat(request_id, matchers.StartsWith('req-')) self.assertEqual('user_id', ctx.user) self.assertEqual('tenant_id', ctx.tenant) self.assertIsNone(ctx.user_name) self.assertIsNone(ctx.tenant_name) self.assertIsNone(ctx.project_name) self.assertIsNone(ctx.auth_token)
Example #9
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_capitalized_headers(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit('Sem-Ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #10
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_capitalized_headers_partial(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit('Sem-ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #11
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_non_canonical_tagged_version_bump(self): self.repo.commit() self.repo.tag('1.4') self.repo.commit('Sem-Ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #12
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_untagged_version_has_dev_version_postversion(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit() version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('1.2.4.dev1'))
Example #13
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_untagged_pre_release_has_pre_dev_version_postversion(self): self.repo.commit() self.repo.tag('1.2.3.0a1') self.repo.commit() version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('1.2.3.0a2.dev1'))
Example #14
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_untagged_version_major_bump(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit('sem-ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #15
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_untagged_version_has_dev_version_preversion(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit() version = packaging._get_version_from_git('1.2.5') self.assertThat(version, matchers.StartsWith('1.2.5.dev1'))
Example #16
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_untagged_version_after_pre_has_dev_version_preversion(self): self.repo.commit() self.repo.tag('1.2.3.0a1') self.repo.commit() version = packaging._get_version_from_git('1.2.5') self.assertThat(version, matchers.StartsWith('1.2.5.dev1'))
Example #17
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_untagged_version_after_rc_has_dev_version_preversion(self): self.repo.commit() self.repo.tag('1.2.3.0a1') self.repo.commit() version = packaging._get_version_from_git('1.2.3') self.assertThat(version, matchers.StartsWith('1.2.3.0a2.dev1'))
Example #18
Source File: test_packaging.py From keras-lambda with MIT License | 5 votes |
def test_preversion_too_low_simple(self): # That is, the target version is either already released or not high # enough for the semver requirements given api breaks etc. self.repo.commit() self.repo.tag('1.2.3') self.repo.commit() # Note that we can't target 1.2.3 anymore - with 1.2.3 released we # need to be working on 1.2.4. err = self.assertRaises( ValueError, packaging._get_version_from_git, '1.2.3') self.assertThat(err.args[0], matchers.StartsWith('git history'))
Example #19
Source File: test_multipart.py From python-libmaas with GNU Affero General Public License v3.0 | 5 votes |
def test_encode_multipart_data_multiple_params(self): # Sequences of parameters and files passed to # encode_multipart_data() permit use of the same name for # multiple parameters and/or files. See `make_payloads` to # understand how it processes different types of parameter # values. params_in = [("one", "ABC"), ("one", "XYZ"), ("two", ["DEF", "UVW"])] files = [ BytesIO(b"f1"), self.makeFile(contents=b"f2").open("rb"), self.makeFile(contents=b"f3").open("rb"), ] for fd in files: self.addCleanup(fd.close) files_in = [ ("f-one", files[0]), ("f-two", files[1]), ("f-three", lambda: files[2]), ] body, headers = encode_multipart_data(params_in, files_in) self.assertEqual("%s" % len(body), headers["Content-Length"]) self.assertThat( headers["Content-Type"], StartsWith("multipart/form-data; boundary=") ) # Round-trip through Django's multipart code. params_out, files_out = parse_headers_and_body_with_django(headers, body) params_out_expected = MultiValueDict() params_out_expected.appendlist("one", "ABC") params_out_expected.appendlist("one", "XYZ") params_out_expected.appendlist("two", "DEF") params_out_expected.appendlist("two", "UVW") self.assertEqual(params_out_expected, params_out, ahem_django_ahem) files_expected = {"f-one": b"f1", "f-two": b"f2", "f-three": b"f3"} files_observed = {name: buf.read() for name, buf in files_out.items()} self.assertEqual(files_expected, files_observed, ahem_django_ahem)
Example #20
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_capitalized_headers(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit('Sem-Ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #21
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_non_canonical_tagged_version_bump(self): self.repo.commit() self.repo.tag('1.4') self.repo.commit('Sem-Ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #22
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_untagged_version_has_dev_version_postversion(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit() version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('1.2.4.dev1'))
Example #23
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_untagged_pre_release_has_pre_dev_version_postversion(self): self.repo.commit() self.repo.tag('1.2.3.0a1') self.repo.commit() version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('1.2.3.0a2.dev1'))
Example #24
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_untagged_version_major_bump(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit('sem-ver: api-break') version = packaging._get_version_from_git() self.assertThat(version, matchers.StartsWith('2.0.0.dev1'))
Example #25
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_untagged_version_has_dev_version_preversion(self): self.repo.commit() self.repo.tag('1.2.3') self.repo.commit() version = packaging._get_version_from_git('1.2.5') self.assertThat(version, matchers.StartsWith('1.2.5.dev1'))
Example #26
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_untagged_version_after_pre_has_dev_version_preversion(self): self.repo.commit() self.repo.tag('1.2.3.0a1') self.repo.commit() version = packaging._get_version_from_git('1.2.5') self.assertThat(version, matchers.StartsWith('1.2.5.dev1'))
Example #27
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_untagged_version_after_rc_has_dev_version_preversion(self): self.repo.commit() self.repo.tag('1.2.3.0a1') self.repo.commit() version = packaging._get_version_from_git('1.2.3') self.assertThat(version, matchers.StartsWith('1.2.3.0a2.dev1'))
Example #28
Source File: test_packaging.py From auto-alt-text-lambda-api with MIT License | 5 votes |
def test_preversion_too_low_simple(self): # That is, the target version is either already released or not high # enough for the semver requirements given api breaks etc. self.repo.commit() self.repo.tag('1.2.3') self.repo.commit() # Note that we can't target 1.2.3 anymore - with 1.2.3 released we # need to be working on 1.2.4. err = self.assertRaises( ValueError, packaging._get_version_from_git, '1.2.3') self.assertThat(err.args[0], matchers.StartsWith('git history'))
Example #29
Source File: base.py From vitrage with Apache License 2.0 | 5 votes |
def assert_starts_with(self, expected_prefix, observed_str, msg=None): self.assertThat(observed_str, matchers.StartsWith(expected_prefix), msg)
Example #30
Source File: test_context.py From tacker with Apache License 2.0 | 5 votes |
def test_tacker_context_create(self): ctx = context.Context('user_id', 'tenant_id') self.assertEqual('user_id', ctx.user_id) self.assertEqual('tenant_id', ctx.project_id) self.assertEqual('tenant_id', ctx.tenant_id) self.assertThat(ctx.request_id, matchers.StartsWith('req-')) self.assertEqual('user_id', ctx.user_id) self.assertEqual('tenant_id', ctx.project_id) self.assertIsNone(ctx.user_name) self.assertIsNone(ctx.tenant_name)