本文整理汇总了Python中hypothesis.strategies.uuids方法的典型用法代码示例。如果您正苦于以下问题:Python strategies.uuids方法的具体用法?Python strategies.uuids怎么用?Python strategies.uuids使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hypothesis.strategies
的用法示例。
在下文中一共展示了strategies.uuids方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: node_uuid_pool_strategy
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def node_uuid_pool_strategy(draw, min_number_of_nodes=1):
"""
A strategy to create a pool of node uuids.
:param min_number_of_nodes: The minimum number of nodes to create.
:returns: A strategy to create an iterable of node uuids.
"""
max_number_of_nodes = max(min_number_of_nodes, 10)
return draw(
st.lists(
uuids(),
min_size=min_number_of_nodes,
max_size=max_number_of_nodes
)
)
示例2: related_deployments_strategy
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def related_deployments_strategy(draw, number_of_deployments):
"""
A strategy to generate more than 1 unique deployments that are related.
Specifically, this ensures that:
* all node uuids are drawn from a common pool for all of the deployments.
* deployments contains unique deployements
:param int number_of_deployments: The number of deployments to create.
:returns: A strategy to create ``number_of_deployments`` ``Deployment`` s.
"""
node_uuid_pool = draw(node_uuid_pool_strategy())
deployments = set()
while True:
deployments.add(
draw(deployment_strategy(node_uuid_pool=node_uuid_pool))
)
if len(deployments) == number_of_deployments:
return tuple(deployments)
示例3: unique_name_strategy
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def unique_name_strategy(draw):
"""
A hypothesis strategy to generate an always unique name.
"""
return unicode(draw(st.uuids()))
示例4: lease_strategy
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def lease_strategy(draw, dataset_id=st.uuids(), node_id=st.uuids()):
"""
A hypothesis strategy to generate a ``Lease``
:param dataset_id: A strategy to use to create the dataset_id for the
Lease.
:param node_id: A strategy to use to create the node_id for the Lease.
"""
return Lease(
dataset_id=draw(dataset_id),
node_id=draw(node_id),
expiration=draw(datetimes())
)
示例5: node_strategy
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def node_strategy(
draw,
min_number_of_applications=0,
stateful_applications=False,
uuid=st.uuids(),
applications=application_strategy()
):
"""
A hypothesis strategy to generate a ``Node``
:param uuid: The strategy to use to generate the Node's uuid.
:param applications: The strategy to use to generate the applications on
the Node.
"""
applications = {
a.name: a for a in
draw(
st.lists(
application_strategy(stateful=stateful_applications),
min_size=min_number_of_applications,
average_size=2,
max_size=5
)
)
}
return Node(
uuid=draw(uuid),
applications=applications,
manifestations={
a.volume.manifestation.dataset_id: a.volume.manifestation
for a in applications.values()
if a.volume is not None
}
)
示例6: tasks
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def tasks(draw):
r = dict()
r['id'] = r['_id'] = str(draw(uuids()))
r['alias'] = draw(aliases())
return r
示例7: strategy
# 需要导入模块: from hypothesis import strategies [as 别名]
# 或者: from hypothesis.strategies import uuids [as 别名]
def strategy(self):
return hy_st.uuids()