def test_make_exception(self): body = 'bad body' e = make_exception(self.__fake_response(400, body)) self.assertTrue(isinstance(e, oss2.exceptions.ServerError)) self.assertEqual(e.status, 400) self.assertEqual(e.body, oss2.to_bytes(body)) body = '<Error><Code>NoSuchKey</Code><Message>中文和控制字符</Message></Error>' e = make_exception(self.__fake_response(404, body)) self.assertTrue(isinstance(e, oss2.exceptions.NoSuchKey)) self.assertEqual(e.status, 404) self.assertEqual(e.code, 'NoSuchKey')
def test_make_exception(self): body = 'bad body' e = make_exception(self.__fake_response(400, body)) self.assertTrue(isinstance(e, oss2.exceptions.ServerError)) self.assertEqual(e.status, 400) self.assertEqual(e.body, oss2.to_bytes(body)) body = '<Error><Code>NoSuchKey</Code><Message>中文和控制字符</Message></Error>' e = make_exception(self.__fake_response(404, body)) self.assertTrue(isinstance(e, oss2.exceptions.NoSuchKey)) self.assertEqual(e.status, 404) self.assertEqual(e.code, 'NoSuchKey')