-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Primative pytest test for upgrade_db
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import sqlite3 | ||
|
||
from logpyle import (upgrade_db) | ||
|
||
|
||
def test_upgrade_v2_v3(): | ||
path = ".github/workflows/log_gathered_v2.sqlite" | ||
suffix = "_pytest_upgrade" | ||
# print(path.rsplit(".", 1)) | ||
# assert False | ||
filename, file_ext = path.rsplit(".", 1) | ||
|
||
# ensure it is V2 | ||
conn = sqlite3.connect(filename + "." + file_ext) | ||
try: | ||
# should throw an exception because logging | ||
# should not exist in a V2 database | ||
print([ele for ele in conn.execute("select * from logging")]) | ||
assert False, f"{filename} is a v3 database" | ||
except sqlite3.OperationalError: | ||
pass # v2 should not have a logging table | ||
conn.close() | ||
|
||
upgrade_db.upgrade_db(path, suffix, False) | ||
|
||
# ensure it is V3 | ||
conn = sqlite3.connect(filename + suffix + "." + file_ext) | ||
try: | ||
print([ele for ele in conn.execute("select * from logging")]) | ||
except sqlite3.OperationalError: | ||
assert False, f"{filename} is not a v3 database" | ||
conn.close() |