aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2021-07-29 16:30:31 +0300
committerBonfaceKilz2021-07-29 21:40:20 +0300
commit651515eb88cb5675434ff068ad19edd0c4c0e858 (patch)
tree6738ea34aaeee2b9f05da069e5309308866f7e27
parentac14e1167d866b8ab3a43583db8860ce99a3310b (diff)
downloadgenenetwork3-651515eb88cb5675434ff068ad19edd0c4c0e858.tar.gz
Delete "update_raw" and it's test-cases
-rw-r--r--gn3/db/__init__.py14
-rw-r--r--tests/unit/db/test_db.py19
2 files changed, 0 insertions, 33 deletions
diff --git a/gn3/db/__init__.py b/gn3/db/__init__.py
index 24ae8f1..149a344 100644
--- a/gn3/db/__init__.py
+++ b/gn3/db/__init__.py
@@ -64,20 +64,6 @@ def update(conn: Any,
return cursor.rowcount
-def update_raw(conn: Any, table: str,
- set_: List[Tuple[str, Any]],
- where: Tuple[str, Tuple]):
- """Run a generic raw statement"""
- sql = f"UPDATE {table} SET "
- sql += ", ".join([f"{k} = '%s'" for k, v in set_])
- sql += f" WHERE {where[0]}"
- with conn.cursor() as cursor:
- cursor.execute(sql,
- tuple(v for _, v in set_) + where[1])
- conn.commit()
- return cursor.rowcount
-
-
def fetchone(conn: Any,
table: str,
where: Optional[Dataclass],
diff --git a/tests/unit/db/test_db.py b/tests/unit/db/test_db.py
index 1bcde35..e47c9fd 100644
--- a/tests/unit/db/test_db.py
+++ b/tests/unit/db/test_db.py
@@ -5,7 +5,6 @@ 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
@@ -119,21 +118,3 @@ 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))