Coverage for test/discard_existing_res_test.py: 100%
21 statements
« prev ^ index » next coverage.py v6.5.0, created at 2025-12-20 08:55 +0000
« prev ^ index » next coverage.py v6.5.0, created at 2025-12-20 08:55 +0000
1import os
2import unittest
3from shutil import rmtree
5from fakeredis import FakeServer, FakeRedis
7from oc_meta.lib.file_manager import get_csv_data
8from oc_meta.run.discard_existing_res import discard_existing_res
11class TestDiscardExistingRes(unittest.TestCase):
12 @classmethod
13 def setUpClass(cls):
14 cls.server = FakeServer()
15 cls.r = FakeRedis(server=cls.server, decode_responses=True)
17 def test_discard_existing_res(self):
18 preexisting_ids = {
19 'pmid:23130068': 'omid:0601',
20 'doi:10.1016/j.freeradbiomed.2008.02.008': 'omid:0602',
21 'pmid:18342017': 'omid:0602',
22 'pmid:10429655': 'omid:0604'
23 }
24 self.r.mset(preexisting_ids)
25 discard_existing_res(os.path.join('test', 'discard_existing_res', 'input'), os.path.join('test', 'discard_existing_res', 'output'), r=self.r)
26 output = get_csv_data(os.path.join('test', 'discard_existing_res', 'output', '1.csv'))
27 expected_output = [
28 {'id': 'arxiv:1406.6047v1', 'title': 'Efficient Algorithms for de novo Assembly of Alternative Splicing Events from RNA-seq Data', 'author': 'Sacomoto Gustavo', 'pub_date': '2014-01-01', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': 'arXiv', 'editor': ''},
29 {'id': 'pmid:30635270', 'title': 'SOD1 activity threshold and TOR signalling modulate VAP(P58S) aggregation via reactive oxygen species-induced proteasomal degradation in a', 'author': 'Kriti Chaplot; Lokesh Pimpale; Balaji Ramalingam; Senthilkumar Deivasigamani; Siddhesh S Kamat; Girish S Ratnaparkhi', 'pub_date': '2018-07-11', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': '', 'editor': ''},
30 {'id': 'pmid:10429655 doi:10.1111/j.1349-7006.1999.tb00794.x', 'title': 'Frameshift mutation of the STK11 gene in a sporadic gastrointestinal cancer with microsatellite instability.', 'author': 'Yusuke Nakamura; Yusuke Nakamura; Hidewaki Nakagawa; Kumiko Koyama; Morito Monden; Masao Kameyama; Shingi Imaoka; Shoji Nakamori', 'pub_date': '1999-06-01', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': 'Wiley [crossref:311]', 'editor': ''},
31 {'id': 'pmid:28212283 doi:10.3390/nu9020143', 'title': 'The Effects of Tocotrienol and Lovastatin Co-Supplementation on Bone Dynamic Histomorphometry and Bone Morphogenetic Protein-2 Expression in Rats with Estrogen Deficiency', 'author': 'Soelaiman Ima-Nirwana; Norazlina Mohamed; Kok-Yong Chin [orcid:0000-0001-6628-1552]; Saif Abdul-Majeed', 'pub_date': '2017-02-15', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': 'MDPI AG [crossref:1968]', 'editor': ''},
32 {'id': 'pmid:22557953 doi:10.3389/fnhum.2012.00092', 'title': 'Influence of Cue Exposure on Inhibitory Control and Brain Activation in Patients with Alcohol Dependence', 'author': 'Ramona Kessel; Barbara Drüke; Maren Boecker; Verena Mainz; Thomas Forkmann; Siegfried Gauggel [orcid:0000-0002-2742-4917]', 'pub_date': '2012-05-01', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': 'Frontiers Research Foundation', 'editor': ''},
33 {'id': 'doi:10.4103/0974-777x.83533 pmid:21887059', 'title': 'Comparing absolute lymphocyte count to total lymphocyte count, as a CD4 T cell surrogate, to initiate antiretroviral therapy', 'author': 'Srirangaraj Sreenivasan; Venkatesha Dasegowda', 'pub_date': '2011-01-01', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': 'Medknow [crossref:2581]', 'editor': ''},
34 {'id': 'pmid:15479473', 'title': 'Current practices in the spatial analysis of cancer: flies in the ointment.', 'author': 'Jacquez Geoffrey M', 'pub_date': '2004-09-28', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': '', 'editor': ''},
35 {'id': 'pmid:27336866', 'title': 'Surgical innovation : The ethical agenda', 'author': 'Broekman Marike L.; Carrière Michelle E.; Bredenoord Annelien L.', 'pub_date': '2016-06-01', 'venue': '', 'volume': '', 'issue': '', 'page': '', 'type': 'journal article', 'publisher': '', 'editor': ''}]
36 self.assertEqual(len(output), 8)
37 self.assertEqual(output, expected_output)
38 rmtree(os.path.join('test', 'discard_existing_res', 'output'))
39 self.r.flushdb()
42if __name__ == '__main__': # pragma: no cover
43 unittest.main()