From bceb5ce98c14dc64ef3980caf23f975278f63d50 Mon Sep 17 00:00:00 2001 From: Munyoki Kilyungi Date: Tue, 10 Sep 2024 10:32:51 +0300 Subject: Add test cases for wiki.__sanitize_result. * tests/unit/db/rdf/test_wiki.py (test_sanitize_result): New file. Signed-off-by: Munyoki Kilyungi --- tests/unit/db/rdf/__init__.py | 0 tests/unit/db/rdf/test_wiki.py | 157 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 157 insertions(+) create mode 100644 tests/unit/db/rdf/__init__.py create mode 100644 tests/unit/db/rdf/test_wiki.py (limited to 'tests/unit/db/rdf') diff --git a/tests/unit/db/rdf/__init__.py b/tests/unit/db/rdf/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/unit/db/rdf/test_wiki.py b/tests/unit/db/rdf/test_wiki.py new file mode 100644 index 0000000..e8f0e62 --- /dev/null +++ b/tests/unit/db/rdf/test_wiki.py @@ -0,0 +1,157 @@ +"""Tests for gn3/db/rdf/wiki.py""" + +import pytest + +from gn3.db.rdf.wiki import __sanitize_result + + +@pytest.mark.unit_test +@pytest.mark.parametrize( + ("result", "expected"), + ( + ( + { + "categories": "", + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": "", + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + { + "categories": [], + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": [], + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + ), + ( + { + "categories": "some-category", + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": "", + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + { + "categories": ["some-category"], + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": [], + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + ), + ( + { + "categories": "", + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": "21", + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + { + "categories": [], + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": [21], + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + ), + ( + { + "categories": "", + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": 21, + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + { + "categories": [], + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": [21], + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + ), + ( + { + "categories": "", + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": [21, 22], + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + { + "categories": [], + "comment": "comment", + "created": "2006-12-23 17:19:14", + "email": "XXX@XXX.edu", + "initial": "KMz", + "pubmed_ids": [21, 22], + "reason": "add", + "species": "mouse", + "symbol": "Sfrs3", + "version": 0, + "web_url": "", + }, + ), + ({}, {}), + ), +) +def test_sanitize_result(result, expected): + """Test that the JSON-LD result is sanitized correctly""" + assert __sanitize_result(result) == expected -- cgit v1.2.3