File: test_unsplit.py

package info (click to toggle)
python-uritools 6.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 240 kB
  • sloc: python: 1,544; makefile: 10
file content (32 lines) | stat: -rw-r--r-- 1,071 bytes parent folder | download | duplicates (3)
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
import unittest

from uritools import uriunsplit


class UnsplitTest(unittest.TestCase):
    def check(self, split, uri):
        result = uriunsplit(split)
        self.assertEqual(result, uri)

    def test_rfc3986_3(self):
        """uriunsplit test cases from [RFC3986] 3. Syntax Components"""
        cases = [
            (
                ("foo", "example.com:8042", "/over/there", "name=ferret", "nose"),
                "foo://example.com:8042/over/there?name=ferret#nose",
            ),
            (
                ("urn", None, "example:animal:ferret:nose", None, None),
                "urn:example:animal:ferret:nose",
            ),
            (
                (b"foo", b"example.com:8042", b"/over/there", b"name=ferret", b"nose"),
                b"foo://example.com:8042/over/there?name=ferret#nose",
            ),
            (
                (b"urn", None, b"example:animal:ferret:nose", None, None),
                b"urn:example:animal:ferret:nose",
            ),
        ]
        for uri, parts in cases:
            self.check(uri, parts)