aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/db
diff options
context:
space:
mode:
authorBonfaceKilz2021-07-09 17:59:41 +0300
committerBonfaceKilz2021-07-10 09:09:00 +0300
commitca5738e471672a1ae681ee5f439f1104c27a7cc6 (patch)
treedcbfb0a8419335354cfcf1980abf2b13a18fe570 /tests/unit/db
parent0795a7b013dc1e274ffb0952d65351ebfe41c885 (diff)
downloadgenenetwork3-ca5738e471672a1ae681ee5f439f1104c27a7cc6.tar.gz
db: test_db: Test that a fetch is correct when columns are specified
Diffstat (limited to 'tests/unit/db')
-rw-r--r--tests/unit/db/test_db.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/unit/db/test_db.py b/tests/unit/db/test_db.py
index 520e781..056c226 100644
--- a/tests/unit/db/test_db.py
+++ b/tests/unit/db/test_db.py
@@ -7,6 +7,7 @@ from gn3.db import fetchone
from gn3.db import update
from gn3.db import diff_from_dict
from gn3.db.phenotypes import Phenotype
+from gn3.db.phenotypes import Probeset
from gn3.db.metadata_audit import MetadataAudit
@@ -95,6 +96,21 @@ class TestCrudMethods(TestCase):
"dataset_id = %s AND editor = %s"),
(35, 'Rob'))
+ def test_probeset_called_with_right_columns(self):
+ """Given a columns argument, test that the correct sql query is
+ constructed"""
+ db_mock = mock.MagicMock()
+ with db_mock.cursor() as cursor:
+ cursor.fetchall.return_value = None
+ fetchone(db_mock,
+ "ProbeSet",
+ where=Probeset(name="1446112_at"),
+ columns=["OMIM", "Probe_set_target_region"])
+ cursor.execute.assert_called_once_with(
+ "SELECT OMIM, Probe_set_target_region FROM ProbeSet WHERE "
+ "Name = %s",
+ ("1446112_at",))
+
def test_diff_from_dict(self):
"""Test that a correct diff is generated"""
self.assertEqual(diff_from_dict({"id": 1, "data": "a"},