From 6d08789ac1f759b66006ab2ec225513863308f91 Mon Sep 17 00:00:00 2001 From: Kevin Morris Date: Thu, 31 Dec 2020 22:00:15 -0800 Subject: [PATCH] add test_popupdate.py We had no coverage over aurweb.scripts.popupdate. This test covers all of its functionality. Signed-off-by: Kevin Morris --- aurweb/db.py | 3 +++ aurweb/scripts/popupdate.py | 1 - test/test_popupdate.py | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 test/test_popupdate.py diff --git a/aurweb/db.py b/aurweb/db.py index 8ca32165..04b40f43 100644 --- a/aurweb/db.py +++ b/aurweb/db.py @@ -1,3 +1,5 @@ +import math + try: import mysql.connector except ImportError: @@ -95,6 +97,7 @@ class Connection: elif aur_db_backend == 'sqlite': aur_db_name = aurweb.config.get('database', 'name') self._conn = sqlite3.connect(aur_db_name) + self._conn.create_function("POWER", 2, math.pow) self._paramstyle = sqlite3.paramstyle else: raise ValueError('unsupported database backend') diff --git a/aurweb/scripts/popupdate.py b/aurweb/scripts/popupdate.py index b64deedb..b1e70403 100755 --- a/aurweb/scripts/popupdate.py +++ b/aurweb/scripts/popupdate.py @@ -7,7 +7,6 @@ import aurweb.db def main(): conn = aurweb.db.Connection() - conn.execute("UPDATE PackageBases SET NumVotes = (" + "SELECT COUNT(*) FROM PackageVotes " + "WHERE PackageVotes.PackageBaseID = PackageBases.ID)") diff --git a/test/test_popupdate.py b/test/test_popupdate.py new file mode 100644 index 00000000..93f86f10 --- /dev/null +++ b/test/test_popupdate.py @@ -0,0 +1,5 @@ +from aurweb.scripts import popupdate + + +def test_popupdate(): + popupdate.main()