From dbfeccada1550cfcfbedb9e92d3b13ccbf0e547f Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 5 Apr 2026 11:43:35 +0200 Subject: Added test for esearch --- VERSION | 2 +- guix.scm | 3 ++- tests/test_network_esearch.py | 24 ++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 tests/test_network_esearch.py diff --git a/VERSION b/VERSION index 2e0e38c..c064b1b 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.9 +1.9.1-pre diff --git a/guix.scm b/guix.scm index 905f1ac..b27bc8c 100644 --- a/guix.scm +++ b/guix.scm @@ -364,7 +364,8 @@ access to Gemini models.") (("\\./minipubmed") pubmed))))) (replace 'check (lambda _ - (invoke "python" "-m" "unittest" "discover" "-s" "tests" "-v"))) + ;; test_network_* files need internet, skip them + (invoke "python" "-m" "unittest" "tests.test_hello" "-v"))) (replace 'install (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) diff --git a/tests/test_network_esearch.py b/tests/test_network_esearch.py new file mode 100644 index 0000000..069f442 --- /dev/null +++ b/tests/test_network_esearch.py @@ -0,0 +1,24 @@ +"""Test PubMed esearch via edirect -- requires internet access. + +Run with: python -m unittest tests.test_network_esearch -v +""" + +import subprocess +import unittest + +class TestNetworkEsearch(unittest.TestCase): + def test_esearch_penk_stress(self): + """Search PubMed for Penk + stress, expect at least some PMIDs.""" + result = subprocess.run( + ["sh", "-c", + 'esearch -db pubmed -query "(stress) AND (Penk [tiab])" ' + '| efetch -format uid'], + capture_output=True, text=True, timeout=60) + self.assertEqual(result.returncode, 0, result.stderr) + pmids = result.stdout.strip().split("\n") + pmids = [p for p in pmids if p.strip()] + print(f" Found {len(pmids)} PMIDs for Penk+stress") + self.assertGreater(len(pmids), 0, "Expected at least 1 PMID") + +if __name__ == "__main__": + unittest.main() -- cgit 1.4.1