-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.py
executable file
·687 lines (522 loc) · 26.4 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
#!/usr/bin/env python
# encoding: utf-8
from richcontext import scholapi as rc_scholapi
import pprint
import unittest
import warnings
def ignore_warnings (test_func):
"""see https://stackoverflow.com/questions/26563711/disabling-python-3-2-resourcewarning
"""
def do_test (self, *args, **kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore", ResourceWarning)
test_func(self, *args, **kwargs)
return do_test
class TestOpenAPIs (unittest.TestCase):
######################################################################
## PubMed family of APIs
def test_europepmc_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.europepmc
title = "Zebrafish models: Gaining insight into purinergic signaling and neurological disorders"
expected = "OrderedDict([('doi', '10.1016/j.pnpbp.2019.109770'), ('journal', 'Prog Neuropsychopharmacol Biol Psychiatry'), ('authors', ['Nabinger DD', 'Altenhofen S', 'Bonan CD.'])])"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(repr(response.meta) == expected)
self.assertTrue(response.doi() == '10.1016/j.pnpbp.2019.109770')
self.assertTrue(response.journal() == 'Prog Neuropsychopharmacol Biol Psychiatry')
self.assertTrue(response.authors() == ['Nabinger DD', 'Altenhofen S', 'Bonan CD.'])
def test_pubmed_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.pubmed
title = "Climate-change-driven accelerated sea-level rise detected in the altimeter era."
expected = "29440401"
doi = "10.1073/pnas.1717312115"
journal = "Proceedings of the National Academy of Sciences of the United States of America"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.pmid() == expected)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title() == title)
self.assertTrue(response.journal() == journal)
self.assertTrue(response.issn() is None)
title = "NOT_TO_BE_FOUND"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.meta is None)
self.assertTrue(response.pmid() is None)
self.assertTrue(response.doi() is None)
self.assertTrue(response.title() is None)
self.assertTrue(response.journal() is None)
self.assertTrue(response.issn() is None)
def test_pubmed_journal_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.pubmed
issn = "1932-6203"
expected = "PLoS ONE".lower()
if source.has_credentials():
response = source.journal_lookup(issn)
source.report_perf(response.timing)
self.assertTrue(response.pmid() == None)
self.assertTrue(response.doi() == None)
self.assertTrue(response.title() == None)
self.assertTrue(response.journal().lower() == expected)
self.assertTrue(response.issn() == issn)
def test_pubmed_full_text_search (self):
#TODO
pass
######################################################################
## Scholix family of APIs
@ignore_warnings
def test_crossref_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.crossref
doi = "10.1503/cmaj.170880"
expected = "Relation between household food insecurity and breastfeeding in Canada"
num_authors = 4
url = "http://dx.doi.org/10.1503/cmaj.170880"
journal = "Canadian Medical Association Journal"
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.title() == expected)
self.assertTrue(response.doi() == doi)
self.assertTrue(len(response.authors()) == num_authors)
self.assertTrue(response.url() == url)
self.assertTrue(response.journal() == journal)
doi_error = "10.XXXX.XXXX"
if source.has_credentials():
response = source.publication_lookup(doi_error)
source.report_perf(response.timing)
self.assertTrue(response.message is not None)
self.assertTrue(response.meta is None)
def test_crossref_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.crossref
title = "Relation between household food insecurity and breastfeeding in Canada"
expected = "10.1503/cmaj.170880"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.doi() == expected)
title = "D"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.meta is None)
def test_crossref_fulltext_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.crossref
search_term = "NHANES"
expected = 100
if source.has_credentials():
responses = source.full_text_search(search_term, limit=expected)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) >= expected)
def test_datacite_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.datacite
doi = "10.22002/d1.246"
title = "In Situ Carbon Dioxide and Methane Mole Fractions from the Los Angeles Megacity Carbon Project"
url = "https://data.caltech.edu/records/246"
journal = "CaltechDATA"
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title() == title)
self.assertTrue(response.authors() == ["Verhulst, Kristal"])
self.assertTrue(response.url() == url)
self.assertTrue(response.journal() == journal)
# error case
doi = "10.00000/xxx"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.serialize() == None)
self.assertTrue("404" in response.message)
self.assertTrue(response.doi() is None)
self.assertTrue(response.title() is None)
self.assertTrue(response.authors() is None)
self.assertTrue(response.url() is None)
self.assertTrue(response.journal() is None)
def test_datacite_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.datacite
title = "Empirical analysis of potential improvements for high voltage protective algorithms"
expected = "10.5281/zenodo.3635395"
journal = "Zenodo"
author = "López, David"
url = "https://zenodo.org/record/3635395"
if source.has_credentials():
response = source.title_search(title)
self.assertTrue(response.meta and response.meta["id"] == expected)
self.assertTrue(response.doi() == expected)
self.assertTrue(response.title() == title)
self.assertTrue(author in response.authors())
self.assertTrue(response.url() == url)
self.assertTrue(response.journal() == journal)
# error case
title = "ajso58tt849qp3g84h38pghq3974ut8gq9j9ht789" # Should be no matches
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.meta == None)
def test_datacite_fulltext_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.datacite
search_term = "NOAA NASA"
expected = 5
if source.has_credentials():
responses = source.full_text_search(search_term, limit=expected, exact_match=True)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == expected)
def test_datacite__format_exact_quote (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.datacite
search_term = "NOAA NASA"
expected = '"NOAA+NASA"'
exact_quote = source._format_exact_quote(search_term)
self.assertTrue(exact_quote == expected)
def test_openaire_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.openaire
doi = "10.1016/j.appet.2017.07.006"
title = "Deal or no deal? The prevalence and nutritional quality of price promotions among U.S. food and beverage purchases"
url = "https://europepmc.org/articles/PMC5574185/"
authors = ["Taillie, Lindsey Smith", "Ng, Shu Wen", "Xue, Ya", "Harding, Matthew"]
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title() == title)
self.assertTrue(response.url() == url)
self.assertTrue(response.authors() == authors)
self.assertTrue(response.meta["open"])
title = "Quantitative easing, portfolio rebalancing and credit growth: Micro evidence from Germany"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue("doi" not in response.meta)
self.assertTrue(response.title() == title)
def test_openaire_fulltext_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.openaire
search_term = "NHANES"
expected = 100
if source.has_credentials():
responses = source.full_text_search(search_term, limit=expected)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) >= expected)
######################################################################
## Digital Science family of APIs
def test_dimensions_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.dimensions
title = "Deal or no deal? The prevalence and nutritional quality of price promotions among U.S. food and beverage purchases"
expected = "10.1016/j.appet.2017.07.006"
url = "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5574185"
journal = "Appetite"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.doi() == expected)
self.assertTrue(response.title() == title)
self.assertTrue(response.url() == url)
self.assertTrue(response.journal() == journal)
def test_dimensions_full_text_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.dimensions
search_term = "the French paradox"
expected = "Food Chemistry"
if source.has_credentials():
responses = source.full_text_search(search_term, limit=20, exact_match=True)
source.report_perf(responses[0].timing)
for response in responses:
if response.doi() == "10.1016/j.foodchem.2019.126123":
self.assertTrue(response.journal() == expected)
return
self.assertTrue("DOI not found" == "")
######################################################################
## Unpaywall family of APIs
def test_unpaywall_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.unpaywall
doi = "10.1016/j.appet.2017.07.006"
title = "Deal or no deal? The prevalence and nutritional quality of price promotions among U.S. food and beverage purchases"
url = "https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5574185"
authors_num = 4
journal = "Appetite"
expected = "https://doi.org/10.1016/j.appet.2017.07.006"
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.meta["doi_url"] == expected)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title() == title)
self.assertTrue(response.url() == url)
self.assertTrue(response.journal() == journal)
self.assertTrue(len(response.authors()) == authors_num)
# error case
doi = "10.00000/xxx"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.meta == None)
def test_dissemin_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.dissemin
doi = "10.1016/j.appet.2017.07.006"
title = "Deal or no deal? The prevalence and nutritional quality of price promotions among U.S. food and beverage purchases"
journal = "Appetite"
authors_num = 4
expected = "2017-10-01"
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.meta["paper"]["date"] == expected)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title() == title)
self.assertTrue(response.journal() == journal)
self.assertTrue(len(response.authors()) == authors_num)
self.assertTrue(response.url() is None)
# error case
doi = "10.00000/xxx"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.meta == None)
self.assertTrue(response.message == None)
# another error case
doi = "10.1023/A:1018882711314"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.meta == None)
self.assertTrue(response.message == None)
def test_semantic_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.semantic
doi = "10.1016/j.appet.2017.07.006"
expected = "https://www.semanticscholar.org/paper/690195fe2ab0fa093204a050ceb2f9fd1d1b2907"
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.url() == expected)
self.assertTrue(response.doi() == doi)
# error case
doi = "10.00000/xxx"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.meta == None)
# another error case
doi = "10.1641/0006-3568(2005)055[0879:EITLSA]2.0.CO;2"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.meta == None)
######################################################################
## Misc. family of APIs
def test_repec_handle_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.repec
title = "Estimating the 'True' Cost of Job Loss: Evidence Using Matched Data from California 1991-2000"
expected = "RePEc:cen:wpaper:09-14"
if source.has_credentials():
meta, timing, message = source.get_handle(title)
source.report_perf(timing)
self.assertTrue(meta == expected)
def test_core_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.core
doi = "10.1371/journal.pone.0013969"
title = "Caribbean corals in crisis: record thermal stress, bleaching, and mortality in 2005".lower()
# NB: there may be multiple "correct" responses for the
# following -- this test case has some instability
urls = ["https://core.ac.uk/download/pdf/143863779.pdf", "https://core.ac.uk/download/pdf/51094169.pdf"]
journals = ["Public Library of Science", "NSUWorks"]
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title().lower() == title)
self.assertTrue(response.url() in urls)
self.assertTrue(response.journal() in journals)
# error case
doi = "10.00000/xxx"
if source.has_credentials():
response = source.publication_lookup(doi)
self.assertTrue(response.meta == None)
self.assertTrue(response.doi() == None)
self.assertTrue(response.title() == None)
self.assertTrue(response.url() == None)
self.assertTrue(response.authors() == None)
self.assertTrue(response.journal() == None)
self.assertTrue("Not found" == response.message)
def test_core_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.core
doi = "10.1371/journal.pone.0013969"
title = "Caribbean corals in crisis: record thermal stress, bleaching, and mortality in 2005".lower()
url = "https://core.ac.uk/download/pdf/51094169.pdf"
author = "Eakin, C. Mark"
journal = "NSUWorks"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title().lower() == title)
self.assertTrue(response.url() == url)
self.assertTrue(author in response.authors())
self.assertTrue(response.journal() == journal)
# error case
title = "ajso58tt849qp3g84h38pghq3974ut8gq9j9ht789" # Should be no matches
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.meta == None)
self.assertTrue(response.message == "Not found")
def test_core_fulltext_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.core
search_term = "NASA NOAA coral"
if source.has_credentials():
# CORE limit value range: 10-100
responses = source.full_text_search(search_term, limit=13)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 13)
responses = source.full_text_search(search_term, limit=2)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 10)
responses = source.full_text_search(search_term, limit=101)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 10)
def test_core_journal_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.core
issn = "1932-6203"
expected = "PLoS ONE"
if source.has_credentials():
response = source.journal_lookup(issn)
source.report_perf(response.timing)
self.assertTrue(response.title() == expected)
# error case
issn = "0000-0000"
if source.has_credentials():
response = source.journal_lookup(issn)
source.report_perf(response.timing)
self.assertTrue(response.meta == None)
self.assertTrue(response.message == 'Not found')
@ignore_warnings
def test_nsf_par_fulltext_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.nsfPar
## please note, these numbers may change as new publications are added
search_term = "NASA NOAA coral"
responses = source.full_text_search(search_term, limit=13, exact_match=True)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 13)
responses = source.full_text_search(search_term, limit=-1, exact_match=True)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 15)
responses = source.full_text_search(search_term, limit=1000, exact_match=True)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 15)
#Won't find any
search_term = "dlkadngeonr3q0984gqn839g"
responses = source.full_text_search(search_term, limit=13)
source.report_perf(responses[0].timing)
self.assertTrue(len(responses) == 1)
self.assertTrue(responses[0].meta is None)
@ignore_warnings
def test_nsf_par_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.nsfPar
##Please note, these numbers may change as new publications are added
title = "Essential ocean variables for global sustained observations of biodiversity and ecosystem changes"
doi = "10.1111/gcb.14108"
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.doi() == doi)
#Won't find any
title = "dlkadngeonr3q0984gqn839g"
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(response.meta is None)
@ignore_warnings
def test_nsf_par_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.nsfPar
##Please note, these numbers may change as new publications are added
title = "Essential ocean variables for global sustained observations of biodiversity and ecosystem changes"
doi = "10.1111/gcb.14108"
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(response.doi() == doi)
self.assertTrue(response.title() == title)
#Error case
doi = "10.00000/xxx"
response = source.publication_lookup(title)
source.report_perf(response.timing)
self.assertTrue(response.meta is None)
def test_orcid_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.orcid
orcid = "0000-0002-8139-2960" #Julia Lane
response = source.publication_lookup(orcid)
source.report_perf(response[0].timing)
#This number may change in the future
self.assertTrue(len(response) == 137)
orcid = "0000-0002-0735-6312"
response = source.publication_lookup(orcid)
source.report_perf(response[0].timing)
#This number may change in the future
self.assertTrue(response[0].meta is None)
def test_orcid_affiliations (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.orcid
orcid = "0000-0002-8139-2960" #Julia Lane
response = source.affiliations(orcid)
source.report_perf(response.timing)
#This number may change in the future
self.assertTrue(len(response.meta) == 3)
orcid = "0000-0002-0735-6312"
response = source.affiliations(orcid)
source.report_perf(response.timing)
#This number may change in the future
self.assertTrue(response.meta is None)
def test_orcid_funding (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.orcid
orcid = "0000-0002-8139-2960" #Julia Lane
response = source.funding(orcid)
source.report_perf(response.timing)
#This number may change in the future
self.assertTrue(len(response.meta) == 17)
orcid = "0000-0002-0735-6312"
response = source.funding(orcid)
source.report_perf(response.timing)
#This number may change in the future
self.assertTrue(response.meta is None)
def test_ssrn_publication_lookup (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.ssrn
doi = "10.2139/ssrn.2898991"
authors = ['Freedman, Matthew', 'Kuhns, Annemarie']
expected = "OrderedDict([('doi', '10.2139/ssrn.2898991'), ('title', 'Supply-Side Subsidies to Improve Food Access and Dietary Outcomes: Evidence from the New Markets Tax Credit'), ('keywords', ['place-based policies', 'retail food', 'tax incentives', 'community health', 'regression discontinuity']), ('authors', ['Freedman, Matthew', 'Kuhns, Annemarie'])])"
if source.has_credentials():
response = source.publication_lookup(doi)
source.report_perf(response.timing)
self.assertTrue(repr(response.meta) == expected)
self.assertTrue(response.doi() == doi)
self.assertTrue(all(author in authors for author in response.authors()))
def test_ssrn_title_search (self):
schol = rc_scholapi.ScholInfraAPI(config_file="rc.cfg")
source = schol.ssrn
title = "Supply-Side Subsidies to Improve Food Access and Dietary Outcomes: Evidence from the New Markets Tax Credit"
expected = "OrderedDict([('doi', '10.2139/ssrn.2898991'), ('title', 'Supply-Side Subsidies to Improve Food Access and Dietary Outcomes: Evidence from the New Markets Tax Credit'), ('keywords', ['place-based policies', 'retail food', 'tax incentives', 'community health', 'regression discontinuity']), ('authors', ['Freedman, Matthew', 'Kuhns, Annemarie'])])"
if source.has_credentials():
response = source.title_search(title)
source.report_perf(response.timing)
self.assertTrue(repr(response.meta) == expected)
self.assertTrue(response.title() == title)
if __name__ == "__main__":
unittest.main()