def test_create_table_with_default_options(self):
"""Ensure the table is correctly created with the default schema."""
tracker = pawprint.Tracker(db=db, table=table)
# The table shouldn't exist. Assert it's correct created.
assert tracker.create_table() == None
# Try creating it again. This should raise an error.
with pytest.raises(ProgrammingError):
tracker.create_table()
# Assert the table is empty when created
assert pd.io.sql.execute("SELECT COUNT(*) FROM {}".format(table), db).fetchall() == [(0,)]
# Ensure its schema is correct
schema = pd.io.sql.execute(
"SELECT column_name, data_type, character_maximum_length "
"FROM INFORMATION_SCHEMA.COLUMNS "
"WHERE table_name = '{}'".format(table),
db).fetchall()
assert schema == [(u"id", u"integer", None),
(u"timestamp", u"timestamp without time zone", None),
(u"user_id", u"text", None),
(u"event", u"text", None),
(u"metadata", u"jsonb", None)]
评论列表
文章目录