| 1 |
#!/usr/bin/env python |
|---|
| 2 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 3 |
##~ Copyright (C) 2002-2004 TechGame Networks, LLC. |
|---|
| 4 |
##~ |
|---|
| 5 |
##~ This library is free software; you can redistribute it and/or |
|---|
| 6 |
##~ modify it under the terms of the BSD style License as found in the |
|---|
| 7 |
##~ LICENSE file included with this distribution. |
|---|
| 8 |
##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 9 |
|
|---|
| 10 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 11 |
#~ Imports |
|---|
| 12 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 13 |
|
|---|
| 14 |
import unittest |
|---|
| 15 |
|
|---|
| 16 |
from TG.w3c import uri |
|---|
| 17 |
|
|---|
| 18 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 19 |
#~ Definitions |
|---|
| 20 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 21 |
|
|---|
| 22 |
class TestURIPathDefaultTestCase(unittest.TestCase): |
|---|
| 23 |
def verifyURIParts(self, uriValue, scheme, authority, path, query, fragment): |
|---|
| 24 |
try: |
|---|
| 25 |
self.failUnlessEqual(uriValue.scheme, scheme) |
|---|
| 26 |
self.failUnlessEqual(uriValue.authority, authority) |
|---|
| 27 |
self.failUnlessEqual(uriValue.path, path) |
|---|
| 28 |
self.failUnlessEqual(uriValue.query, query) |
|---|
| 29 |
self.failUnlessEqual(uriValue.fragment, fragment) |
|---|
| 30 |
except: |
|---|
| 31 |
print |
|---|
| 32 |
print uriValue.getURIParts() |
|---|
| 33 |
print |
|---|
| 34 |
raise |
|---|
| 35 |
|
|---|
| 36 |
def testScheme(self): |
|---|
| 37 |
'Path Default: "scheme:"' |
|---|
| 38 |
uriStr = 'scheme:' |
|---|
| 39 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 40 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 41 |
self.verifyURIParts(uriValue, 'scheme', None, None, None, None) |
|---|
| 42 |
|
|---|
| 43 |
def testPath(self): |
|---|
| 44 |
'Path Default: "path"' |
|---|
| 45 |
uriStr = 'path' |
|---|
| 46 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 47 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 48 |
self.verifyURIParts(uriValue, None, None, 'path', None, None) |
|---|
| 49 |
|
|---|
| 50 |
def testPathSlash(self): |
|---|
| 51 |
'Path Default: "/path"' |
|---|
| 52 |
uriStr = '/path' |
|---|
| 53 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 54 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 55 |
self.verifyURIParts(uriValue, None, None, '/path', None, None) |
|---|
| 56 |
|
|---|
| 57 |
def testSchemePath(self): |
|---|
| 58 |
'Path Default: "scheme:path"' |
|---|
| 59 |
uriStr = 'scheme:path' |
|---|
| 60 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 61 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 62 |
self.verifyURIParts(uriValue, 'scheme', None, 'path', None, None) |
|---|
| 63 |
|
|---|
| 64 |
def testSchemePathSlash(self): |
|---|
| 65 |
'Path Default: "scheme:/path"' |
|---|
| 66 |
uriStr = 'scheme:/path' |
|---|
| 67 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 68 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 69 |
self.verifyURIParts(uriValue, 'scheme', None, '/path', None, None) |
|---|
| 70 |
|
|---|
| 71 |
def testAuthority(self): |
|---|
| 72 |
'Path Default: "//authority"' |
|---|
| 73 |
uriStr = '//authority' |
|---|
| 74 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 75 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 76 |
self.verifyURIParts(uriValue, None, 'authority', None, None, None) |
|---|
| 77 |
|
|---|
| 78 |
def testSchemeAuthority(self): |
|---|
| 79 |
'Path Default: "scheme://authority"' |
|---|
| 80 |
uriStr = 'scheme://authority' |
|---|
| 81 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 82 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 83 |
self.verifyURIParts(uriValue, 'scheme', 'authority', None, None, None) |
|---|
| 84 |
|
|---|
| 85 |
def testAuthorityPath(self): |
|---|
| 86 |
'Path Default: "//authority/path"' |
|---|
| 87 |
uriStr = '//authority/path' |
|---|
| 88 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 89 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 90 |
self.verifyURIParts(uriValue, None, 'authority', '/path', None, None) |
|---|
| 91 |
|
|---|
| 92 |
def testSchemeAuthorityPath(self): |
|---|
| 93 |
'Path Default: "scheme://authority/path"' |
|---|
| 94 |
uriStr = 'scheme://authority/path' |
|---|
| 95 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 96 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 97 |
self.verifyURIParts(uriValue, 'scheme', 'authority', '/path', None, None) |
|---|
| 98 |
|
|---|
| 99 |
def testUserAuthorityPath(self): |
|---|
| 100 |
'Path Default: "//user@authority/path"' |
|---|
| 101 |
uriStr = '//user@authority/path' |
|---|
| 102 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 103 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 104 |
self.verifyURIParts(uriValue, None, 'user@authority', '/path', None, None) |
|---|
| 105 |
|
|---|
| 106 |
def testSchemeUserAuthorityPath(self): |
|---|
| 107 |
'Path Default: "scheme://user@authority/path"' |
|---|
| 108 |
uriStr = 'scheme://user@authority/path' |
|---|
| 109 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 110 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 111 |
self.verifyURIParts(uriValue, 'scheme', 'user@authority', '/path', None, None) |
|---|
| 112 |
|
|---|
| 113 |
def testSchemeUserAuthorityHostPath(self): |
|---|
| 114 |
'Path Default: "scheme://user@authority:4242/path"' |
|---|
| 115 |
uriStr = 'scheme://user@authority:4242/path' |
|---|
| 116 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 117 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 118 |
self.verifyURIParts(uriValue, 'scheme', 'user@authority:4242', '/path', None, None) |
|---|
| 119 |
|
|---|
| 120 |
def testMailto(self): |
|---|
| 121 |
'Path Default: "mailto:user@host"' |
|---|
| 122 |
uriStr = 'mailto:user@host' |
|---|
| 123 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 124 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 125 |
self.verifyURIParts(uriValue, 'mailto', None, 'user@host', None, None) |
|---|
| 126 |
|
|---|
| 127 |
def testUserPasswdAuthority(self): |
|---|
| 128 |
'Path Default: "//user:passwd@authority"' |
|---|
| 129 |
uriStr = '//user:passwd@authority' |
|---|
| 130 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 131 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 132 |
self.verifyURIParts(uriValue, None, 'user:passwd@authority', None, None, None) |
|---|
| 133 |
|
|---|
| 134 |
def testUserPasswdAuthorityHostPath(self): |
|---|
| 135 |
'Path Default: "//user:passwd@authority:4242/path"' |
|---|
| 136 |
uriStr = '//user:passwd@authority:4242/path' |
|---|
| 137 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 138 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 139 |
self.verifyURIParts(uriValue, None, 'user:passwd@authority:4242', '/path', None, None) |
|---|
| 140 |
|
|---|
| 141 |
def testSchemeUserPasswdAuthorityHostPath(self): |
|---|
| 142 |
'Path Default: "scheme://user:passwd@authority:4242/path"' |
|---|
| 143 |
uriStr = 'scheme://user:passwd@authority:4242/path' |
|---|
| 144 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 145 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 146 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path', None, None) |
|---|
| 147 |
|
|---|
| 148 |
def testSchemeUserPasswdAuthorityHostPathAttributes(self): |
|---|
| 149 |
'Path Default: "scheme://user:passwd@authority:4242/path;attr1=value1"' |
|---|
| 150 |
uriStr = 'scheme://user:passwd@authority:4242/path;attr1=value1' |
|---|
| 151 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 152 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 153 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', None, None) |
|---|
| 154 |
|
|---|
| 155 |
def testSchemeUserPasswdAuthorityHostPathAttributesQuery(self): |
|---|
| 156 |
'Path Default: "scheme://user:passwd@authority:4242/path;attr1=value1?query"' |
|---|
| 157 |
uriStr = 'scheme://user:passwd@authority:4242/path;attr1=value1?query' |
|---|
| 158 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 159 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 160 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', 'query', None) |
|---|
| 161 |
|
|---|
| 162 |
def testSchemeUserPasswdAuthorityHostPathAttributesQueryFragment(self): |
|---|
| 163 |
'Path Default: "scheme://user:passwd@authority:4242/path;attr1=value1?query#fragment"' |
|---|
| 164 |
uriStr = 'scheme://user:passwd@authority:4242/path;attr1=value1?query#fragment' |
|---|
| 165 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 166 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 167 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 168 |
|
|---|
| 169 |
def testSchemeNullAuthorityPathAttributesQueryFragment(self): |
|---|
| 170 |
'Path Default: "scheme:///path;attr1=value1?query#fragment"' |
|---|
| 171 |
uriStr = 'scheme:///path;attr1=value1?query#fragment' |
|---|
| 172 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 173 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 174 |
self.verifyURIParts(uriValue, 'scheme', '', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 175 |
|
|---|
| 176 |
def testSchemePathAttributesQueryFragment(self): |
|---|
| 177 |
'Path Default: "scheme:/path;attr1=value1?query#fragment"' |
|---|
| 178 |
uriStr = 'scheme:/path;attr1=value1?query#fragment' |
|---|
| 179 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 180 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 181 |
self.verifyURIParts(uriValue, 'scheme', None, '/path;attr1=value1', 'query', 'fragment') |
|---|
| 182 |
|
|---|
| 183 |
def testNullAuthorityPathAttributesQueryFragment(self): |
|---|
| 184 |
'Path Default: "///path;attr1=value1?query#fragment"' |
|---|
| 185 |
uriStr = '///path;attr1=value1?query#fragment' |
|---|
| 186 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 187 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 188 |
self.verifyURIParts(uriValue, None, '', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 189 |
|
|---|
| 190 |
def testPathAttributesQueryFragment(self): |
|---|
| 191 |
'Path Default: "/path;attr1=value1?query#fragment"' |
|---|
| 192 |
uriStr = '/path;attr1=value1?query#fragment' |
|---|
| 193 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 194 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 195 |
self.verifyURIParts(uriValue, None, None, '/path;attr1=value1', 'query', 'fragment') |
|---|
| 196 |
|
|---|
| 197 |
def testPathQueryFragment(self): |
|---|
| 198 |
'Path Default: "/path?query#fragment"' |
|---|
| 199 |
uriStr = '/path?query#fragment' |
|---|
| 200 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 201 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 202 |
self.verifyURIParts(uriValue, None, None, '/path', 'query', 'fragment') |
|---|
| 203 |
|
|---|
| 204 |
def testQueryFragment(self): |
|---|
| 205 |
'Path Default: "?query#fragment"' |
|---|
| 206 |
uriStr = '?query#fragment' |
|---|
| 207 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 208 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 209 |
self.verifyURIParts(uriValue, None, None, None, 'query', 'fragment') |
|---|
| 210 |
|
|---|
| 211 |
def testSchemeQuery(self): |
|---|
| 212 |
'Path Default: "scheme:?query"' |
|---|
| 213 |
uriStr = 'scheme:?query' |
|---|
| 214 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 215 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 216 |
self.verifyURIParts(uriValue, 'scheme', None, None, 'query', None) |
|---|
| 217 |
|
|---|
| 218 |
def testQuery(self): |
|---|
| 219 |
'Path Default: "?query"' |
|---|
| 220 |
uriStr = '?query' |
|---|
| 221 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 222 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 223 |
self.verifyURIParts(uriValue, None, None, None, 'query', None) |
|---|
| 224 |
|
|---|
| 225 |
def testFragment(self): |
|---|
| 226 |
'Path Default: "#fragment"' |
|---|
| 227 |
uriStr = '#fragment' |
|---|
| 228 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 229 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 230 |
self.verifyURIParts(uriValue, None, None, None, None, 'fragment') |
|---|
| 231 |
|
|---|
| 232 |
def testSchemeFragment(self): |
|---|
| 233 |
'Path Default: "scheme:#fragment"' |
|---|
| 234 |
uriStr = 'scheme:#fragment' |
|---|
| 235 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 236 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 237 |
self.verifyURIParts(uriValue, 'scheme', None, None, None, 'fragment') |
|---|
| 238 |
|
|---|
| 239 |
def testPathQuery(self): |
|---|
| 240 |
'Path Default: "/path?query"' |
|---|
| 241 |
uriStr = '/path?query' |
|---|
| 242 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 243 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 244 |
self.verifyURIParts(uriValue, None, None, '/path', 'query', None) |
|---|
| 245 |
|
|---|
| 246 |
def testPathFragment(self): |
|---|
| 247 |
'Path Default: "/path#fragment"' |
|---|
| 248 |
uriStr = '/path#fragment' |
|---|
| 249 |
uriValue = uri.URIPathDefault(uriStr) |
|---|
| 250 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 251 |
self.verifyURIParts(uriValue, None, None, '/path', None, 'fragment') |
|---|
| 252 |
|
|---|
| 253 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 254 |
|
|---|
| 255 |
class TestURIAuthorityDefaultTestCase(unittest.TestCase): |
|---|
| 256 |
def verifyURIParts(self, uriValue, scheme, authority, path, query, fragment): |
|---|
| 257 |
self.failUnlessEqual(uriValue.scheme, scheme) |
|---|
| 258 |
self.failUnlessEqual(uriValue.authority, authority) |
|---|
| 259 |
self.failUnlessEqual(uriValue.path, path) |
|---|
| 260 |
self.failUnlessEqual(uriValue.query, query) |
|---|
| 261 |
self.failUnlessEqual(uriValue.fragment, fragment) |
|---|
| 262 |
|
|---|
| 263 |
def testScheme(self): |
|---|
| 264 |
'Authority Default: "scheme:"' |
|---|
| 265 |
uriStr = 'scheme:' |
|---|
| 266 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 267 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 268 |
self.verifyURIParts(uriValue, 'scheme', '', None, None, None) |
|---|
| 269 |
|
|---|
| 270 |
def testAuthority(self): |
|---|
| 271 |
'Authority Default: "authority"' |
|---|
| 272 |
uriStr = 'authority' |
|---|
| 273 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 274 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 275 |
self.verifyURIParts(uriValue, None, 'authority', None, None, None) |
|---|
| 276 |
|
|---|
| 277 |
def testPath(self): |
|---|
| 278 |
'Authority Default: "/path"' |
|---|
| 279 |
uriStr = '/path' |
|---|
| 280 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 281 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 282 |
self.verifyURIParts(uriValue, None, '', '/path', None, None) |
|---|
| 283 |
|
|---|
| 284 |
def testSchemeAuthority(self): |
|---|
| 285 |
'Authority Default: "scheme:authority"' |
|---|
| 286 |
uriStr = 'scheme:authority' |
|---|
| 287 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 288 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 289 |
self.verifyURIParts(uriValue, 'scheme', 'authority', None, None, None) |
|---|
| 290 |
|
|---|
| 291 |
def testSchemePath(self): |
|---|
| 292 |
'Authority Default: "scheme:/path"' |
|---|
| 293 |
uriStr = 'scheme:/path' |
|---|
| 294 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 295 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 296 |
self.verifyURIParts(uriValue, 'scheme', '', '/path', None, None) |
|---|
| 297 |
|
|---|
| 298 |
def testNetworkAuthority(self): |
|---|
| 299 |
'Authority Default: "//authority"' |
|---|
| 300 |
uriStr = '//authority' |
|---|
| 301 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 302 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 303 |
self.verifyURIParts(uriValue, None, 'authority', None, None, None) |
|---|
| 304 |
|
|---|
| 305 |
def testSchemeNetworkAuthority(self): |
|---|
| 306 |
'Authority Default: "scheme://authority"' |
|---|
| 307 |
uriStr = 'scheme://authority' |
|---|
| 308 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 309 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 310 |
self.verifyURIParts(uriValue, 'scheme', 'authority', None, None, None) |
|---|
| 311 |
|
|---|
| 312 |
def testAuthorityPath(self): |
|---|
| 313 |
'Authority Default: "authority/path"' |
|---|
| 314 |
uriStr = 'authority/path' |
|---|
| 315 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 316 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 317 |
self.verifyURIParts(uriValue, None, 'authority', '/path', None, None) |
|---|
| 318 |
|
|---|
| 319 |
def testNetworkAuthorityPath(self): |
|---|
| 320 |
'Authority Default: "//authority/path"' |
|---|
| 321 |
uriStr = '//authority/path' |
|---|
| 322 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 323 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 324 |
self.verifyURIParts(uriValue, None, 'authority', '/path', None, None) |
|---|
| 325 |
|
|---|
| 326 |
def testSchemeAuthorityPath(self): |
|---|
| 327 |
'Authority Default: "scheme:authority/path"' |
|---|
| 328 |
uriStr = 'scheme:authority/path' |
|---|
| 329 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 330 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 331 |
self.verifyURIParts(uriValue, 'scheme', 'authority', '/path', None, None) |
|---|
| 332 |
|
|---|
| 333 |
def testSchemeNetworkAuthorityPath(self): |
|---|
| 334 |
'Authority Default: "scheme://authority/path"' |
|---|
| 335 |
uriStr = 'scheme://authority/path' |
|---|
| 336 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 337 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 338 |
self.verifyURIParts(uriValue, 'scheme', 'authority', '/path', None, None) |
|---|
| 339 |
|
|---|
| 340 |
def testNetworkUserAuthorityPath(self): |
|---|
| 341 |
'Authority Default: "//user@authority/path"' |
|---|
| 342 |
uriStr = '//user@authority/path' |
|---|
| 343 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 344 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 345 |
self.verifyURIParts(uriValue, None, 'user@authority', '/path', None, None) |
|---|
| 346 |
|
|---|
| 347 |
def testUserAuthorityPath(self): |
|---|
| 348 |
'Authority Default: "user@authority/path"' |
|---|
| 349 |
uriStr = 'user@authority/path' |
|---|
| 350 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 351 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 352 |
self.verifyURIParts(uriValue, None, 'user@authority', '/path', None, None) |
|---|
| 353 |
|
|---|
| 354 |
def testSchemeUserAuthorityPath(self): |
|---|
| 355 |
'Authority Default: "scheme:user@authority/path"' |
|---|
| 356 |
uriStr = 'scheme:user@authority/path' |
|---|
| 357 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 358 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 359 |
self.verifyURIParts(uriValue, 'scheme', 'user@authority', '/path', None, None) |
|---|
| 360 |
|
|---|
| 361 |
def testSchemeNetworkUserAuthorityPath(self): |
|---|
| 362 |
'Authority Default: "scheme://user@authority/path"' |
|---|
| 363 |
uriStr = 'scheme://user@authority/path' |
|---|
| 364 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 365 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 366 |
self.verifyURIParts(uriValue, 'scheme', 'user@authority', '/path', None, None) |
|---|
| 367 |
|
|---|
| 368 |
def testSchemeNetworkUserAuthorityHostPath(self): |
|---|
| 369 |
'Authority Default: "scheme://user@authority:4242/path"' |
|---|
| 370 |
uriStr = 'scheme://user@authority:4242/path' |
|---|
| 371 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 372 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 373 |
self.verifyURIParts(uriValue, 'scheme', 'user@authority:4242', '/path', None, None) |
|---|
| 374 |
|
|---|
| 375 |
def testSchemeUserAuthorityHostPath(self): |
|---|
| 376 |
'Authority Default: "scheme:user@authority:4242/path"' |
|---|
| 377 |
uriStr = 'scheme:user@authority:4242/path' |
|---|
| 378 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 379 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 380 |
self.verifyURIParts(uriValue, 'scheme', 'user@authority:4242', '/path', None, None) |
|---|
| 381 |
|
|---|
| 382 |
def testMailto(self): |
|---|
| 383 |
'Authority Default: "mailto:user@host"' |
|---|
| 384 |
uriStr = 'mailto:user@host' |
|---|
| 385 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 386 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 387 |
self.verifyURIParts(uriValue, 'mailto', 'user@host', None, None, None) |
|---|
| 388 |
|
|---|
| 389 |
def testNetworkUserPasswdAuthority(self): |
|---|
| 390 |
'Authority Default: "//user:passwd@authority"' |
|---|
| 391 |
uriStr = '//user:passwd@authority' |
|---|
| 392 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 393 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 394 |
self.verifyURIParts(uriValue, None, 'user:passwd@authority', None, None, None) |
|---|
| 395 |
|
|---|
| 396 |
def testNetworkUserPasswdAuthorityHostPath(self): |
|---|
| 397 |
'Authority Default: "//user:passwd@authority:4242/path"' |
|---|
| 398 |
uriStr = '//user:passwd@authority:4242/path' |
|---|
| 399 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 400 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 401 |
self.verifyURIParts(uriValue, None, 'user:passwd@authority:4242', '/path', None, None) |
|---|
| 402 |
|
|---|
| 403 |
def testSchemeNetworkUserPasswdAuthorityHostPath(self): |
|---|
| 404 |
'Authority Default: "scheme://user:passwd@authority:4242/path"' |
|---|
| 405 |
uriStr = 'scheme://user:passwd@authority:4242/path' |
|---|
| 406 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 407 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 408 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path', None, None) |
|---|
| 409 |
|
|---|
| 410 |
def testSchemeUserPasswdAuthorityHostPath(self): |
|---|
| 411 |
'Authority Default: "scheme:user:passwd@authority:4242/path"' |
|---|
| 412 |
uriStr = 'scheme:user:passwd@authority:4242/path' |
|---|
| 413 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 414 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 415 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path', None, None) |
|---|
| 416 |
|
|---|
| 417 |
def testSchemeNetworkUserPasswdAuthorityHostPathAttributes(self): |
|---|
| 418 |
'Authority Default: "scheme://user:passwd@authority:4242/path;attr1=value1"' |
|---|
| 419 |
uriStr = 'scheme://user:passwd@authority:4242/path;attr1=value1' |
|---|
| 420 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 421 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 422 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', None, None) |
|---|
| 423 |
|
|---|
| 424 |
def testSchemeUserPasswdAuthorityHostPathAttributes(self): |
|---|
| 425 |
'Authority Default: "scheme:user:passwd@authority:4242/path;attr1=value1"' |
|---|
| 426 |
uriStr = 'scheme:user:passwd@authority:4242/path;attr1=value1' |
|---|
| 427 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 428 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 429 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', None, None) |
|---|
| 430 |
|
|---|
| 431 |
def testSchemeNetworkUserPasswdAuthorityHostPathAttributesQuery(self): |
|---|
| 432 |
'Authority Default: "scheme://user:passwd@authority:4242/path;attr1=value1?query"' |
|---|
| 433 |
uriStr = 'scheme://user:passwd@authority:4242/path;attr1=value1?query' |
|---|
| 434 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 435 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 436 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', 'query', None) |
|---|
| 437 |
|
|---|
| 438 |
def testSchemeUserPasswdAuthorityHostPathAttributesQuery(self): |
|---|
| 439 |
'Authority Default: "scheme:user:passwd@authority:4242/path;attr1=value1?query"' |
|---|
| 440 |
uriStr = 'scheme:user:passwd@authority:4242/path;attr1=value1?query' |
|---|
| 441 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 442 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 443 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', 'query', None) |
|---|
| 444 |
|
|---|
| 445 |
def testSchemeNetworkUserPasswdAuthorityHostPathAttributesQueryFragment(self): |
|---|
| 446 |
'Authority Default: "scheme://user:passwd@authority:4242/path;attr1=value1?query#fragment"' |
|---|
| 447 |
uriStr = 'scheme://user:passwd@authority:4242/path;attr1=value1?query#fragment' |
|---|
| 448 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 449 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 450 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 451 |
|
|---|
| 452 |
def testSchemeUserPasswdAuthorityHostPathAttributesQueryFragment(self): |
|---|
| 453 |
'Authority Default: "scheme:user:passwd@authority:4242/path;attr1=value1?query#fragment"' |
|---|
| 454 |
uriStr = 'scheme:user:passwd@authority:4242/path;attr1=value1?query#fragment' |
|---|
| 455 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 456 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 457 |
self.verifyURIParts(uriValue, 'scheme', 'user:passwd@authority:4242', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 458 |
|
|---|
| 459 |
def testSchemeNetworkNullAuthorityPathAttributesQueryFragment(self): |
|---|
| 460 |
'Authority Default: "scheme:///path;attr1=value1?query#fragment"' |
|---|
| 461 |
uriStr = 'scheme:///path;attr1=value1?query#fragment' |
|---|
| 462 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 463 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 464 |
self.verifyURIParts(uriValue, 'scheme', '', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 465 |
|
|---|
| 466 |
def testSchemePathAttributesQueryFragment(self): |
|---|
| 467 |
'Authority Default: "scheme:/path;attr1=value1?query#fragment"' |
|---|
| 468 |
uriStr = 'scheme:/path;attr1=value1?query#fragment' |
|---|
| 469 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 470 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 471 |
self.verifyURIParts(uriValue, 'scheme', '', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 472 |
|
|---|
| 473 |
def testNetworkNullAuthorityPathAttributesQueryFragment(self): |
|---|
| 474 |
'Authority Default: "///path;attr1=value1?query#fragment"' |
|---|
| 475 |
uriStr = '///path;attr1=value1?query#fragment' |
|---|
| 476 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 477 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 478 |
self.verifyURIParts(uriValue, None, '', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 479 |
|
|---|
| 480 |
def testPathAttributesQueryFragment(self): |
|---|
| 481 |
'Authority Default: "/path;attr1=value1?query#fragment"' |
|---|
| 482 |
uriStr = '/path;attr1=value1?query#fragment' |
|---|
| 483 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 484 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 485 |
self.verifyURIParts(uriValue, None, '', '/path;attr1=value1', 'query', 'fragment') |
|---|
| 486 |
|
|---|
| 487 |
def testPathQueryFragment(self): |
|---|
| 488 |
'Authority Default: "/path?query#fragment"' |
|---|
| 489 |
uriStr = '/path?query#fragment' |
|---|
| 490 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 491 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 492 |
self.verifyURIParts(uriValue, None, '', '/path', 'query', 'fragment') |
|---|
| 493 |
|
|---|
| 494 |
def testQueryFragment(self): |
|---|
| 495 |
'Authority Default: "?query#fragment"' |
|---|
| 496 |
uriStr = '?query#fragment' |
|---|
| 497 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 498 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 499 |
self.verifyURIParts(uriValue, None, '', None, 'query', 'fragment') |
|---|
| 500 |
|
|---|
| 501 |
def testSchemeQuery(self): |
|---|
| 502 |
'Authority Default: "scheme:?query"' |
|---|
| 503 |
uriStr = 'scheme:?query' |
|---|
| 504 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 505 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 506 |
self.verifyURIParts(uriValue, 'scheme', '', None, 'query', None) |
|---|
| 507 |
|
|---|
| 508 |
def testQuery(self): |
|---|
| 509 |
'Authority Default: "?query"' |
|---|
| 510 |
uriStr = '?query' |
|---|
| 511 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 512 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 513 |
self.verifyURIParts(uriValue, None, '', None, 'query', None) |
|---|
| 514 |
|
|---|
| 515 |
def testFragment(self): |
|---|
| 516 |
'Authority Default: "#fragment"' |
|---|
| 517 |
uriStr = '#fragment' |
|---|
| 518 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 519 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 520 |
self.verifyURIParts(uriValue, None, '', None, None, 'fragment') |
|---|
| 521 |
|
|---|
| 522 |
def testSchemeFragment(self): |
|---|
| 523 |
'Authority Default: "scheme:#fragment"' |
|---|
| 524 |
uriStr = 'scheme:#fragment' |
|---|
| 525 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 526 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 527 |
self.verifyURIParts(uriValue, 'scheme', '', None, None, 'fragment') |
|---|
| 528 |
|
|---|
| 529 |
def testPathQuery(self): |
|---|
| 530 |
'Authority Default: "/path?query"' |
|---|
| 531 |
uriStr = '/path?query' |
|---|
| 532 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 533 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 534 |
self.verifyURIParts(uriValue, None, '', '/path', 'query', None) |
|---|
| 535 |
|
|---|
| 536 |
def testPathFragment(self): |
|---|
| 537 |
'Authority Default: "/path#fragment"' |
|---|
| 538 |
uriStr = '/path#fragment' |
|---|
| 539 |
uriValue = uri.URIAuthorityDefault(uriStr) |
|---|
| 540 |
self.failUnlessEqual(uriValue.uri, uriStr) |
|---|
| 541 |
self.verifyURIParts(uriValue, None, '', '/path', None, 'fragment') |
|---|
| 542 |
|
|---|
| 543 |
|
|---|
| 544 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 545 |
#~ Unittest Main |
|---|
| 546 |
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|---|
| 547 |
|
|---|
| 548 |
if __name__=='__main__': |
|---|
| 549 |
unittest.main() |
|---|
| 550 |
|
|---|