about summary refs log tree commit diff
path: root/tests/unit
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/db/test_case_attributes.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/unit/db/test_case_attributes.py b/tests/unit/db/test_case_attributes.py
index 97a0703..e7802d5 100644
--- a/tests/unit/db/test_case_attributes.py
+++ b/tests/unit/db/test_case_attributes.py
@@ -1,7 +1,11 @@
 """Test cases for gn3.db.case_attributes.py"""
 
 import pytest
+import tempfile
+import os
 from pytest_mock import MockFixture
+from gn3.db.case_attributes import queue_edit
+from gn3.db.case_attributes import CaseAttributeEdit
 from gn3.db.case_attributes import get_unreviewed_diffs
 from gn3.db.case_attributes import get_case_attributes
 from gn3.db.case_attributes import insert_case_attribute_audit
@@ -10,6 +14,25 @@ from gn3.db.case_attributes import reject_case_attribute
 
 
 @pytest.mark.unit_test
+def test_queue_edit(mocker: MockFixture) -> None:
+    mock_conn = mocker.MagicMock()
+    with mock_conn.cursor() as cursor:
+        type(cursor).lastrowid = 28
+        TMPDIR = os.environ.get("TMPDIR", tempfile.gettempdir())
+        review_ids = queue_edit(
+            cursor,
+            directory=TMPDIR,
+            edit=CaseAttributeEdit(inbredset_id=1, user_id="xxxx", changes={"a": 1, "b": 2}))
+        cursor.execute.assert_called_once_with(
+            "INSERT INTO "
+            "caseattributes_audit(status, editor, json_diff_data) "
+            "VALUES (%s, %s, %s) "
+            "ON DUPLICATE KEY UPDATE status=%s",
+            ('review', 'xxxx', '{"a": 1, "b": 2}', 'review'))
+        assert {28} == review_ids
+
+
+@pytest.mark.unit_test
 def test_get_case_attributes(mocker: MockFixture) -> None:
     """Test that all the case attributes are fetched correctly"""
     mock_conn = mocker.MagicMock()