aboutsummaryrefslogtreecommitdiff
path: root/tests/unit/db
diff options
context:
space:
mode:
authorBonfaceKilz2021-06-02 07:54:35 +0300
committerzsloan2021-06-18 22:08:04 +0000
commitece41f5f971595c5d005c4beaa984c45471a6647 (patch)
tree27bf21653cd0086c4102854683757e79f4faece2 /tests/unit/db
parent515ac34950db419bd6440afd1393cf41310d1814 (diff)
downloadgenenetwork3-ece41f5f971595c5d005c4beaa984c45471a6647.tar.gz
Get the diff between 2 dicts and return that as a dict
Diffstat (limited to 'tests/unit/db')
-rw-r--r--tests/unit/db/test_phenotypes.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/tests/unit/db/test_phenotypes.py b/tests/unit/db/test_phenotypes.py
index 505714a..b53db23 100644
--- a/tests/unit/db/test_phenotypes.py
+++ b/tests/unit/db/test_phenotypes.py
@@ -4,6 +4,7 @@ from unittest import mock
from gn3.db import fetchone
from gn3.db import update
+from gn3.db import diff_from_dict
from gn3.db.phenotypes import Phenotype
@@ -63,3 +64,10 @@ class TestPhenotypes(TestCase):
"Test pre-publication")
cursor.execute.assert_called_once_with(
"SELECT * FROM Phenotype WHERE id = '35'")
+
+ def test_diff_from_dict(self):
+ """Test that a correct diff is generated"""
+ self.assertEqual(diff_from_dict({"id": 1, "data": "a"},
+ {"id": 2, "data": "b"}),
+ {"id": {"old": 1, "new": 2},
+ "data": {"old": "a", "new": "b"}})