Skip to content

Commit f76a131

Browse files
Merge pull request #422 from scholarly-python-package/develop
Release v1.6.3
2 parents da6954e + 7777ea1 commit f76a131

3 files changed

Lines changed: 16 additions & 6 deletions

File tree

scholarly/_scholarly.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def search_pubs(self,
152152
"""
153153
url = self._construct_url(_PUBSEARCH.format(requests.utils.quote(query)), patents=patents,
154154
citations=citations, year_low=year_low, year_high=year_high,
155-
sort_by=sort_by, start_index=start_index)
155+
sort_by=sort_by, include_last_year=include_last_year, start_index=start_index)
156156
return self.__nav.search_publications(url)
157157

158158
def search_citedby(self, publication_id: int, **kwargs):
@@ -620,4 +620,4 @@ def save_journals_csv(self, filename, category="English", subcategory=None, incl
620620
except IOError:
621621
self.logger.error("Error writing journals as %s", filename)
622622
finally:
623-
return journals
623+
return journals

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name='scholarly',
8-
version='1.6.2',
8+
version='1.6.3',
99
author='Steven A. Cholewiak, Panos Ipeirotis, Victor Silva, Arun Kannawadi',
1010
author_email='steven@cholewiak.com, panos@stern.nyu.edu, vsilva@ualberta.ca, arunkannawadi@astro.princeton.edu',
1111
description='Simple access to Google Scholar authors and citations',

test_module.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import random
88
import json
99
import csv
10+
import requests
11+
from bs4 import BeautifulSoup
1012
from contextlib import contextmanager
1113

1214

@@ -640,13 +642,14 @@ def test_download_mandates_csv(self):
640642
# Delete the file with a finally block no matter what happens
641643
try:
642644
scholarly.download_mandates_csv(filename)
643-
funder, policy, percentage2020 = [], [], []
645+
funder, policy, percentage2020, percentageOverall = [], [], [], []
644646
with open(filename, "r") as f:
645647
csv_reader = csv.DictReader(f)
646648
for row in csv_reader:
647649
funder.append(row['\ufeffFunder'])
648650
policy.append(row['Policy'])
649651
percentage2020.append(row['2020'])
652+
percentageOverall.append(row['Overall'])
650653

651654
agency_policy = {
652655
"US National Science Foundation": "https://www.nsf.gov/pubs/2015/nsf15052/nsf15052.pdf",
@@ -661,10 +664,17 @@ def test_download_mandates_csv(self):
661664
"Swedish Research Council for Environment, Agricultural Sciences and Spatial Planning": "88%"
662665
}
663666

664-
for agency in agency_policy:
667+
response = requests.get("https://scholar.google.com/citations?view_op=mandates_leaderboard&hl=en")
668+
soup = BeautifulSoup(response.text, "html.parser")
669+
agency_overall = soup.find_all("td", class_="gsc_mlt_n gsc_mlt_bd")
670+
671+
for agency, index in zip(agency_policy, [4-1,10-1, 19-1, 64-1]):
665672
agency_index = funder.index(agency)
666673
self.assertEqual(policy[agency_index], agency_policy[agency])
667-
self.assertEqual(percentage2020[agency_index], agency_2020[agency])
674+
# Check that the percentage values from CSV and on the page agree.
675+
self.assertEqual(percentageOverall[agency_index], agency_overall[index].text)
676+
# The percentage fluctuates, so we can't check the exact value.
677+
self.assertAlmostEquals(int(percentage2020[agency_index][:-1]), int(agency_2020[agency][:-1]), delta=2)
668678
finally:
669679
if os.path.exists(filename):
670680
os.remove(filename)

0 commit comments

Comments
 (0)