Python hypothesis.strategies.uuids() Examples

The following are 7 code examples of hypothesis.strategies.uuids(). 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 hypothesis.strategies , or try the search function .
Example #1
Source File: testtools.py    From flocker with Apache License 2.0 6 votes vote down vote up
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
        )
    ) 
Example #2
Source File: testtools.py    From flocker with Apache License 2.0 6 votes vote down vote up
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) 
Example #3
Source File: testtools.py    From flocker with Apache License 2.0 5 votes vote down vote up
def unique_name_strategy(draw):
    """
    A hypothesis strategy to generate an always unique name.
    """
    return unicode(draw(st.uuids())) 
Example #4
Source File: testtools.py    From flocker with Apache License 2.0 5 votes vote down vote up
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())
    ) 
Example #5
Source File: testtools.py    From flocker with Apache License 2.0 5 votes vote down vote up
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
        }
    ) 
Example #6
Source File: test_cli.py    From habitipy with MIT License 5 votes vote down vote up
def tasks(draw):
    r = dict()
    r['id'] = r['_id'] = str(draw(uuids()))
    r['alias'] = draw(aliases())
    return r 
Example #7
Source File: primitivestrategies.py    From swagger-conformance with MIT License 5 votes vote down vote up
def strategy(self):
        return hy_st.uuids()