File: test_helpers.py

package info (click to toggle)
dosage 3.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,400 kB
  • sloc: python: 12,703; sh: 55; makefile: 6
file content (23 lines) | stat: -rw-r--r-- 987 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: © 2019 Tobias Gruetzmacher
from dosagelib.helpers import joinPathPartsNamer, queryNamer


class TestNamer:
    """
    Tests for comic namer.
    """

    def test_queryNamer(self):
        testurl = 'http://FOO?page=result&page2=result2'
        assert queryNamer('page')(self, testurl, "") == 'result'
        assert queryNamer('page2', True)(self, "", testurl) == 'result2'

    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, -1))(self, imgurl, pageurl) == '2019_12450'