diff options
| author | Munyoki Kilyungi | 2025-06-25 14:14:42 +0300 |
|---|---|---|
| committer | BonfaceKilz | 2025-07-07 07:58:31 +0300 |
| commit | 3111d02bdf8884c1478e31789dc448aa95c3179e (patch) | |
| tree | 8f0210c0d2ba0c70f4436877a45300ecf6b922e6 | |
| parent | 258bfea0682728843099d11fad0d8253fc33a172 (diff) | |
| download | genenetwork3-3111d02bdf8884c1478e31789dc448aa95c3179e.tar.gz | |
Add test case for queue_edit.
Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
| -rw-r--r-- | tests/unit/db/test_case_attributes.py | 23 |
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() |
