linted
This commit is contained in:
@@ -3,7 +3,8 @@ import sqlite3
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
from scripts.utils.notifications import sendAppriseNotifications
|
from scripts.utils.notifications import sendAppriseNotifications
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime
|
||||||
|
|
||||||
|
|
||||||
def create_test_db(db_file):
|
def create_test_db(db_file):
|
||||||
""" create a database connection to a SQLite database """
|
""" create a database connection to a SQLite database """
|
||||||
@@ -22,11 +23,11 @@ def create_test_db(db_file):
|
|||||||
VALUES(?,?) '''
|
VALUES(?,?) '''
|
||||||
|
|
||||||
cur = conn.cursor()
|
cur = conn.cursor()
|
||||||
today = datetime.now().strftime("%Y-%m-%d") # SQLite stores date as YYYY-MM-DD
|
today = datetime.now().strftime("%Y-%m-%d") # SQLite stores date as YYYY-MM-DD
|
||||||
cur.execute(sql, ["Great Crested Flycatcher", today])
|
cur.execute(sql, ["Great Crested Flycatcher", today])
|
||||||
conn.commit()
|
conn.commit()
|
||||||
|
|
||||||
except Error as e:
|
except Exception as e:
|
||||||
print(e)
|
print(e)
|
||||||
finally:
|
finally:
|
||||||
if conn:
|
if conn:
|
||||||
@@ -52,7 +53,7 @@ def test_notifications(mocker):
|
|||||||
|
|
||||||
# No active apprise notifcations configured. Confirm no notifications.
|
# No active apprise notifcations configured. Confirm no notifications.
|
||||||
sendAppriseNotifications("Myiarchus crinitus_Great Crested Flycatcher", "91", "filename", settings_dict, "test.db")
|
sendAppriseNotifications("Myiarchus crinitus_Great Crested Flycatcher", "91", "filename", settings_dict, "test.db")
|
||||||
assert(notify_call.call_count == 0) # No notification should be sent.
|
assert(notify_call.call_count == 0) # No notification should be sent.
|
||||||
|
|
||||||
# Add daily notification.
|
# Add daily notification.
|
||||||
notify_call.reset_mock()
|
notify_call.reset_mock()
|
||||||
@@ -72,7 +73,8 @@ def test_notifications(mocker):
|
|||||||
notify_call.call_args_list[0][0][0] == "A Great Crested Flycatcher (Myiarchus crinitus) was just detected with a confidence of 91 (first time today)"
|
notify_call.call_args_list[0][0][0] == "A Great Crested Flycatcher (Myiarchus crinitus) was just detected with a confidence of 91 (first time today)"
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
notify_call.call_args_list[1][0][0] == "A Great Crested Flycatcher (Myiarchus crinitus) was just detected with a confidence of 91 (only seen 1 times in last 7d)"
|
notify_call.call_args_list[1][0][0] == "A Great Crested Flycatcher (Myiarchus crinitus) \
|
||||||
|
was just detected with a confidence of 91 (only seen 1 times in last 7d)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Add each species notification.
|
# Add each species notification.
|
||||||
|
|||||||
Reference in New Issue
Block a user