aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/db/test_db.py
diff options
context:
space:
mode:
authorBonfaceKilz2021-07-26 22:01:36 +0300
committerBonfaceKilz2021-07-26 22:01:36 +0300
commit0b8f5fef2398385113d8e480050b8cb1ed404b4d (patch)
treed684cc7f02eabedc5918762bf28deb4148f44063 /tests/unit/db/test_db.py
parentab108e2988ed15b3de4db506a36444d9c736348d (diff)
downloadgenenetwork3-0b8f5fef2398385113d8e480050b8cb1ed404b4d.tar.gz
tests: test_db: Add test case for "update_raw"
Diffstat (limited to 'tests/unit/db/test_db.py')
-rw-r--r--tests/unit/db/test_db.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/unit/db/test_db.py b/tests/unit/db/test_db.py
index e47c9fd..1bcde35 100644
--- a/tests/unit/db/test_db.py
+++ b/tests/unit/db/test_db.py
@@ -5,6 +5,7 @@ from unittest import mock
from gn3.db import fetchall
from gn3.db import fetchone
from gn3.db import update
+from gn3.db import update_raw
from gn3.db import diff_from_dict
from gn3.db.phenotypes import Phenotype
from gn3.db.phenotypes import Probeset
@@ -118,3 +119,21 @@ class TestCrudMethods(TestCase):
{"id": 2, "data": "b"}),
{"id": {"old": 1, "new": 2},
"data": {"old": "a", "new": "b"}})
+
+ def test_update_raw(self):
+ """Test a raw update query"""
+ db_mock = mock.MagicMock()
+ with db_mock.cursor() as cursor:
+ type(cursor).rowcount = 1
+ self.assertEqual(update_raw(
+ conn=db_mock,
+ table="PublishData",
+ set_=[("value", 1)],
+ where=("StrainId = '%s' AND DataId = '%s'",
+ (2, 8967049))),
+ 1)
+ cursor.execute.assert_called_once_with(
+ "UPDATE PublishData SET "
+ "value = '%s' WHERE "
+ "StrainId = '%s' AND DataId = '%s'",
+ (1, 2, 8967049))