dosage/tests/test_helpers.py

24 lines
987 B
Python
Raw Permalink Normal View History

# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2019 Tobias Gruetzmacher
2019-12-30 23:43:46 +00:00
from dosagelib.helpers import joinPathPartsNamer, queryNamer
2019-10-28 18:17:57 +00:00
class TestNamer:
2019-10-28 18:17:57 +00:00
"""
Tests for comic namer.
"""
2019-12-30 23:43:46 +00:00
def test_queryNamer(self):
testurl = 'http://FOO?page=result&page2=result2'
assert queryNamer('page')(self, testurl, "") == 'result'
assert queryNamer('page2', True)(self, "", testurl) == 'result2'
2019-10-28 18:17:57 +00:00
def test_joinPathPartsNamer(self):
imgurl = 'https://HOST/wp-content/uploads/2019/02/tennis5wp-1.png'
pageurl = 'https://HOST/2019/03/11/12450/'
assert joinPathPartsNamer(pageparts=(0, 1, 2), imageparts=(-1,))(self,
imgurl, pageurl) == '2019_03_11_tennis5wp-1.png'
assert joinPathPartsNamer(pageparts=(0, 1, 2), imageparts=(-1,), joinchar='-')(self,
imgurl, pageurl) == '2019-03-11-tennis5wp-1.png'
assert joinPathPartsNamer(pageparts=(0, -2))(self, imgurl, pageurl) == '2019_12450'