# Path: spanner_orm/index.py
# class Index(object):
#   PRIMARY_INDEX = 'PRIMARY_KEY'
#   def __init__(self,
#                columns: List[str],
#                parent: Optional[str] = None,
#                null_filtered: bool = False,
#                unique: bool = False,
#                storing_columns: Optional[List[str]] = None):
#   def primary(self) -> bool:
# 
# Path: spanner_orm/admin/column.py
# class ColumnSchema(schema.InformationSchema):
#   def nullable(self) -> bool:
#   def field_type(self) -> Type[field.FieldType]:
# 
# Path: spanner_orm/admin/index.py
# class IndexSchema(schema.InformationSchema):
# 
# Path: spanner_orm/admin/index_column.py
# class IndexColumnSchema(schema.InformationSchema):
# 
# Path: spanner_orm/admin/metadata.py
# class SpannerMetadata(object):
#   def _class_name_from_table(cls, table_name: Optional[str]) -> Optional[str]:
#   def models(cls) -> Dict[str, Type[model.Model]]:
#   def model(cls, table_name) -> Optional[Type[model.Model]]:
#   def tables(cls) -> Dict[str, Dict[str, Any]]:
#   def indexes(cls) -> Dict[str, Dict[str, Any]]:
# 
# Path: spanner_orm/admin/table.py
# class TableSchema(schema.InformationSchema):
# 
# Path: spanner_orm/admin/update.py
# class MigrationUpdate(abc.ABC):
# class NoUpdate(MigrationUpdate):
# class SchemaUpdate(MigrationUpdate, abc.ABC):
# class CreateTable(SchemaUpdate):
# class DropTable(SchemaUpdate):
# class AddColumn(SchemaUpdate):
# class DropColumn(SchemaUpdate):
# class AlterColumn(SchemaUpdate):
# class CreateIndex(SchemaUpdate):
# class DropIndex(SchemaUpdate):
# class ExecutePartitionedDml(MigrationUpdate):
#   def execute(self) -> None:
#   def execute(self) -> None:
#   def ddl(self) -> str:
#   def execute(self) -> None:
#   def validate(self) -> None:
#   def __init__(self, model_: Type[model.Model]):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def _validate_parent(self) -> None:
#   def _validate_primary_keys(self) -> None:
#   def __init__(self, table_name: str):
#   def ddl(self) -> str:
#   def __init__(self, table_name: str, column_name: str, field_: field.Field):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self, table_name: str, column_name: str):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self, table_name: str, column_name: str, field_: field.Field):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self,
#                table_name: str,
#                index_name: str,
#                columns: Iterable[str],
#                interleaved: Optional[str] = None,
#                null_filtered: bool = False,
#                unique: bool = False,
#                storing_columns: Optional[Iterable[str]] = None):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def _validate_columns(self, model_: Type[model.Model]) -> None:
#   def _validate_parent(self, model_: Type[model.Model]) -> None:
#   def __init__(self, table_name: str, index_name: str):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self, dml: str):
#   def execute(self) -> None:
# def model_creation_ddl(model_: Type[model.Model]) -> List[str]:
# 
# Path: spanner_orm/tests/models.py
# class SmallTestModel(model.Model):
# class SmallTestModelWithoutSecondaryIndexes(model.Model):
# class ChildTestModel(model.Model):
# class IndexTestModel(model.Model):
# class RelationshipTestModel(model.Model):
# class ForeignKeyTestModel(model.Model):
# class InheritanceTestModel(SmallTestModel):
# class UnittestModel(model.Model):
# class UnittestModelWithoutSecondaryIndexes(model.Model):
# class NullFilteredIndexModel(model.Model):


import logging
import unittest
from unittest import mock
from spanner_orm import index
from spanner_orm.admin import column
from spanner_orm.admin import index as index_schema
from spanner_orm.admin import index_column
from spanner_orm.admin import metadata
from spanner_orm.admin import table
from spanner_orm.admin import update
from spanner_orm.tests import models
        getattr(meta, index.Index.PRIMARY_INDEX).columns, model.primary_keys)

  @mock.patch('spanner_orm.admin.index.IndexSchema.where')
  @mock.patch('spanner_orm.admin.index_column.IndexColumnSchema.where')
  @mock.patch('spanner_orm.admin.column.ColumnSchema.where')
  @mock.patch('spanner_orm.admin.table.TableSchema.where')
  def test_interleaved(self, tables, columns, index_columns, indexes):
    model = models.SmallTestModel
    parent_model = models.UnittestModel
    tables.return_value = (
        self.make_test_tables(model, parent_table=parent_model.table) +
        self.make_test_tables(parent_model))
    columns.return_value = (
        self.make_test_columns(model) + self.make_test_columns(parent_model))
    index_columns.return_value = (
        self.make_test_index_columns(model) +
        self.make_test_index_columns(parent_model))
    indexes.return_value = (
        self.make_test_index(model) + self.make_test_index(parent_model))

    meta = metadata.SpannerMetadata.models()['SmallTestModel']

    self.assertEqual(meta.table, model.table)
    self.assertEqual(meta.interleaved.table, parent_model.table)

  @mock.patch('spanner_orm.admin.index.IndexSchema.where')
  @mock.patch('spanner_orm.admin.index_column.IndexColumnSchema.where')
  @mock.patch('spanner_orm.admin.column.ColumnSchema.where')
  @mock.patch('spanner_orm.admin.table.TableSchema.where')
  def test_secondary_index(self, tables, columns, index_columns, indexes):

# Path: spanner_orm/index.py
# class Index(object):
#   PRIMARY_INDEX = 'PRIMARY_KEY'
#   def __init__(self,
#                columns: List[str],
#                parent: Optional[str] = None,
#                null_filtered: bool = False,
#                unique: bool = False,
#                storing_columns: Optional[List[str]] = None):
#   def primary(self) -> bool:
# 
# Path: spanner_orm/admin/column.py
# class ColumnSchema(schema.InformationSchema):
#   def nullable(self) -> bool:
#   def field_type(self) -> Type[field.FieldType]:
# 
# Path: spanner_orm/admin/index.py
# class IndexSchema(schema.InformationSchema):
# 
# Path: spanner_orm/admin/index_column.py
# class IndexColumnSchema(schema.InformationSchema):
# 
# Path: spanner_orm/admin/metadata.py
# class SpannerMetadata(object):
#   def _class_name_from_table(cls, table_name: Optional[str]) -> Optional[str]:
#   def models(cls) -> Dict[str, Type[model.Model]]:
#   def model(cls, table_name) -> Optional[Type[model.Model]]:
#   def tables(cls) -> Dict[str, Dict[str, Any]]:
#   def indexes(cls) -> Dict[str, Dict[str, Any]]:
# 
# Path: spanner_orm/admin/table.py
# class TableSchema(schema.InformationSchema):
# 
# Path: spanner_orm/admin/update.py
# class MigrationUpdate(abc.ABC):
# class NoUpdate(MigrationUpdate):
# class SchemaUpdate(MigrationUpdate, abc.ABC):
# class CreateTable(SchemaUpdate):
# class DropTable(SchemaUpdate):
# class AddColumn(SchemaUpdate):
# class DropColumn(SchemaUpdate):
# class AlterColumn(SchemaUpdate):
# class CreateIndex(SchemaUpdate):
# class DropIndex(SchemaUpdate):
# class ExecutePartitionedDml(MigrationUpdate):
#   def execute(self) -> None:
#   def execute(self) -> None:
#   def ddl(self) -> str:
#   def execute(self) -> None:
#   def validate(self) -> None:
#   def __init__(self, model_: Type[model.Model]):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def _validate_parent(self) -> None:
#   def _validate_primary_keys(self) -> None:
#   def __init__(self, table_name: str):
#   def ddl(self) -> str:
#   def __init__(self, table_name: str, column_name: str, field_: field.Field):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self, table_name: str, column_name: str):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self, table_name: str, column_name: str, field_: field.Field):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self,
#                table_name: str,
#                index_name: str,
#                columns: Iterable[str],
#                interleaved: Optional[str] = None,
#                null_filtered: bool = False,
#                unique: bool = False,
#                storing_columns: Optional[Iterable[str]] = None):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def _validate_columns(self, model_: Type[model.Model]) -> None:
#   def _validate_parent(self, model_: Type[model.Model]) -> None:
#   def __init__(self, table_name: str, index_name: str):
#   def ddl(self) -> str:
#   def validate(self) -> None:
#   def __init__(self, dml: str):
#   def execute(self) -> None:
# def model_creation_ddl(model_: Type[model.Model]) -> List[str]:
# 
# Path: spanner_orm/tests/models.py
# class SmallTestModel(model.Model):
# class SmallTestModelWithoutSecondaryIndexes(model.Model):
# class ChildTestModel(model.Model):
# class IndexTestModel(model.Model):
# class RelationshipTestModel(model.Model):
# class ForeignKeyTestModel(model.Model):
# class InheritanceTestModel(SmallTestModel):
# class UnittestModel(model.Model):
# class UnittestModelWithoutSecondaryIndexes(model.Model):
# class NullFilteredIndexModel(model.Model):


# Path: spanner_orm/tests/admin_test.py
import logging
import unittest
from unittest import mock
from spanner_orm import index
from spanner_orm.admin import column
from spanner_orm.admin import index as index_schema
from spanner_orm.admin import index_column
from spanner_orm.admin import metadata
from spanner_orm.admin import table
from spanner_orm.admin import update
from spanner_orm.tests import models

        getattr(meta, index.Index.PRIMARY_INDEX).columns, model.primary_keys)

  @mock.patch('spanner_orm.admin.index.IndexSchema.where')
  @mock.patch('spanner_orm.admin.index_column.IndexColumnSchema.where')
  @mock.patch('spanner_orm.admin.column.ColumnSchema.where')
  @mock.patch('spanner_orm.admin.table.TableSchema.where')
  def test_interleaved(self, tables, columns, index_columns, indexes):
    model = models.SmallTestModel
    parent_model = models.UnittestModel
    tables.return_value = (
        self.make_test_tables(model, parent_table=parent_model.table) +
        self.make_test_tables(parent_model))
    columns.return_value = (
        self.make_test_columns(model) + self.make_test_columns(parent_model))
    index_columns.return_value = (
        self.make_test_index_columns(model) +
        self.make_test_index_columns(parent_model))
    indexes.return_value = (
        self.make_test_index(model) + self.make_test_index(parent_model))

    meta = metadata.SpannerMetadata.models()['SmallTestModel']

    self.assertEqual(meta.table, model.table)
    self.assertEqual(meta.interleaved.table, parent_model.table)

  @mock.patch('spanner_orm.admin.index.IndexSchema.where')
  @mock.patch('spanner_orm.admin.index_column.IndexColumnSchema.where')
  @mock.patch('spanner_orm.admin.column.ColumnSchema.where')
  @mock.patch('spanner_orm.admin.table.TableSchema.where')
  def test_secondary_index(self, tables, columns, index_columns, indexes):

    model = models.SmallTestModel