test_tracker.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pawprint 作者: cbredev 项目源码 文件源码
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)]
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号