コード例 #1
0
def test_check_if_empty_db_false(create_chromium_data):
    not_empty_table = Table(
        table='urls',
        path=create_chromium_data,
        browser=None,
        filename='anything',
        profile=None,
    )
    not_empty_table._connect()
    assert not_empty_table.check_if_db_empty() == False
コード例 #2
0
def test_check_if_empty_db_true(create_chromium_data):
    with tempfile.TemporaryDirectory() as tmpdir:
        dbname = 'empty.sqlite'
        dbpath = str(Path(tmpdir, dbname))
        conn = sqlite3.connect(dbpath)
        conn.close()
        empty_ = Table(
            table='nonexistent_table',
            path=dbpath,
            browser=None,
            filename=dbname,
            profile=None,
        )
        empty_._connect()
        assert empty_.check_if_db_empty() == True
        empty_._connection.close()