# Path: psqlextra/util.py
# @contextmanager
# def postgres_manager(model):
#     """Allows you to use the :see:PostgresManager with the specified model
#     instance on the fly.
# 
#     Arguments:
#         model:
#             The model or model instance to use this on.
#     """
# 
#     manager = PostgresManager()
#     manager.model = model
# 
#     yield manager
# 
# Path: tests/fake_model.py
# def get_fake_model(fields=None, model_base=PostgresModel, meta_options={}):
#     """Defines a fake model and creates it in the database."""
# 
#     model = define_fake_model(fields, model_base, meta_options)
# 
#     with connection.schema_editor() as schema_editor:
#         schema_editor.create_model(model)
# 
#     return model


from django.db import models
from psqlextra.util import postgres_manager
from .fake_model import get_fake_model




def test_manager_context():
    """Tests whether the :see:postgres_manager context manager can be used to
    get access to :see:PostgresManager on a model that does not use it directly
    or inherits from :see:PostgresModel."""

    model = get_fake_model(
        {"myfield": models.CharField(max_length=255, unique=True)}, models.Model
    )


# Path: psqlextra/util.py
# @contextmanager
# def postgres_manager(model):
#     """Allows you to use the :see:PostgresManager with the specified model
#     instance on the fly.
# 
#     Arguments:
#         model:
#             The model or model instance to use this on.
#     """
# 
#     manager = PostgresManager()
#     manager.model = model
# 
#     yield manager
# 
# Path: tests/fake_model.py
# def get_fake_model(fields=None, model_base=PostgresModel, meta_options={}):
#     """Defines a fake model and creates it in the database."""
# 
#     model = define_fake_model(fields, model_base, meta_options)
# 
#     with connection.schema_editor() as schema_editor:
#         schema_editor.create_model(model)
# 
#     return model


# Path: tests/test_manager_context.py
from django.db import models
from psqlextra.util import postgres_manager
from .fake_model import get_fake_model





def test_manager_context():
    """Tests whether the :see:postgres_manager context manager can be used to
    get access to :see:PostgresManager on a model that does not use it directly
    or inherits from :see:PostgresModel."""

    model = get_fake_model(
        {"myfield": models.CharField(max_length=255, unique=True)}, models.Model
    )


    with postgres_manager(model) as manager: