2020-04-18 11:45:44 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
2021-01-10 18:18:45 +00:00
|
|
|
# Copyright (C) 2019-2021 Tobias Gruetzmacher
|
2019-12-01 21:36:49 +00:00
|
|
|
import re
|
|
|
|
|
2019-12-03 22:52:14 +00:00
|
|
|
import pytest
|
2019-12-01 21:36:49 +00:00
|
|
|
import responses
|
|
|
|
|
|
|
|
import dosagelib.cmd
|
|
|
|
import httpmocks
|
|
|
|
|
2020-10-04 21:24:05 +00:00
|
|
|
|
2019-12-01 21:36:49 +00:00
|
|
|
def cmd(*options):
|
|
|
|
"""'Fake' run dosage with given options."""
|
|
|
|
assert dosagelib.cmd.main(("--allow-multiple",) + options) == 0
|
|
|
|
|
|
|
|
|
2020-10-04 21:24:05 +00:00
|
|
|
@pytest.mark.usefixtures('_nosleep', '_noappdirs')
|
2019-12-01 21:36:49 +00:00
|
|
|
class TestModules(object):
|
|
|
|
"""Test that specific comic modules work correctly."""
|
|
|
|
|
|
|
|
@responses.activate
|
|
|
|
def test_turnoff(self, tmpdir):
|
|
|
|
httpmocks.page('https://turnoff.us/', 'turnoff-home')
|
|
|
|
httpmocks.page('https://turnoff.us/geek/the-bad-design-punisher',
|
|
|
|
'turnoff-229')
|
|
|
|
|
|
|
|
httpmocks.png(re.compile(r'https://turnoff\.us/image/en/.*\.png'))
|
|
|
|
|
|
|
|
cmd('--numstrips', '2', '--basepath', str(tmpdir), 'turnoff')
|
2020-03-25 23:43:43 +00:00
|
|
|
|
|
|
|
@responses.activate
|
|
|
|
def test_gocomics_index(self, tmpdir):
|
|
|
|
httpmocks.page('https://www.gocomics.com/calvinandhobbesespanol',
|
|
|
|
'gocomics-root')
|
|
|
|
httpmocks.page(re.compile('.*espanol/2020/03/25'), 'gocomics-page')
|
|
|
|
httpmocks.page(re.compile('.*espanol/2012/07/22'), 'gocomics-page')
|
|
|
|
|
|
|
|
httpmocks.png(re.compile(r'https://assets\..*'))
|
|
|
|
|
|
|
|
cmd('--basepath', str(tmpdir), 'CalvinAndHobbesEnEspanol')
|
|
|
|
cmd('--basepath', str(tmpdir), 'CalvinAndHobbesEnEspanol:2012/07/22')
|
2020-09-28 11:11:34 +00:00
|
|
|
|
|
|
|
@responses.activate
|
2022-04-15 22:11:01 +00:00
|
|
|
@pytest.mark.skip(reason="SoloeLeveling was removed, so we have no way to test this...")
|
2020-09-28 11:11:34 +00:00
|
|
|
def test_sololeveling_geoblock(self, tmpdir):
|
2022-04-15 22:11:01 +00:00
|
|
|
from dosagelib.plugins.s import SoloLeveling
|
|
|
|
from dosagelib.scraper import GeoblockedException
|
|
|
|
|
2021-01-31 22:40:21 +00:00
|
|
|
responses.add(responses.GET, 'https://w3.sololeveling.net/',
|
2020-09-28 11:11:34 +00:00
|
|
|
'<span>1020</span>', status=403)
|
|
|
|
|
|
|
|
with pytest.raises(GeoblockedException):
|
|
|
|
next(SoloLeveling.getmodules()[0].getStrips(1))
|