aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBonfaceKilz2022-05-25 21:36:25 +0300
committerBonfaceKilz2022-05-27 15:02:25 +0300
commit7bcd718a2954c2f1ff67bea84d79c7cd9a1d43a0 (patch)
treee0d6cfa820ddf283856d5b1241f557062d9b44f7
parent9fa398d57e26c8ece01bce7a4f67545449e94821 (diff)
downloadgenenetwork3-7bcd718a2954c2f1ff67bea84d79c7cd9a1d43a0.tar.gz
Move sql for CRUD operations on case-attrs from gn2 to gn3
-rw-r--r--gn3/db/case_attributes.py6
-rw-r--r--tests/unit/db/test_sample_data.py27
2 files changed, 3 insertions, 30 deletions
diff --git a/gn3/db/case_attributes.py b/gn3/db/case_attributes.py
index 8eb2bf6..98fc58d 100644
--- a/gn3/db/case_attributes.py
+++ b/gn3/db/case_attributes.py
@@ -33,13 +33,13 @@ def insert_case_attribute_audit(
"INSERT INTO caseattributes_audit "
"(status, editor, json_diff_data) "
"VALUES (%s, %s, %s)",
- (status, author, data),
+ (status, author, data,),
)
rowcount = cursor.rowcount
- conn.commit()
except Exception as _e:
conn.rollback()
raise MySQLdb.Error(_e) from _e
+ conn.commit()
return rowcount
@@ -55,7 +55,7 @@ def reject_case_attribute(conn: Any, case_attr_audit_id: int) -> int:
(case_attr_audit_id,),
)
rowcount = cursor.rowcount
- conn.commit()
+ conn.commit()
except Exception as _e:
conn.rollback()
raise MySQLdb.Error(_e) from _e
diff --git a/tests/unit/db/test_sample_data.py b/tests/unit/db/test_sample_data.py
index 8af4d3b..4c64da4 100644
--- a/tests/unit/db/test_sample_data.py
+++ b/tests/unit/db/test_sample_data.py
@@ -4,10 +4,8 @@ import gn3
from gn3.db.sample_data import __extract_actions
from gn3.db.sample_data import delete_sample_data
-from gn3.db.sample_data import get_case_attributes
from gn3.db.sample_data import insert_sample_data
from gn3.db.sample_data import update_sample_data
-from gn3.db.sample_data import get_trait_csv_sample_data
@pytest.mark.unit_test
@@ -221,28 +219,3 @@ def test_update_sample_data(mocker):
],
any_order=False,
)
-
-
-@pytest.mark.unit_test
-def test_get_case_attributes(mocker):
- """Test that case attributes work well"""
- mock_conn = mocker.MagicMock()
- with mock_conn.cursor() as cursor:
- cursor.fetchall.return_value = (
- (1, "Condition", None),
- (2, "Tissue", None),
- (3, "Age", "Cum sociis natoque penatibus et magnis dis"),
- (4, "Condition", "Description A"),
- (5, "Condition", "Description B"),
- )
- results = get_case_attributes(mock_conn)
- cursor.execute.assert_called_once_with(
- "SELECT Id, Name, Description FROM CaseAttribute"
- )
- assert results == (
- (1, "Condition", None),
- (2, "Tissue", None),
- (3, "Age", "Cum sociis natoque penatibus et magnis dis"),
- (4, "Condition", "Description A"),
- (5, "Condition", "Description B"),
- )