Skip to content

Commit 1beda89

Browse files
committed
Update unit test values
1 parent 3636e45 commit 1beda89

File tree

1 file changed

+30
-26
lines changed

1 file changed

+30
-26
lines changed

test_module.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def test_search_author_single_author(self):
151151
mandate = Mandate(agency="US National Science Foundation", effective_date="2016/1", embargo="12 months",
152152
url_policy="https://www.nsf.gov/pubs/2015/nsf15052/nsf15052.pdf",
153153
url_policy_cached="/mandates/nsf-2021-02-13.pdf",
154-
acknowledgement=" …NSF grant BCS-1354029")
154+
grant="BCS-1354029")
155155
self.assertIn(mandate, pub['mandates'])
156156
# Trigger the pprint method, but suppress the output
157157
with self.suppress_stdout():
@@ -194,10 +194,10 @@ def test_search_author_id_filled(self):
194194
self.assertEqual(author['affiliation'],
195195
u'Institut du radium, University of Paris')
196196
self.assertEqual(author['interests'], [])
197-
self.assertEqual(author['public_access']['available'], 1)
197+
self.assertEqual(author['public_access']['available'], 0)
198198
self.assertEqual(author['public_access']['not_available'], 0)
199-
self.assertGreaterEqual(author['citedby'], 1963) # TODO: maybe change
200-
self.assertGreaterEqual(len(author['publications']), 179)
199+
self.assertGreaterEqual(author['citedby'], 2067) # TODO: maybe change
200+
self.assertGreaterEqual(len(author['publications']), 218)
201201
pub = author['publications'][1]
202202
self.assertEqual(pub["citedby_url"],
203203
"https://scholar.google.com/scholar?oi=bibs&hl=en&cites=9976400141451962702")
@@ -260,19 +260,21 @@ def test_full_title(self):
260260
author = scholarly.search_author_id('Xxjj6IsAAAAJ')
261261
author = scholarly.fill(author, sections=['publications'])
262262
pub_index = -1
263-
for i in range(len(author['publications'])):
264-
if author['publications'][i]['author_pub_id'] == 'Xxjj6IsAAAAJ:u_35RYKgDlwC':
265-
pub_index = i
266-
self.assertGreaterEqual(i, 0)
267-
# elided title
268-
self.assertEqual(author['publications'][pub_index]['bib']['title'],
269-
u'Evaluation of toxicity of Dichlorvos (Nuvan) to fresh water fish Anabas testudineus and possible modulation by crude aqueous extract of Andrographis paniculata: A preliminary …')
270-
# full text
271-
pub = scholarly.fill(author['publications'][pub_index])
272-
self.assertEqual(pub['bib']['title'],
273-
u'Evaluation of toxicity of Dichlorvos (Nuvan) to fresh water fish Anabas testudineus and possible modulation by crude aqueous extract of Andrographis paniculata: A preliminary investigation')
274-
275-
self.assertEqual(pub['bib']['citation'], "")
263+
# Skip this part of the test since u_35RYKgDlwC has vanished from Google Scholar
264+
if False:
265+
for i in range(len(author['publications'])):
266+
if author['publications'][i]['author_pub_id'] == 'Xxjj6IsAAAAJ:u_35RYKgDlwC':
267+
pub_index = i
268+
self.assertGreaterEqual(i, 0)
269+
# elided title
270+
self.assertEqual(author['publications'][pub_index]['bib']['title'],
271+
u'Evaluation of toxicity of Dichlorvos (Nuvan) to fresh water fish Anabas testudineus and possible modulation by crude aqueous extract of Andrographis paniculata: A preliminary …')
272+
# full text
273+
pub = scholarly.fill(author['publications'][pub_index])
274+
self.assertEqual(pub['bib']['title'],
275+
u'Evaluation of toxicity of Dichlorvos (Nuvan) to fresh water fish Anabas testudineus and possible modulation by crude aqueous extract of Andrographis paniculata: A preliminary investigation')
276+
277+
self.assertEqual(pub['bib']['citation'], "")
276278

277279
for i in range(len(author['publications'])):
278280
if author['publications'][i]['author_pub_id'] == 'Xxjj6IsAAAAJ:ldfaerwXgEUC':
@@ -363,7 +365,8 @@ def test_mandates(self):
363365
if pub['author_pub_id'] == "kUDCLXAAAAAJ:tzM49s52ZIMC":
364366
scholarly.fill(pub)
365367
break
366-
mandate = Mandate(agency="European Commission", effective_date="2013/12", embargo="6 months", grant="279396",
368+
# The hard-coded reference mandate may need regular updates.
369+
mandate = Mandate(agency="European Commission", effective_date="2013/12", embargo="6 months", grant="647112",
367370
url_policy="https://erc.europa.eu/sites/default/files/document/file/ERC%20Open%20Access%20guidelines-Version%201.1._10.04.2017.pdf",
368371
url_policy_cached="/mandates/horizon2020_eu-2021-02-13-en.pdf",
369372
)
@@ -381,16 +384,15 @@ def test_related_articles_from_author(self):
381384
related_articles = scholarly.get_related_articles(pub)
382385
# Typically, the same publication is returned as the most related article
383386
same_article = next(related_articles)
384-
for key in {'pub_url', 'num_citations'}:
385-
self.assertEqual(pub[key], same_article[key])
387+
self.assertEqual(pub["pub_url"], same_article["pub_url"])
386388
for key in {'title', 'pub_year'}:
387389
self.assertEqual(str(pub['bib'][key]), (same_article['bib'][key]))
388390

389391
# These may change with time
390392
related_article = next(related_articles)
391-
self.assertEqual(related_article['bib']['title'], 'Choices, values, and frames')
392-
self.assertEqual(related_article['bib']['pub_year'], '2013')
393-
self.assertGreaterEqual(related_article['num_citations'], 16561)
393+
self.assertEqual(related_article['bib']['title'], 'Advances in prospect theory: Cumulative representation of uncertainty')
394+
self.assertEqual(related_article['bib']['pub_year'], '1992')
395+
self.assertGreaterEqual(related_article['num_citations'], 18673)
394396
self.assertIn("A Tversky", related_article['bib']['author'])
395397

396398
def test_author_custom_url(self):
@@ -435,7 +437,8 @@ def test_download_mandates_csv(self):
435437
soup = BeautifulSoup(response.text, "html.parser")
436438
agency_overall = soup.find_all("td", class_="gsc_mlt_n gsc_mlt_bd")
437439

438-
for agency, index in zip(agency_policy, [4-1,10-1, 19-1, 64-1]):
440+
# These hardcoded numbers need some regular updates.
441+
for agency, index in zip(agency_policy, [5-1,9-1, 21-1, 63-1]):
439442
agency_index = funder.index(agency)
440443
self.assertEqual(policy[agency_index], agency_policy[agency])
441444
# Check that the percentage values from CSV and on the page agree.
@@ -492,9 +495,10 @@ def test_save_journal_leaderboard(self):
492495
with open(filename, "r") as f:
493496
csv_reader = csv.DictReader(f)
494497
for row in csv_reader:
498+
# These hard-coded values need regular updates.
495499
self.assertEqual(row['Publication'], 'The Astrophysical Journal')
496-
self.assertEqual(row['h5-index'], '161')
497-
self.assertEqual(row['h5-median'], '239')
500+
self.assertEqual(row['h5-index'], '167')
501+
self.assertEqual(row['h5-median'], '234')
498502
self.assertEqual(row['Comment'], '#1 Astronomy & Astrophysics; #2 Physics & Mathematics; ')
499503
break
500504
finally:

0 commit comments

Comments
 (0)