def setUp(self): create_tables(*COMPLEX_SCHEMA, if_not_exists=True) small_table = SmallTable(varchar_col="Test") small_table.save().run_sync() mega_table = MegaTable( array_col=["bob", "sally"], bigint_col=1, boolean_col=True, bytea_col="hello".encode("utf8"), date_col=datetime.date(year=2021, month=1, day=1), double_precision_col=1.344, integer_col=1, interval_col=datetime.timedelta(seconds=10), json_col={"a": 1}, jsonb_col={"a": 1}, numeric_col=decimal.Decimal("1.1"), real_col=1.1, smallint_col=1, text_col="hello", timestamp_col=datetime.datetime(year=2021, month=1, day=1), timestamptz_col=datetime.datetime(year=2021, month=1, day=1, tzinfo=datetime.timezone.utc), uuid_col=uuid.UUID("12783854-c012-4c15-8183-8eecb46f2c4e"), varchar_col="hello", ) mega_table.save().run_sync() SmallToMega(small=small_table, mega=mega_table).save().run_sync() self.mega_table = mega_table
def setUp(self): create_tables(*TABLES) manager_1 = Manager.objects().create(name="Guido").run_sync() manager_2 = Manager.objects().create(name="Graydon").run_sync() band_1 = (Band.objects().create(name="Pythonistas", manager=manager_1).run_sync()) band_2 = (Band.objects().create(name="Rustaceans", manager=manager_2).run_sync()) venue = (Venue.objects().create(name="Royal Albert Hall", capacity=5900).run_sync()) concert = (Concert.objects().create(venue=venue, band_1=band_1, band_2=band_2).run_sync()) Ticket.objects().create(price=decimal.Decimal(50.0), concert=concert).run_sync()
def setUp(self): create_tables(*CUSTOM_PK_SCHEMA, if_not_exists=True) bob = Customer.objects().create(name="Bob").run_sync() sally = Customer.objects().create(name="Sally").run_sync() fred = Customer.objects().create(name="Fred").run_sync() rockfest = Concert.objects().create(name="Rockfest").run_sync() folkfest = Concert.objects().create(name="Folkfest").run_sync() classicfest = Concert.objects().create(name="Classicfest").run_sync() CustomerToConcert.insert( CustomerToConcert(customer=bob, concert=rockfest), CustomerToConcert(customer=bob, concert=classicfest), CustomerToConcert(customer=sally, concert=rockfest), CustomerToConcert(customer=sally, concert=folkfest), CustomerToConcert(customer=fred, concert=classicfest), ).run_sync()
def setUp(self): create_tables(*SIMPLE_SCHEMA, if_not_exists=True) Band.insert( Band(name="Pythonistas"), Band(name="Rustaceans"), Band(name="C-Sharps"), ).run_sync() Genre.insert( Genre(name="Rock"), Genre(name="Folk"), Genre(name="Classical"), ).run_sync() GenreToBand.insert( GenreToBand(band=1, genre=1), GenreToBand(band=1, genre=2), GenreToBand(band=2, genre=2), GenreToBand(band=3, genre=1), GenreToBand(band=3, genre=3), ).run_sync()
def setUp(self): create_tables(Band, Manager)
def setUp(self): create_tables(Manager, Band)
def test_create_tables(self): create_tables(Manager, Band, if_not_exists=False) self.assertTrue(Manager.table_exists().run_sync()) self.assertTrue(Band.table_exists().run_sync())