about summary refs log tree commit diff
path: root/tests/unit/db/test_case_attributes.py
diff options
context:
space:
mode:
authorMunyoki Kilyungi2025-07-01 15:31:10 +0300
committerBonfaceKilz2025-07-07 07:58:31 +0300
commit29fa7568856aff8b491396290416379677ff5baa (patch)
tree21fd8d887ae1c5548514f5f5078273874e2e3183 /tests/unit/db/test_case_attributes.py
parent524046c1c3c67d0d580381a7e20ce93ac76afb28 (diff)
downloadgenenetwork3-29fa7568856aff8b491396290416379677ff5baa.tar.gz
Delete "update_case_attribute"
To update an attribute, you can use the "apply_change" function
instead.

Signed-off-by: Munyoki Kilyungi <me@bonfacemunyoki.com>
Diffstat (limited to 'tests/unit/db/test_case_attributes.py')
-rw-r--r--tests/unit/db/test_case_attributes.py94
1 files changed, 1 insertions, 93 deletions
diff --git a/tests/unit/db/test_case_attributes.py b/tests/unit/db/test_case_attributes.py
index 494461a..5d023f6 100644
--- a/tests/unit/db/test_case_attributes.py
+++ b/tests/unit/db/test_case_attributes.py
@@ -12,8 +12,7 @@ from gn3.db.case_attributes import (
     CaseAttributeEdit,
     EditStatus,
     apply_change,
-    view_change,
-    update_case_attribute
+    view_change
 )
 
 
@@ -40,97 +39,6 @@ def test_queue_edit(mocker: MockFixture) -> None:
 
 
 @pytest.mark.unit_test
-def test_update_case_attribute_success(mocker: MockFixture) -> None:
-    """Test successful case attribute update with valid modifications."""
-    mock_cursor, mock_conn = mocker.MagicMock(), mocker.MagicMock()
-    mock_conn.cursor.return_value = mock_cursor
-    mock_lmdb = mocker.patch("gn3.db.case_attributes.lmdb")
-    mock_env, mock_txn = mocker.MagicMock(), mocker.MagicMock()
-    mock_lmdb.open.return_value = mock_env
-    mock_env.begin.return_value.__enter__.return_value = mock_txn
-    mock_txn.get.side_effect = [
-        pickle.dumps({100}),  # b"review" key
-        None,                 # b"approved" key
-    ]
-
-    TMPDIR = Path(os.environ.get("TMPDIR", tempfile.gettempdir()))
-    edit = CaseAttributeEdit(
-        inbredset_id=1,
-        user_id="test_user",
-        status=EditStatus.approved,
-        changes={
-            "Modifications": {
-                "Current": {
-                    "Strain1": {"Attribute1": "Value1"}
-                }
-            }
-        }
-    )
-    change_id = 100
-
-    # Mock cursor fetch results
-    mock_cursor.fetchone.side_effect = [
-        (10, "Strain1"),          # Strain query
-        (20, "Attribute1"),       # CaseAttribute query
-    ]
-
-    assert update_case_attribute(mock_cursor, TMPDIR, change_id, edit)
-
-    # Assertions for lmdb interactions
-    mock_lmdb.open.assert_called_once_with(
-        f"{TMPDIR}/case-attributes/1", map_size=8_000_000)
-    mock_env.begin.assert_called_once_with(write=True)
-    mock_txn.get.assert_has_calls([
-        mocker.call(b"review"),
-        mocker.call(b"approved")
-    ])
-    mock_txn.put.assert_has_calls([
-        mocker.call(b"review", pickle.dumps(set())),
-        mocker.call(b"approved", pickle.dumps({100}))
-    ])
-
-    # Assertions for SQL executions
-    mock_cursor.execute.assert_has_calls([
-        mocker.call(
-            "SELECT Id AS StrainId, Name AS StrainName FROM Strain WHERE Name = %s",
-            ("Strain1",)
-        ),
-        mocker.call(
-            "SELECT CaseAttributeId, Name AS CaseAttributeName FROM CaseAttribute "
-            "WHERE InbredSetId = %s AND Name = %s",
-            (1, "Attribute1")
-        ),
-        mocker.call(
-            "INSERT INTO CaseAttributeXRefNew(InbredSetId, StrainId, CaseAttributeId, Value) "
-            "VALUES (%s, %s, %s, %s) ON DUPLICATE KEY UPDATE Value=VALUES(value)",
-            (1, 10, 20, "Value1")
-        ),
-        mocker.call(
-            "UPDATE caseattributes_audit SET status = %s WHERE id = %s",
-            ("approved", 100)
-        )
-    ])
-
-
-@pytest.mark.unit_test
-def test_update_case_attribute_no_modifications(mocker: MockFixture) -> None:
-    """Test update_case_attribute with no modifications in edit.changes."""
-    mock_cursor, mock_conn = mocker.MagicMock(), mocker.MagicMock()
-    mock_conn.cursor.return_value = mock_cursor
-    mock_lmdb = mocker.patch("gn3.db.case_attributes.lmdb")
-    mock_env, mock_txn = mocker.MagicMock(), mocker.MagicMock()
-    TMPDIR = Path(os.environ.get("TMPDIR", tempfile.gettempdir()))
-    edit = CaseAttributeEdit(
-        inbredset_id=1,
-        user_id="test_user",
-        status=EditStatus.approved,
-        changes={}  # No modifications
-    )
-    change_id = 28
-    assert not update_case_attribute(mock_cursor, TMPDIR, change_id, edit)
-
-
-@pytest.mark.unit_test
 def test_view_change(mocker: MockFixture) -> None:
     """Test view_change function."""
     sample_json_diff = {