-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test_gateways.py
23 lines (18 loc) · 885 Bytes
/
test_gateways.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# coding: utf-8
from gummy import journals
from gummy.utils import get_driver
from gummy.journals import whichJournal
def _test_gateways(gateway, url="https://doi.org/10.1038/171737a0", **kwargs):
journal_type = whichJournal(url)
# Crawler without gateway.
useless_crawler = journals.get(identifier=journal_type, gateway="useless")
with get_driver() as driver:
useless_title, useless_contents = useless_crawler.get_contents(url=url, driver=driver)
# Crawler with gateway.
gateway_crawler = journals.get(identifier=journal_type, gateway=gateway)
with get_driver() as driver:
gateway_title, gateway_contents = gateway_crawler.get_contents(url=url, driver=driver)
assert useless_title == gateway_title
assert len(useless_contents) < len(gateway_contents)
def test_utokyo_gateways():
_test_gateways(gateway="utokyo")