40 |
lower_3 = uri_3.lower() |
lower_3 = uri_3.lower() |
41 |
data_3 = 1025 * 'A' |
data_3 = 1025 * 'A' |
42 |
|
|
43 |
|
contenttest = ("urn:x-storm:1.0:%s," |
44 |
|
"u7uu5zpmkoeykkwhxd4unlqycc36gvl7." |
45 |
|
"jtlcbiy2r6gfsznbgj42yzqbqk4ti373bqs5qyy") |
46 |
|
|
47 |
def testConstructor(): |
def testConstructor(): |
48 |
id = BlockId(uri_1) |
id = BlockId(uri_1) |
87 |
else: assert 0 |
else: assert 0 |
88 |
# XXX test other wrong lengths too |
# XXX test other wrong lengths too |
89 |
|
|
90 |
|
def testContentType(): |
91 |
|
"""Malformed content types must throw exceptions""" |
92 |
|
|
93 |
|
BlockId(contenttest % 'text/html') |
94 |
|
BlockId(contenttest % 'a/a') |
95 |
|
BlockId(contenttest % 'x/x') |
96 |
|
|
97 |
|
try: BlockId(contenttest % '/html') |
98 |
|
except java.lang.IllegalArgumentException: pass |
99 |
|
else: assert 0 |
100 |
|
|
101 |
|
try: BlockId(contenttest % 'text/') |
102 |
|
except java.lang.IllegalArgumentException: pass |
103 |
|
else: assert 0 |
104 |
|
|
105 |
|
try: BlockId(contenttest % '/') |
106 |
|
except java.lang.IllegalArgumentException: pass |
107 |
|
else: assert 0 |
108 |
|
|
109 |
|
try: BlockId(contenttest % 'text/html/myextension') |
110 |
|
except java.lang.IllegalArgumentException: pass |
111 |
|
else: assert 0 |
112 |
|
|
113 |
|
try: BlockId(contenttest % 'mytype') |
114 |
|
except java.lang.IllegalArgumentException: pass |
115 |
|
else: assert 0 |
116 |
|
|
117 |
|
|
118 |
def testSpaces(): |
def testSpaces(): |
119 |
"""Spaces in content types must throw exceptions""" |
"""Spaces in content types must throw exceptions""" |
|
str = ("urn:x-storm:1.0:%s," |
|
|
"u7uu5zpmkoeykkwhxd4unlqycc36gvl7." |
|
|
"jtlcbiy2r6gfsznbgj42yzqbqk4ti373bqs5qyy") |
|
120 |
|
|
121 |
BlockId(str % 'text/plain;charset=UTF-8') |
BlockId(contenttest % 'text/plain;charset=UTF-8') |
122 |
|
|
123 |
try: BlockId(str % 'text/plain; charset=UTF-8') |
try: BlockId(contenttest % 'text/plain; charset=UTF-8') |
124 |
except java.lang.IllegalArgumentException: pass |
except java.lang.IllegalArgumentException: pass |
125 |
else: assert 0 |
else: assert 0 |
126 |
|
|