Revision f93cc364 snf-astakos-client/astakosclient/tests.py
b/snf-astakos-client/astakosclient/tests.py | ||
---|---|---|
45 | 45 |
import simplejson |
46 | 46 |
|
47 | 47 |
import astakosclient |
48 |
from astakosclient import AstakosClient, AstakosClientException, \ |
|
49 |
AstakosClientEInvalid, AstakosClientEMethod, AstakosClientENotFound |
|
48 |
from astakosclient import AstakosClient |
|
49 |
from astakosclient.errors import \ |
|
50 |
AstakosClientException, Unauthorized, BadRequest, NotFound |
|
50 | 51 |
|
51 | 52 |
# Use backported unittest functionality if Python < 2.7 |
52 | 53 |
try: |
... | ... | |
296 | 297 |
try: |
297 | 298 |
client = AstakosClient("https://example.com", use_pool=pool) |
298 | 299 |
client._callAstakos(token, "/im/authenticate") |
299 |
except AstakosClientEInvalid:
|
|
300 |
except Unauthorized:
|
|
300 | 301 |
pass |
301 | 302 |
except Exception: |
302 | 303 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)") |
... | ... | |
319 | 320 |
try: |
320 | 321 |
client = AstakosClient("https://example.com", use_pool=pool) |
321 | 322 |
client._callAstakos(token_1, "/im/misspelled") |
322 |
except AstakosClientENotFound:
|
|
323 |
except NotFound: |
|
323 | 324 |
pass |
324 | 325 |
except Exception: |
325 | 326 |
self.fail("Should have returned 404 (Not Found)") |
... | ... | |
387 | 388 |
try: |
388 | 389 |
client = AstakosClient("https://example.com", use_pool=pool) |
389 | 390 |
client._callAstakos(token_1, "/im/authenticate", method="POST") |
390 |
except AstakosClientEMethod:
|
|
391 |
except BadRequest:
|
|
391 | 392 |
pass |
392 | 393 |
except Exception: |
393 | 394 |
self.fail("Should have returned 400 (Method not allowed)") |
... | ... | |
410 | 411 |
try: |
411 | 412 |
client = AstakosClient("https://example.com", use_pool=pool) |
412 | 413 |
client._callAstakos(token_1, "/user_catalogs") |
413 |
except AstakosClientEMethod:
|
|
414 |
except BadRequest:
|
|
414 | 415 |
pass |
415 | 416 |
except Exception: |
416 | 417 |
self.fail("Should have returned 400 (Method not allowed)") |
... | ... | |
451 | 452 |
try: |
452 | 453 |
client = AstakosClient("https://example.com", use_pool=pool) |
453 | 454 |
client.authenticate(token) |
454 |
except AstakosClientEInvalid:
|
|
455 |
except Unauthorized:
|
|
455 | 456 |
pass |
456 | 457 |
except Exception: |
457 | 458 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)") |
... | ... | |
538 | 539 |
try: |
539 | 540 |
client = AstakosClient("https://example.com") |
540 | 541 |
client.getDisplayNames(token, [user_1['uuid']]) |
541 |
except AstakosClientEInvalid:
|
|
542 |
except Unauthorized:
|
|
542 | 543 |
pass |
543 | 544 |
except Exception: |
544 | 545 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)") |
... | ... | |
588 | 589 |
try: |
589 | 590 |
client = AstakosClient("https://example.com") |
590 | 591 |
client.getUUIDs(token, [user_1['username']]) |
591 |
except AstakosClientEInvalid:
|
|
592 |
except Unauthorized:
|
|
592 | 593 |
pass |
593 | 594 |
except Exception: |
594 | 595 |
self.fail("Should have returned 401 (Invalid X-Auth-Token)") |
Also available in: Unified diff