From ca5738e471672a1ae681ee5f439f1104c27a7cc6 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Fri, 9 Jul 2021 17:59:41 +0300 Subject: db: test_db: Test that a fetch is correct when columns are specified --- tests/unit/db/test_db.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'tests/unit/db') 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"}, -- cgit v1.2.3