add tests for sqlitemanager util class

+ implement pendulum in date_string_to_time_passed()
+ remove unused bisection_search_string
This commit is contained in:
mungai-njoroge
2023-06-21 12:18:19 +03:00
parent 9d4f7af581
commit 4d310c39c3
10 changed files with 186 additions and 161 deletions
+11 -2
View File
@@ -62,7 +62,12 @@ class SQLiteManager:
for you. It also commits and closes the connection when you're done.
"""
def __init__(self, conn: Optional[Connection] = None, userdata_db=False) -> None:
def __init__(
self,
conn: Optional[Connection] = None,
userdata_db=False,
test_db_path: str = None,
) -> None:
"""
When a connection is passed in, don't close the connection, because it's
a connection to the search database [in memory db].
@@ -70,6 +75,7 @@ class SQLiteManager:
self.conn = conn
self.CLOSE_CONN = True
self.userdata_db = userdata_db
self.test_db_path = test_db_path
if conn:
self.conn = conn
@@ -79,7 +85,10 @@ class SQLiteManager:
if self.conn is not None:
return self.conn.cursor()
db_path = Db.get_app_db_path()
if self.test_db_path:
db_path = self.test_db_path
else:
db_path = Db.get_app_db_path()
if self.userdata_db:
db_path = Db.get_userdata_db_path()