# Path: psqlextra/models/base.py
# class PostgresModel(models.Model):
#     """Base class for for taking advantage of PostgreSQL specific features."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
#     objects = PostgresManager()
# 
# Path: psqlextra/models/partitioned.py
# class PostgresPartitionedModel(
#     PostgresModel, metaclass=PostgresPartitionedModelMeta
# ):
#     """Base class for taking advantage of PostgreSQL's 11.x native support for
#     table partitioning."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
# Path: psqlextra/models/view.py
# class PostgresMaterializedViewModel(
#     PostgresViewModel, metaclass=PostgresViewModelMeta
# ):
#     """Base class for creating a model that is a materialized view."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
#     @classmethod
#     def refresh(
#         cls, concurrently: bool = False, using: Optional[str] = None
#     ) -> None:
#         """Refreshes this materialized view.
# 
#         Arguments:
#             concurrently:
#                 Whether to tell PostgreSQL to refresh this
#                 materialized view concurrently.
# 
#             using:
#                 Optionally, the name of the database connection
#                 to use for refreshing the materialized view.
#         """
# 
#         conn_name = using or "default"
# 
#         with connections[conn_name].schema_editor() as schema_editor:
#             schema_editor.refresh_materialized_view_model(cls, concurrently)
# 
# class PostgresViewModel(PostgresModel, metaclass=PostgresViewModelMeta):
#     """Base class for creating a model that is a view."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"


import os
import sys
import uuid
from contextlib import contextmanager
from django.apps import AppConfig, apps
from django.db import connection
from psqlextra.models import (
    PostgresMaterializedViewModel,
    PostgresModel,
    PostgresPartitionedModel,
    PostgresViewModel,
)
):
    """Defines a fake partitioned model."""

    model = define_fake_model(
        fields=fields,
        model_base=PostgresPartitionedModel,
        meta_options=meta_options,
        PartitioningMeta=type(
            "PartitioningMeta", (object,), partitioning_options
        ),
    )

    return model


def get_fake_partitioned_model(
    fields=None, partitioning_options={}, meta_options={}
):
    """Defines a fake partitioned model and creates it in the database."""

    model = define_fake_partitioned_model(
        fields, partitioning_options, meta_options
    )

    with connection.schema_editor() as schema_editor:
        schema_editor.create_model(model)

    return model



# Path: psqlextra/models/base.py
# class PostgresModel(models.Model):
#     """Base class for for taking advantage of PostgreSQL specific features."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
#     objects = PostgresManager()
# 
# Path: psqlextra/models/partitioned.py
# class PostgresPartitionedModel(
#     PostgresModel, metaclass=PostgresPartitionedModelMeta
# ):
#     """Base class for taking advantage of PostgreSQL's 11.x native support for
#     table partitioning."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
# Path: psqlextra/models/view.py
# class PostgresMaterializedViewModel(
#     PostgresViewModel, metaclass=PostgresViewModelMeta
# ):
#     """Base class for creating a model that is a materialized view."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"
# 
#     @classmethod
#     def refresh(
#         cls, concurrently: bool = False, using: Optional[str] = None
#     ) -> None:
#         """Refreshes this materialized view.
# 
#         Arguments:
#             concurrently:
#                 Whether to tell PostgreSQL to refresh this
#                 materialized view concurrently.
# 
#             using:
#                 Optionally, the name of the database connection
#                 to use for refreshing the materialized view.
#         """
# 
#         conn_name = using or "default"
# 
#         with connections[conn_name].schema_editor() as schema_editor:
#             schema_editor.refresh_materialized_view_model(cls, concurrently)
# 
# class PostgresViewModel(PostgresModel, metaclass=PostgresViewModelMeta):
#     """Base class for creating a model that is a view."""
# 
#     class Meta:
#         abstract = True
#         base_manager_name = "objects"


# Path: tests/fake_model.py
import os
import sys
import uuid
from contextlib import contextmanager
from django.apps import AppConfig, apps
from django.db import connection
from psqlextra.models import (
    PostgresMaterializedViewModel,
    PostgresModel,
    PostgresPartitionedModel,
    PostgresViewModel,
)

):
    """Defines a fake partitioned model."""

    model = define_fake_model(
        fields=fields,
        model_base=PostgresPartitionedModel,
        meta_options=meta_options,
        PartitioningMeta=type(
            "PartitioningMeta", (object,), partitioning_options
        ),
    )

    return model


def get_fake_partitioned_model(
    fields=None, partitioning_options={}, meta_options={}
):
    """Defines a fake partitioned model and creates it in the database."""

    model = define_fake_partitioned_model(
        fields, partitioning_options, meta_options
    )

    with connection.schema_editor() as schema_editor:
        schema_editor.create_model(model)

    return model



def get_fake_model(fields=None, model_base=PostgresModel, meta_options={}):