# 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/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/testlib/spanner_emulator/testlib.py
# def _make_emulator_spanner_orm_connection(
#     db: database.Database, inst: instance.Instance,
#     spanner_client: client.Client) -> spanner_orm.SpannerConnection:
# def _get_instance(spanner_client: client.Client) -> instance.Instance:
# def _migrate_database_at_connection(connection: spanner_orm.SpannerConnection,
#                                     migrations_dir: str) -> None:
# def _database_id() -> str:
#   def setUpClass(cls):
#   def setUp(self):
#   def tearDownClass(cls):
#   def run_orm_migrations(self, migrations_folder: str) -> None:
# class TestCase(unittest.TestCase):


import datetime
import logging
import os
import textwrap
import unittest
import spanner_orm
from typing import Iterable, Type
from absl.testing import absltest
from absl.testing import parameterized
from spanner_orm.admin import metadata
from spanner_orm.tests import models
from spanner_orm.testlib.spanner_emulator import testlib as spanner_emulator_testlib
from google.api_core import exceptions as google_api_exceptions
    with self.assertRaisesRegex(
        google_api_exceptions.FailedPrecondition,
        'Cannot find referenced key',
    ):
      models.ForeignKeyTestModel({
          'referencing_key_1': 'key',
          'referencing_key_2': 'key',
          'referencing_key_3': 42,
          'value': 'value'
      }).save()

  def test_key(self):
    models.SmallTestModel({'key': 'key', 'value_1': 'value'}).save()
    models.UnittestModel({
        'string': 'string',
        'int_': 42,
        'float_': 4.2,
        'bytes_': b'A1A1',
        'timestamp': datetime.datetime.now(tz=datetime.timezone.utc),
    }).save()
    models.ForeignKeyTestModel({
        'referencing_key_1': 'key',
        'referencing_key_2': 'string',
        'referencing_key_3': 42,
        'value': 'value'
    }).save()


class SpecificMigrationsEmulatorTest(
    parameterized.TestCase,

# 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/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/testlib/spanner_emulator/testlib.py
# def _make_emulator_spanner_orm_connection(
#     db: database.Database, inst: instance.Instance,
#     spanner_client: client.Client) -> spanner_orm.SpannerConnection:
# def _get_instance(spanner_client: client.Client) -> instance.Instance:
# def _migrate_database_at_connection(connection: spanner_orm.SpannerConnection,
#                                     migrations_dir: str) -> None:
# def _database_id() -> str:
#   def setUpClass(cls):
#   def setUp(self):
#   def tearDownClass(cls):
#   def run_orm_migrations(self, migrations_folder: str) -> None:
# class TestCase(unittest.TestCase):


# Path: spanner_orm/tests/migrations_emulator_test.py
import datetime
import logging
import os
import textwrap
import unittest
import spanner_orm
from typing import Iterable, Type
from absl.testing import absltest
from absl.testing import parameterized
from spanner_orm.admin import metadata
from spanner_orm.tests import models
from spanner_orm.testlib.spanner_emulator import testlib as spanner_emulator_testlib
from google.api_core import exceptions as google_api_exceptions

    with self.assertRaisesRegex(
        google_api_exceptions.FailedPrecondition,
        'Cannot find referenced key',
    ):
      models.ForeignKeyTestModel({
          'referencing_key_1': 'key',
          'referencing_key_2': 'key',
          'referencing_key_3': 42,
          'value': 'value'
      }).save()

  def test_key(self):
    models.SmallTestModel({'key': 'key', 'value_1': 'value'}).save()
    models.UnittestModel({
        'string': 'string',
        'int_': 42,
        'float_': 4.2,
        'bytes_': b'A1A1',
        'timestamp': datetime.datetime.now(tz=datetime.timezone.utc),
    }).save()
    models.ForeignKeyTestModel({
        'referencing_key_1': 'key',
        'referencing_key_2': 'string',
        'referencing_key_3': 42,
        'value': 'value'
    }).save()


class SpecificMigrationsEmulatorTest(
    parameterized.TestCase,

    spanner_emulator_testlib.TestCase,