本文整理汇总了Python中testtools.matchers.Equals方法的典型用法代码示例。如果您正苦于以下问题:Python matchers.Equals方法的具体用法?Python matchers.Equals怎么用?Python matchers.Equals使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类testtools.matchers
的用法示例。
在下文中一共展示了matchers.Equals方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_run
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_run(self):
"""
The script creates a new release version branch in a new working
directory and prints some shell commands to ``stdout``.
"""
expected_version = "9.9.9"
script_path = self.make_temporary_directory()
repo_path = script_path.sibling(
'flocker-release-{}'.format(expected_version)
)
result = run_process(
[INITIALIZE_RELEASE_PATH.path,
'--flocker-version={}'.format(expected_version)],
cwd=script_path.path
)
self.expectThat(result.status, Equals(0))
self.expectThat(
result.output,
Contains('export VERSION={}'.format(expected_version))
)
self.expectThat(
Repo(path=repo_path.path).active_branch.name,
Equals('release/flocker-{}'.format(expected_version))
)
示例2: test_consistent_hash
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_consistent_hash(self):
"""
A given deployment hashes to a specific value.
"""
# Unfortunately these are manually created golden values generated by
# running the test with wrong values and copying the output into this
# file. This test mostly adds value in verifying that the hashes
# computed in all of our CI environments are the same.
TEST_DEPLOYMENT_1_HASH = ''.join(chr(x) for x in [
0x87, 0x13, 0xcb, 0x47, 0x60, 0xd7, 0xab, 0x0f,
0x30, 0xd5, 0xd2, 0x78, 0xe8, 0x12, 0x5d, 0x11
])
TEST_DEPLOYMENT_2_HASH = ''.join(chr(x) for x in [
0x5f, 0xc0, 0x2b, 0x4c, 0x57, 0x75, 0x35, 0xff,
0x6d, 0x1f, 0xd2, 0xc0, 0x14, 0xcf, 0x45, 0x32
])
self.assertThat(
generation_hash(TEST_DEPLOYMENT_1),
Equals(TEST_DEPLOYMENT_1_HASH)
)
self.assertThat(
generation_hash(TEST_DEPLOYMENT_2),
Equals(TEST_DEPLOYMENT_2_HASH)
)
示例3: test_deployment_diffing_composable
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_deployment_diffing_composable(self, deployments):
"""
Diffs should compose to create an aggregate diff.
Create a bunch of deployments and compute the incremental diffs from
one to the next. Compose all diffs together and apply the resulting
diff to the first deployment. Verify that the final deployment is the
result.
"""
reserialize = lambda x: wire_decode(wire_encode(x))
deployment_diffs = list(
reserialize(create_diff(a, b))
for a, b in zip(deployments[:-1], deployments[1:])
)
full_diff = reserialize(compose_diffs(deployment_diffs))
self.assertThat(
full_diff.apply(deployments[0]),
Equals(deployments[-1])
)
示例4: test_equal_objects
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_equal_objects(self):
"""
Diffing objects that are equal results in an object that is smaller
than the object.
"""
baseobj = frozenset(xrange(1000))
object_a = DiffTestObj(a=baseobj)
object_b = DiffTestObj(a=baseobj)
diff = create_diff(object_a, object_b)
serialized_diff = wire_encode(diff)
self.assertThat(
len(serialized_diff),
LessThan(len(dumps(list(baseobj))))
)
self.assertThat(
wire_decode(serialized_diff).apply(object_a),
Equals(object_b)
)
示例5: test_straight_swap
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_straight_swap(self):
"""
A diff composed of two separate ``set`` operations can be applied to an
object without triggering an invariant exception.
"""
o1 = DiffTestObjInvariant(
a=1,
b=2,
)
o2 = DiffTestObjInvariant(
a=2,
b=1,
)
diff = create_diff(o1, o2)
self.expectThat(len(diff.changes), Equals(2))
self.assertEqual(
o2,
diff.apply(o1)
)
示例6: test_create_service_v3
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_create_service_v3(self):
service_data = self._get_service_data(name='a service', type='network',
description='A test service')
self.register_uris([
dict(method='POST',
uri=self.get_mock_url(),
status_code=200,
json=service_data.json_response_v3,
validate=dict(json={'service': service_data.json_request}))
])
service = self.cloud.create_service(
name=service_data.service_name,
service_type=service_data.service_type,
description=service_data.description)
self.assertThat(service.name,
matchers.Equals(service_data.service_name))
self.assertThat(service.id, matchers.Equals(service_data.service_id))
self.assertThat(service.description,
matchers.Equals(service_data.description))
self.assertThat(service.type,
matchers.Equals(service_data.service_type))
self.assert_calls()
示例7: test_list_services
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_list_services(self):
service_data = self._get_service_data()
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(),
status_code=200,
json={'services': [service_data.json_response_v3['service']]})
])
services = self.cloud.list_services()
self.assertThat(len(services), matchers.Equals(1))
self.assertThat(services[0].id,
matchers.Equals(service_data.service_id))
self.assertThat(services[0].name,
matchers.Equals(service_data.service_name))
self.assertThat(services[0].type,
matchers.Equals(service_data.service_type))
self.assert_calls()
示例8: test_update_role
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_update_role(self):
role_data = self._get_role_data()
req = {'role_id': role_data.role_id,
'role': {'name': role_data.role_name}}
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(),
status_code=200,
json={'roles': [role_data.json_response['role']]}),
dict(method='PATCH',
uri=self.get_mock_url(),
status_code=200,
json=role_data.json_response,
validate=dict(json=req))
])
role = self.cloud.update_role(
role_data.role_id, role_data.role_name)
self.assertIsNotNone(role)
self.assertThat(role.name, matchers.Equals(role_data.role_name))
self.assertThat(role.id, matchers.Equals(role_data.role_id))
self.assert_calls()
示例9: test_create_project_v3
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_create_project_v3(self,):
project_data = self._get_project_data(
description=self.getUniqueString('projectDesc'))
reference_req = project_data.json_request.copy()
reference_req['project']['enabled'] = True
self.register_uris([
dict(method='POST',
uri=self.get_mock_url(),
status_code=200,
json=project_data.json_response,
validate=dict(json=reference_req))
])
project = self.cloud.create_project(
name=project_data.project_name,
description=project_data.description,
domain_id=project_data.domain_id)
self.assertThat(project.id, matchers.Equals(project_data.project_id))
self.assertThat(
project.name, matchers.Equals(project_data.project_name))
self.assertThat(
project.description, matchers.Equals(project_data.description))
self.assertThat(
project.domain_id, matchers.Equals(project_data.domain_id))
self.assert_calls()
示例10: test_list_projects_v3_kwarg
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_list_projects_v3_kwarg(self):
project_data = self._get_project_data(
description=self.getUniqueString('projectDesc'))
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
resource=('projects?domain_id=%s' %
project_data.domain_id)),
status_code=200,
json={'projects': [project_data.json_response['project']]})
])
projects = self.cloud.list_projects(
domain_id=project_data.domain_id)
self.assertThat(len(projects), matchers.Equals(1))
self.assertThat(
projects[0].id, matchers.Equals(project_data.project_id))
self.assert_calls()
示例11: test_list_projects_search_compat_v3
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_list_projects_search_compat_v3(self):
project_data = self._get_project_data(
description=self.getUniqueString('projectDesc'))
self.register_uris([
dict(method='GET',
uri=self.get_mock_url(
resource=('projects?domain_id=%s' %
project_data.domain_id)),
status_code=200,
json={'projects': [project_data.json_response['project']]})
])
projects = self.cloud.search_projects(
domain_id=project_data.domain_id)
self.assertThat(len(projects), matchers.Equals(1))
self.assertThat(
projects[0].id, matchers.Equals(project_data.project_id))
self.assert_calls()
示例12: test_update_domain
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_update_domain(self):
domain_data = self._get_domain_data(
description=self.getUniqueString('domainDesc'))
domain_resource_uri = self.get_mock_url(append=[domain_data.domain_id])
self.register_uris([
dict(method='PATCH', uri=domain_resource_uri, status_code=200,
json=domain_data.json_response,
validate=dict(json=domain_data.json_request))])
domain = self.cloud.update_domain(
domain_data.domain_id,
name=domain_data.domain_name,
description=domain_data.description)
self.assertThat(domain.id, matchers.Equals(domain_data.domain_id))
self.assertThat(domain.name, matchers.Equals(domain_data.domain_name))
self.assertThat(
domain.description, matchers.Equals(domain_data.description))
self.assert_calls()
示例13: test_update_domain_name_or_id
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_update_domain_name_or_id(self):
domain_data = self._get_domain_data(
description=self.getUniqueString('domainDesc'))
domain_resource_uri = self.get_mock_url(append=[domain_data.domain_id])
self.register_uris([
dict(method='GET', uri=self.get_mock_url(), status_code=200,
json={'domains': [domain_data.json_response['domain']]}),
dict(method='PATCH', uri=domain_resource_uri, status_code=200,
json=domain_data.json_response,
validate=dict(json=domain_data.json_request))])
domain = self.cloud.update_domain(
name_or_id=domain_data.domain_id,
name=domain_data.domain_name,
description=domain_data.description)
self.assertThat(domain.id, matchers.Equals(domain_data.domain_id))
self.assertThat(domain.name, matchers.Equals(domain_data.domain_name))
self.assertThat(
domain.description, matchers.Equals(domain_data.description))
self.assert_calls()
示例14: test_prepare_request_body
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_prepare_request_body(self):
body = {
'fake': {
'name': 'terminator',
'model': 'T-800',
}
}
params = [
{'param-name': 'name',
'required': True},
{'param-name': 'model',
'required': True},
{'param-name': 'quote',
'required': False,
'default-value': "i'll be back"},
]
expect = {
'fake': {
'name': 'terminator',
'model': 'T-800',
'quote': "i'll be back",
}
}
actual = self.controller._prepare_request_body(body, params)
self.assertThat(expect, matchers.Equals(actual))
示例15: test_create_service_v3
# 需要导入模块: from testtools import matchers [as 别名]
# 或者: from testtools.matchers import Equals [as 别名]
def test_create_service_v3(self):
service_data = self._get_service_data(name='a service', type='network',
description='A test service')
self.register_uris([
dict(method='POST',
uri=self.get_mock_url(),
status_code=200,
json=service_data.json_response_v3,
validate=dict(json={'service': service_data.json_request}))
])
service = self.op_cloud.create_service(
name=service_data.service_name,
service_type=service_data.service_type,
description=service_data.description)
self.assertThat(service.name,
matchers.Equals(service_data.service_name))
self.assertThat(service.id, matchers.Equals(service_data.service_id))
self.assertThat(service.description,
matchers.Equals(service_data.description))
self.assertThat(service.type,
matchers.Equals(service_data.service_type))
self.assert_calls()