1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 from caldavclientlibrary.protocol.http.util import parsequoted
18 from caldavclientlibrary.protocol.http.util import parsetoken
19 from caldavclientlibrary.protocol.http.util import parseStatusLine
20
21 import unittest
22
24
26
27 data = {
28 "\"\"" : ("", ""),
29 "\"quoted\"" : ("quoted", ""),
30 "\"quoted words\"" : ("quoted words", ""),
31 "\"quoting a \\\"word\\\"\"" : ("quoting a \"word\"", ""),
32 "\"\" after" : ("", "after"),
33 "\"quoted\" after" : ("quoted", "after"),
34 "\"quoted words\" after" : ("quoted words", "after"),
35 "\"quoting a \\\"word\\\"\" after" : ("quoting a \"word\"", "after"),
36 "\"quoting a \\\"word\\\" after\" after": ("quoting a \"word\" after", "after"),
37 "\"quoted\"after" : ("quoted", "after"),
38 "\"" : ("", ""),
39 "\"unterminated" : ("unterminated", ""),
40 "\"unterminated words" : ("unterminated words", ""),
41 "\"unterminated a \\\"word\\\"" : ("unterminated a \"word\"", ""),
42 }
43
44 for input, result in data.iteritems():
45 self.assertEqual(parsequoted(input), result)
46
57
59
61
62 data = {
63 "" : ("", ""),
64 "unquoted" : ("unquoted", ""),
65 "unquoted words" : ("unquoted", "words"),
66 "unquoted words" : ("unquoted", "words"),
67 "unquoting a \"word\"" : ("unquoting", "a \"word\""),
68 "unquoted\twords" : ("unquoted", "words"),
69 "unquoting\ta \"word\"" : ("unquoting", "a \"word\""),
70 "unquoted: words" : ("unquoted", "words"),
71 "unquoting: a \"word\"" : ("unquoting", "a \"word\""),
72
73 "\"\"" : ("", ""),
74 "\"quoted\"" : ("quoted", ""),
75 "\"quoted words\"" : ("quoted words", ""),
76 "\"quoting a \\\"word\\\"\"" : ("quoting a \"word\"", ""),
77 "\"\" after" : ("", "after"),
78 "\"quoted\" after" : ("quoted", "after"),
79 "\"quoted words\" after" : ("quoted words", "after"),
80 "\"quoting a \\\"word\\\"\" after" : ("quoting a \"word\"", "after"),
81 "\"quoting a \\\"word\\\" after\" after": ("quoting a \"word\" after", "after"),
82 "\"quoted\"after" : ("quoted", "after"),
83 "\"" : ("", ""),
84 "\"unterminated" : ("unterminated", ""),
85 "\"unterminated words" : ("unterminated words", ""),
86 "\"unterminated a \\\"word\\\"" : ("unterminated a \"word\"", ""),
87 }
88
89 for input, result in data.iteritems():
90 self.assertEqual(parsetoken(input, " \t:"), result)
91
108