@@ 1018-1029 (lines=12) @@ | ||
1015 | def test_exception_on_403(self): |
|
1016 | """Exception if 403 forbidden.""" |
|
1017 | path_to_mock = 'passwords.json' |
|
1018 | request_url = api_url + path_to_mock |
|
1019 | exception_error = "{} forbidden".format(request_url) |
|
1020 | with self.assertRaises(tpm.TPMException) as context: |
|
1021 | with requests_mock.Mocker() as m: |
|
1022 | m.get(request_url, text='forbidden', status_code=403) |
|
1023 | response = self.client.list_passwords() |
|
1024 | log.debug("context exception: {}".format(context.exception)) |
|
1025 | self.assertTrue(exception_error in str(context.exception)) |
|
1026 | ||
1027 | def test_exception_on_404(self): |
|
1028 | """Exception if 404 not found.""" |
|
1029 | path_to_mock = 'passwords.json' |
|
1030 | request_url = api_url + path_to_mock |
|
1031 | exception_error = "{} not found".format(request_url) |
|
1032 | with self.assertRaises(tpm.TPMException) as context: |
|
@@ 1055-1065 (lines=11) @@ | ||
1052 | ||
1051 | ||
1050 | ||
@@ 1043-1053 (lines=11) @@ | ||
1040 | """Exception if 405 Method Not Allowed.""" |
|
1041 | path_to_mock = 'passwords.json' |
|
1042 | request_url = api_url + path_to_mock |
|
1043 | exception_error = "{} Method Not Allowed".format(request_url) |
|
1044 | with self.assertRaises(ValueError) as context: |
|
1045 | with requests_mock.Mocker() as m: |
|
1046 | m.get(request_url, text='Method Not Allowed', status_code=405) |
|
1047 | response = self.client.list_passwords() |
|
1048 | log.debug("context exception: {}".format(context.exception)) |
|
1049 | self.assertTrue(str(context.exception).endswith(exception_error)) |
|
1050 |