Skip to content

Commit cab6e38

Browse files
authored
auto release for 0.9.2
auto incr version
1 parent 5799b26 commit cab6e38

File tree

7 files changed

+54
-13
lines changed

7 files changed

+54
-13
lines changed

CHANGELOG.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
## 0.9.2 (2020-07-31)
2+
3+
ENHANCEMENTS:
4+
5+
- Improve testing with `requests_mock`
6+
- Add `InvalidResponseException` and `HTTPStatusException`
7+
- Add `request_uuid` to response and exception logging
8+
- Add default exception middileware
9+
- Change documentation url
10+
- Update all APIs of `UCloudStack`
11+
12+
BUG FIXES:
13+
14+
- Fix `pytest` version compatible
15+
116
## 0.9.1 (2020-06-05)
217

318
ENHANCEMENTS:

examples/auth/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ def main():
66
"ucloudsomeone@example.com1296235120854146120",
77
"46f09bb9fab4f12dfc160dae12273d5332b5debe",
88
)
9-
d = {'Action': 'DescribeUHostInstance', 'Region': 'cn-bj2', 'Limit': 10}
9+
d = {"Action": "DescribeUHostInstance", "Region": "cn-bj2", "Limit": 10}
1010
print(cred.verify_ac(d))
1111

1212

13-
if __name__ == '__main__':
13+
if __name__ == "__main__":
1414
main()

tests/test_unit/test_core/test_client.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,22 +38,34 @@ def transport():
3838
def test_client_invoke(client):
3939
expected = {"RetCode": 0, "Action": "Foo"}
4040
with requests_mock.Mocker() as m:
41-
m.post(consts.TEST_URL, text=json.dumps(expected), headers={http.REQUEST_UUID_HEADER_KEY: str(uuid.uuid4())})
41+
m.post(
42+
consts.TEST_URL,
43+
text=json.dumps(expected),
44+
headers={http.REQUEST_UUID_HEADER_KEY: str(uuid.uuid4())},
45+
)
4246
assert client.invoke("Foo") == expected
4347

4448

4549
def test_client_invoke_code_error(client):
4650
expected = {"RetCode": 171, "Action": "Foo", "Message": "签名错误"}
4751

4852
with requests_mock.Mocker() as m:
49-
m.post(consts.TEST_URL, text=json.dumps(expected), headers={http.REQUEST_UUID_HEADER_KEY: str(uuid.uuid4())})
53+
m.post(
54+
consts.TEST_URL,
55+
text=json.dumps(expected),
56+
headers={http.REQUEST_UUID_HEADER_KEY: str(uuid.uuid4())},
57+
)
5058

5159
with pytest.raises(exc.RetCodeException):
5260
try:
5361
client.invoke("Foo")
5462
except exc.RetCodeException as e:
5563
assert e.retryable is False
56-
assert e.json() == {"RetCode": 171, "Action": "Foo", "Message": "签名错误"}
64+
assert e.json() == {
65+
"RetCode": 171,
66+
"Action": "Foo",
67+
"Message": "签名错误",
68+
}
5769
raise e
5870

5971

tests/test_unit/test_core/test_transport.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88

99
from tests.test_unit.test_core.consts import TEST_URL
1010
from ucloud.core import exc
11-
from ucloud.core.transport import RequestsTransport, Request, Response, utils, http
11+
from ucloud.core.transport import (
12+
RequestsTransport,
13+
Request,
14+
Response,
15+
utils,
16+
http,
17+
)
1218

1319
logger = logging.getLogger(__name__)
1420

@@ -78,8 +84,12 @@ def exception_handler(r):
7884

7985
with requests_mock.Mocker() as m:
8086
request_uuid = str(uuid.uuid4())
81-
m.post(TEST_URL, text=json.dumps(expect), status_code=200,
82-
headers={http.REQUEST_UUID_HEADER_KEY: request_uuid})
87+
m.post(
88+
TEST_URL,
89+
text=json.dumps(expect),
90+
status_code=200,
91+
headers={http.REQUEST_UUID_HEADER_KEY: request_uuid},
92+
)
8393
resp = transport.send(req)
8494
assert resp.text
8595
assert resp.json() == expect

ucloud/core/client/_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def logged_response_handler(self, resp, http_resp: http.Response = None):
7777
action = resp.get("Action", "")
7878
request_uuid = http_resp and http_resp.request_uuid
7979
self.logger.info(
80-
"[response] [{}] {} {}".format(request_uuid or '*', action, resp)
80+
"[response] [{}] {} {}".format(request_uuid or "*", action, resp)
8181
)
8282
return resp
8383

ucloud/core/exc/_exc.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def retryable(self):
2727

2828
def __str__(self):
2929
return "[{uuid}] {self.status_code} http status error".format(
30-
self=self, uuid=self.request_uuid or '*'
30+
self=self, uuid=self.request_uuid or "*"
3131
)
3232

3333

@@ -42,7 +42,9 @@ def retryable(self):
4242
return False
4343

4444
def __str__(self):
45-
return "[{uuid}] {self.message}: {self.content}".format(self=self, uuid=self.request_uuid or '*')
45+
return "[{uuid}] {self.message}: {self.content}".format(
46+
self=self, uuid=self.request_uuid or "*"
47+
)
4648

4749

4850
class RetCodeException(UCloudException):
@@ -59,7 +61,9 @@ def retryable(self):
5961
return self.code > MAX_COMMON_RET_CODE
6062

6163
def __str__(self):
62-
return "[{uuid}] {self.action} - {self.code}: {self.message}".format(self=self, uuid=self.request_uuid or '*')
64+
return "[{uuid}] {self.action} - {self.code}: {self.message}".format(
65+
self=self, uuid=self.request_uuid or "*"
66+
)
6367

6468
def json(self):
6569
return {

ucloud/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.9.1"
1+
version = "0.9.2"

0 commit comments

Comments
 (0)