File: test_parse_url.py

package info (click to toggle)
gdown 5.2.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 416 kB
  • sloc: python: 1,161; makefile: 23
file content (40 lines) | stat: -rw-r--r-- 1,041 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import pytest

from gdown.parse_url import parse_url


def test_parse_url():
    file_id = "0B_NiLAzvehC9R2stRmQyM3ZiVjQ"

    # list of (url, expected, check_warn)
    urls = [
        (
            "https://drive.google.com/open?id={}".format(file_id),
            (file_id, False),
            True,
        ),
        (
            "https://drive.google.com/uc?id={}".format(file_id),
            (file_id, True),
            False,
        ),
        (
            "https://drive.google.com/file/d/{}/view?usp=sharing".format(file_id),
            (file_id, False),
            True,
        ),
        (
            "https://drive.google.com/a/jsk.imi.i.u-tokyo.ac.jp/uc?id={}&export=download".format(  # NOQA
                file_id
            ),
            (file_id, True),
            False,
        ),
    ]

    for url, expected, check_warn in urls:
        if check_warn:
            with pytest.warns(UserWarning):
                assert parse_url(url) == expected
        else:
            assert parse_url(url) == expected