aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBonfaceKilz2021-06-03 11:08:58 +0300
committerBonfaceKilz2021-06-03 21:58:31 +0300
commit5d361fe5102a11afbd56aaab30e4a75a332c3e99 (patch)
tree81d61039106d9c283984c5b7507b618c074f3af1 /tests
parent8d29add407d5662995dbc9e94901636b15d32475 (diff)
downloadgenenetwork3-5d361fe5102a11afbd56aaab30e4a75a332c3e99.tar.gz
Add data structures for the table metadata_audit
Diffstat (limited to 'tests')
-rw-r--r--tests/unit/db/test_audit.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/unit/db/test_audit.py b/tests/unit/db/test_audit.py
new file mode 100644
index 0000000..22787bb
--- /dev/null
+++ b/tests/unit/db/test_audit.py
@@ -0,0 +1,28 @@
+"""Tests for db/phenotypes.py"""
+import json
+from unittest import TestCase
+from unittest import mock
+
+from gn3.db import insert
+from gn3.db.metadata_audit import MetadataAudit
+
+
+class TestMetadatAudit(TestCase):
+ """Test cases for fetching chromosomes"""
+
+ def test_insert_into_metadata_audit(self):
+ """Test that data is inserted correctly in the audit table
+
+ """
+ db_mock = mock.MagicMock()
+ with db_mock.cursor() as cursor:
+ type(cursor).rowcount = 1
+ self.assertEqual(insert(
+ conn=db_mock, table="metadata_audit",
+ data=MetadataAudit(dataset_id=35,
+ editor="Bonface",
+ json_data=json.dumps({"a": "b"}))), 1)
+ cursor.execute.assert_called_once_with(
+ "INSERT INTO metadata_audit ('dataset_id', "
+ "'editor', 'json_data') "
+ 'VALUES (\'35\', \'Bonface\', \'{\\"a\\": \\"b\\"}\')')