16
16
def test_set_400_error(self):
17
17
xml = "<Error><Code>1</Code><Message>2</Message></Error>"
18
error = S3Error("<dummy />")
18
error = S3Error("<dummy />", 400)
19
19
error._set_400_error(XML(xml))
20
20
self.assertEquals(error.errors[0]["Code"], "1")
21
21
self.assertEquals(error.errors[0]["Message"], "2")
23
23
def test_get_error_code(self):
24
error = S3Error(payload.sample_s3_invalid_access_key_result)
24
error = S3Error(payload.sample_s3_invalid_access_key_result, 400)
25
25
self.assertEquals(error.get_error_code(), "InvalidAccessKeyId")
27
27
def test_get_error_message(self):
28
error = S3Error(payload.sample_s3_invalid_access_key_result)
28
error = S3Error(payload.sample_s3_invalid_access_key_result, 400)
30
30
error.get_error_message(),
31
31
("The AWS Access Key Id you provided does not exist in our "
34
34
def test_error_count(self):
35
error = S3Error(payload.sample_s3_invalid_access_key_result)
35
error = S3Error(payload.sample_s3_invalid_access_key_result, 400)
36
36
self.assertEquals(len(error.errors), 1)
38
38
def test_error_repr(self):
39
error = S3Error(payload.sample_s3_invalid_access_key_result)
39
error = S3Error(payload.sample_s3_invalid_access_key_result, 400)
42
42
"<S3Error object with Error code: InvalidAccessKeyId>")
44
44
def test_signature_mismatch_result(self):
45
error = S3Error(payload.sample_s3_signature_mismatch)
45
error = S3Error(payload.sample_s3_signature_mismatch, 400)
47
error.get_error_messages(),
47
error.get_error_messages(),
48
48
("The request signature we calculated does not match the "
49
49
"signature you provided. Check your key and signing method."))
51
51
def test_invalid_access_key_result(self):
52
error = S3Error(payload.sample_s3_invalid_access_key_result)
52
error = S3Error(payload.sample_s3_invalid_access_key_result, 400)
54
54
error.get_error_messages(),
55
55
("The AWS Access Key Id you provided does not exist in our "
58
58
def test_internal_error_result(self):
59
error = S3Error(payload.sample_server_internal_error_result)
59
error = S3Error(payload.sample_server_internal_error_result, 400)
61
61
error.get_error_messages(),
62
62
"We encountered an internal error. Please try again.")