File: test_classify.py

package info (click to toggle)
python-uritools 3.0.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 264 kB
  • sloc: python: 1,470; makefile: 134
file content (56 lines) | stat: -rw-r--r-- 3,062 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import unittest

import uritools


class ClassifyTest(unittest.TestCase):
    def test_classification(self):
        cases = [
            ("", False, False, False, False, True, True),
            ("#", False, False, False, False, True, True),
            ("#f", False, False, False, False, True, True),
            ("?", False, False, False, False, True, False),
            ("?q", False, False, False, False, True, False),
            ("p", False, False, False, False, True, False),
            ("/p", False, False, False, True, False, False),
            ("/p?", False, False, False, True, False, False),
            ("/p?q", False, False, False, True, False, False),
            ("/p#", False, False, False, True, False, False),
            ("/p#f", False, False, False, True, False, False),
            ("/p?q#f", False, False, False, True, False, False),
            ("//", False, False, True, False, False, False),
            ("//n?", False, False, True, False, False, False),
            ("//n?q", False, False, True, False, False, False),
            ("//n#", False, False, True, False, False, False),
            ("//n#f", False, False, True, False, False, False),
            ("//n?q#f", False, False, True, False, False, False),
            ("s:", True, True, False, False, False, False),
            ("s:p", True, True, False, False, False, False),
            ("s:p?", True, True, False, False, False, False),
            ("s:p?q", True, True, False, False, False, False),
            ("s:p#", True, False, False, False, False, False),
            ("s:p#f", True, False, False, False, False, False),
            ("s://", True, True, False, False, False, False),
            ("s://h", True, True, False, False, False, False),
            ("s://h/", True, True, False, False, False, False),
            ("s://h/p", True, True, False, False, False, False),
            ("s://h/p?", True, True, False, False, False, False),
            ("s://h/p?q", True, True, False, False, False, False),
            ("s://h/p#", True, False, False, False, False, False),
            ("s://h/p#f", True, False, False, False, False, False),
        ]
        for s, uri, absuri, netpath, abspath, relpath, samedoc in cases:
            for ref in [s, s.encode("ascii")]:
                parts = uritools.urisplit(ref)
                self.assertEqual(parts.isuri(), uri)
                self.assertEqual(parts.isabsuri(), absuri)
                self.assertEqual(parts.isnetpath(), netpath)
                self.assertEqual(parts.isabspath(), abspath)
                self.assertEqual(parts.isrelpath(), relpath)
                self.assertEqual(parts.issamedoc(), samedoc)
                self.assertEqual(uritools.isuri(ref), uri)
                self.assertEqual(uritools.isabsuri(ref), absuri)
                self.assertEqual(uritools.isnetpath(ref), netpath)
                self.assertEqual(uritools.isabspath(ref), abspath)
                self.assertEqual(uritools.isrelpath(ref), relpath)
                self.assertEqual(uritools.issamedoc(ref), samedoc)