File: test_urls.py

package info (click to toggle)
xphyle 4.4.4-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,904 kB
  • sloc: python: 6,308; makefile: 205; ruby: 105
file content (33 lines) | stat: -rw-r--r-- 1,078 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
from unittest import TestCase
from xphyle.urls import *
from xphyle.paths import *


good_url = 'https://github.com/jdidion/xphyle/blob/master/tests/foo.gz?raw=True'
bad_url = 'foo'


class TestURLs(TestCase):
    def test_parse(self):
        self.assertEqual(
            tuple(parse_url(good_url)),
            ('https', 'github.com',
             '/jdidion/xphyle/blob/master/tests/foo.gz',
             '', 'raw=True', ''))
        self.assertIsNone(parse_url(bad_url))

    def test_open_invalid(self):
        self.assertIsNone(open_url(bad_url))

    def test_get_url_file_name(self):
        with TempDir() as temp:
            path = abspath(temp.make_file(name='foo.txt'))
            url = open_url(path.as_uri())
            assert get_url_file_name(url) == str(path)
        # TODO: need to find a reliable compressed file URL with a
        # Content-Disposition, or figure out how to mock one up

    def test_mime_types(self):
        # TODO: need to find a reliable compressed file URL with a MIME type,
        # or figure out how to mock one up
        pass