summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Morris <kevr@0cost.org>2021-01-01 07:00:15 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2021-02-20 17:52:52 +0100
commita376020977085d08a49d427e6bf7c4266a7f6413 (patch)
treedc8279df67f0532b673138872800abd6e42592dc
parent3b7ebc7693933a2520c50fa89296a77dad020f47 (diff)
downloadaur-a376020977085d08a49d427e6bf7c4266a7f6413.tar.gz
aur-a376020977085d08a49d427e6bf7c4266a7f6413.tar.xz
add test_popupdate.py
We had no coverage over aurweb.scripts.popupdate. This test covers all of its functionality. Signed-off-by: Kevin Morris <kevr@0cost.org>
-rw-r--r--aurweb/db.py3
-rwxr-xr-xaurweb/scripts/popupdate.py1
-rw-r--r--test/test_popupdate.py5
3 files changed, 8 insertions, 1 deletions
diff --git a/aurweb/db.py b/aurweb/db.py
index 02aeba38..8b9b8ada 100644
--- a/aurweb/db.py
+++ b/aurweb/db.py
@@ -1,3 +1,5 @@
+import math
+
try:
import mysql.connector
except ImportError:
@@ -91,6 +93,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()