# Path: tests/test_utils.py
# def mock_uuid_generator():
#     """
#     Returns a generator object that creates UUID instances with a deterministic
#     and progressive value in the form of `00000000-0000-0000-0000-000000000001`
#     """
#     i = 1
#     while True:
#         yield uuid.UUID('00000000-0000-0000-0000-{:012d}'.format(i))
#         i += 1
# 
# class MockModelCreate:
#     """
#     Override callable class that goes in place of the Model.create()
#     classmethod and allows extra default custom parameters so test objects can
#     be predictable.
#     Defaulted attributes are `created_at`, with a static datetime and `uuid`
#     with a progressive uuid
#     """
# 
#     def __init__(self, cls):
#         self.original = cls.create
#         self.uuid_generator = mock_uuid_generator()
# 
#     def __call__(self, created_at=mock_datetime(), uuid=None, **query):
#         query['created_at'] = created_at
#         query['uuid'] = uuid or next(self.uuid_generator)
#         return self.original(**query)


import uuid
import pytest
import models
from tests.test_utils import mock_uuid_generator, MockModelCreate






@pytest.fixture(autouse=True, name='mockuuid4')
def mock_uuid(mocker):
    """
    Fixture to override the default uuid.uuid4 function to return a
    deterministic uuid instead of a random one.
    """
    muuid = mock_uuid_generator()

    def getuuid():
        return next(muuid)
    mockuuid = mocker.patch.object(uuid, 'uuid4', autospec=True)
    mockuuid.side_effect = getuuid


@pytest.fixture(autouse=True, name='mock_create')
def mock_models_create(mocker):
    """
    Fixture to patch the create method of our models to force a default
    created_at datetime and a progressive UUID-like UUID object when creating
    new instances, but allowing to override with specific values.
    """
    for cls in [models.Order]:
        mocker.patch(
            'models.{}.create'.format(cls.__name__),

# Path: tests/test_utils.py
# def mock_uuid_generator():
#     """
#     Returns a generator object that creates UUID instances with a deterministic
#     and progressive value in the form of `00000000-0000-0000-0000-000000000001`
#     """
#     i = 1
#     while True:
#         yield uuid.UUID('00000000-0000-0000-0000-{:012d}'.format(i))
#         i += 1
# 
# class MockModelCreate:
#     """
#     Override callable class that goes in place of the Model.create()
#     classmethod and allows extra default custom parameters so test objects can
#     be predictable.
#     Defaulted attributes are `created_at`, with a static datetime and `uuid`
#     with a progressive uuid
#     """
# 
#     def __init__(self, cls):
#         self.original = cls.create
#         self.uuid_generator = mock_uuid_generator()
# 
#     def __call__(self, created_at=mock_datetime(), uuid=None, **query):
#         query['created_at'] = created_at
#         query['uuid'] = uuid or next(self.uuid_generator)
#         return self.original(**query)


# Path: tests/conftest.py
import uuid
import pytest
import models
from tests.test_utils import mock_uuid_generator, MockModelCreate







@pytest.fixture(autouse=True, name='mockuuid4')
def mock_uuid(mocker):
    """
    Fixture to override the default uuid.uuid4 function to return a
    deterministic uuid instead of a random one.
    """
    muuid = mock_uuid_generator()

    def getuuid():
        return next(muuid)
    mockuuid = mocker.patch.object(uuid, 'uuid4', autospec=True)
    mockuuid.side_effect = getuuid


@pytest.fixture(autouse=True, name='mock_create')
def mock_models_create(mocker):
    """
    Fixture to patch the create method of our models to force a default
    created_at datetime and a progressive UUID-like UUID object when creating
    new instances, but allowing to override with specific values.
    """
    for cls in [models.Order]:
        mocker.patch(
            'models.{}.create'.format(cls.__name__),

            new=MockModelCreate(cls),