Example #1
0
class CreateTableDialectTestCase(TestCase):

    _fixtures = [sample.SampleFixture]

    def setUp(self):
        super().setUp()
        from aiorm.orm.dialect.postgresql import CreateTableDialect
        self._dialect = CreateTableDialect()

    def test_render_create_table(self):
        self._dialect.render_create_table(sample.UserGroup)
        self.assertEqual(self._dialect.query,
                         """\
CREATE TABLE IF NOT EXISTS"user_group" (
  "group_id" int NOT NULL,
  "user_id" int NOT NULL,
  CONSTRAINT "user_group_group_id_fkey" FOREIGN KEY ("group_id")
    REFERENCES "group" ("id") MATCH SIMPLE ON UPDATE NO ACTION \
ON DELETE NO ACTION,
  CONSTRAINT "user_group_user_id_fkey" FOREIGN KEY ("user_id")
    REFERENCES "user" ("id") MATCH SIMPLE ON UPDATE NO ACTION ON DELETE NO ACTION
)
""")
Example #2
0
 def setUp(self):
     super().setUp()
     from aiorm.orm.dialect.postgresql import CreateTableDialect
     self._dialect = CreateTableDialect()