Python源码示例:hypothesis.strategies.uuids()

示例1
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
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
def unique_name_strategy(draw):
    """
    A hypothesis strategy to generate an always unique name.
    """
    return unicode(draw(st.uuids())) 
示例4
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
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
def tasks(draw):
    r = dict()
    r['id'] = r['_id'] = str(draw(uuids()))
    r['alias'] = draw(aliases())
    return r 
示例7
def strategy(self):
        return hy_st.uuids()