about summary refs log tree commit diff
path: root/tests/unit/db/rdf
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/db/rdf')
-rw-r--r--tests/unit/db/rdf/data.py199
-rw-r--r--tests/unit/db/rdf/test_wiki.py50
2 files changed, 249 insertions, 0 deletions
diff --git a/tests/unit/db/rdf/data.py b/tests/unit/db/rdf/data.py
new file mode 100644
index 0000000..6bc612f
--- /dev/null
+++ b/tests/unit/db/rdf/data.py
@@ -0,0 +1,199 @@
+"""Some test data to be used in RDF data."""
+
+LPL_RIF_ENTRIES = {
+    "@context": {
+        "dct": "http://purl.org/dc/terms/",
+        "gnt": "http://genenetwork.org/term/",
+        "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
+        "skos": "http://www.w3.org/2004/02/skos/core#",
+        "symbol": "gnt:symbol",
+        "species": "gnt:species",
+        "taxonomic_id": "skos:notation",
+        "gene_id": "gnt:hasGeneId",
+        "pubmed_id": "dct:references",
+        "created": "dct:created",
+        "comment": "rdfs:comment",
+        "version": "dct:hasVersion",
+    },
+    "data": [
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-02-23 20:40:00",
+            "pubmed_id": 36763533,
+            "comment": "Angiopoietin-like protein 4/8 complex-mediated plasmin generation \
+leads to cleavage of the complex and restoration of LPL activity.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-04-07 20:39:00",
+            "pubmed_id": 36652113,
+            "comment": "The breast cancer microenvironment and lipoprotein lipase: \
+Another negative notch for a beneficial enzyme?",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-04-27 20:33:00",
+            "pubmed_id": 36519761,
+            "comment": "Parkin regulates neuronal lipid homeostasis through \
+SREBP2-lipoprotein lipase pathway-implications for Parkinson's disease.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-05-22 20:32:00",
+            "pubmed_id": 36708756,
+            "comment": "Plasma Lipoprotein Lipase Is Associated with Risk of \
+Future Major Adverse Cardiovascular Events in Patients Following Carotid Endarterectomy.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-07-04 21:12:00",
+            "pubmed_id": 37155355,
+            "comment": "Inverse association between apolipoprotein C-II and \
+cardiovascular mortality: role of lipoprotein lipase activity modulation.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-07-13 20:35:00",
+            "pubmed_id": 37432202,
+            "comment": "Effect of the Interaction between Seaweed Intake and LPL \
+Polymorphisms on Metabolic Syndrome in Middle-Aged Korean Adults.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-08-14 20:37:00",
+            "pubmed_id": 37568214,
+            "comment": "Frameshift coding sequence variants in the LPL gene: identification \
+of two novel events and exploration of the genotype-phenotype relationship for \
+variants reported to date.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-08-22 20:29:00",
+            "pubmed_id": 37550668,
+            "comment": "The East Asian-specific LPL p.Ala288Thr (c.862G > A) missense \
+variant exerts a mild effect on protein function.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-09-12 20:35:00",
+            "pubmed_id": 37128695,
+            "comment": "Interaction between APOE, APOA1, and LPL Gene Polymorphisms \
+and Variability in Changes in Lipid and Blood Pressure following Orange Juice Intake: \
+A Pilot Study.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-09-25 09:33:00",
+            "pubmed_id": 37427758,
+            "comment": "Variants within the LPL gene confer susceptility to \
+diabetic kidney disease and rapid decline in kidney function in Chinese patients \
+with type 2 diabetes.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-11-01 08:55:00",
+            "pubmed_id": 37901192,
+            "comment": "The Association of Adipokines and Myokines in the \
+Blood of Obese Children and Adolescents with Lipoprotein Lipase rs328 Gene Variants.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-11-10 08:44:00",
+            "pubmed_id": 37871217,
+            "comment": "The lipoprotein lipase that is shuttled into \
+capillaries by GPIHBP1 enters the glycocalyx where it mediates lipoprotein processing.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-12-28 20:33:00",
+            "pubmed_id": 37858495,
+            "comment": "Clinical profile, genetic spectrum and therapy \
+evaluation of 19 Chinese pediatric patients with lipoprotein lipase deficiency.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 4023,
+            "version": 5,
+            "species": "Homo sapiens",
+            "symbol": "LPL",
+            "created": "2023-12-29 20:33:00",
+            "pubmed_id": 38114521,
+            "comment": "Developing a model to predict the early risk of \
+hypertriglyceridemia based on inhibiting lipoprotein lipase (LPL): a translational study.",
+            "taxonomic_id": 9606,
+        },
+        {
+            "gene_id": 16956,
+            "version": 5,
+            "species": "Mus musculus",
+            "symbol": "Lpl",
+            "created": "2023-04-27 20:33:00",
+            "pubmed_id": 36519761,
+            "comment": "Parkin regulates neuronal lipid homeostasis through \
+SREBP2-lipoprotein lipase pathway-implications for Parkinson's disease.",
+            "taxonomic_id": 10090,
+        },
+        {
+            "gene_id": 24539,
+            "version": 5,
+            "species": "Rattus norvegicus",
+            "symbol": "Lpl",
+            "created": "2023-12-29 20:33:00",
+            "pubmed_id": 38114521,
+            "comment": "Developing a model to predict the early risk of \
+hypertriglyceridemia based on inhibiting lipoprotein lipase (LPL): a translational study.",
+            "taxonomic_id": 10116,
+        },
+    ],
+}
diff --git a/tests/unit/db/rdf/test_wiki.py b/tests/unit/db/rdf/test_wiki.py
index 3abf3ad..bab37ce 100644
--- a/tests/unit/db/rdf/test_wiki.py
+++ b/tests/unit/db/rdf/test_wiki.py
@@ -22,11 +22,15 @@ from tests.fixtures.rdf import (
     SPARQL_CONF,
 )
 
+from tests.unit.db.rdf.data import LPL_RIF_ENTRIES
+
 from gn3.db.rdf.wiki import (
     __sanitize_result,
     get_wiki_entries_by_symbol,
     get_comment_history,
     update_wiki_comment,
+    get_rif_entries_by_symbol,
+    delete_wiki_entries_by_id,
 )
 
 GRAPH = "<http://cd-test.genenetwork.org>"
@@ -396,3 +400,49 @@ def test_update_wiki_comment(rdf_setup):  # pylint: disable=W0613,W0621
         "version": 3,
         "web_url": "http://some-website.com",
     })
+
+
+@pytest.mark.rdf
+def test_get_rif_entries_by_symbol(rdf_setup):  # pylint: disable=W0613,W0621
+    """Test fetching NCBI Rif Metadata from RDF"""
+    sparql_conf = SPARQL_CONF
+    entries = get_rif_entries_by_symbol(
+        symbol="Lpl",
+        sparql_uri=sparql_conf["sparql_endpoint"],
+        graph=GRAPH,
+    )
+    assert len(LPL_RIF_ENTRIES["data"]) == len(entries["data"])
+    for result, expected in zip(LPL_RIF_ENTRIES["data"], entries["data"]):
+        TestCase().assertDictEqual(result, expected)
+
+
+@pytest.mark.rdf
+def test_delete_wiki_entries_by_id(rdf_setup):  # pylint: disable=W0613,W0621
+    """Test deleting a given RIF Wiki entry"""
+    sparql_conf = SPARQL_CONF
+    delete_wiki_entries_by_id(
+        230,
+        sparql_user=sparql_conf["sparql_user"],
+        sparql_password=sparql_conf["sparql_password"],
+        sparql_auth_uri=sparql_conf["sparql_auth_uri"],
+        graph=GRAPH)
+    entries = get_comment_history(
+        comment_id=230,
+        sparql_uri=sparql_conf["sparql_endpoint"],
+        graph=GRAPH,
+    )
+    assert len(entries["data"]) == 0
+
+    # Deleting a non-existent entry has no effect
+    delete_wiki_entries_by_id(
+        199999,
+        sparql_user=sparql_conf["sparql_user"],
+        sparql_password=sparql_conf["sparql_password"],
+        sparql_auth_uri=sparql_conf["sparql_auth_uri"],
+        graph=GRAPH)
+    entries = get_comment_history(
+        comment_id=230,
+        sparql_uri=sparql_conf["sparql_endpoint"],
+        graph=GRAPH,
+    )
+    assert len(entries["data"]) == 0