File tree Expand file tree Collapse file tree 4 files changed +19
-3
lines changed
Expand file tree Collapse file tree 4 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -188,6 +188,8 @@ def base64_encode(string):
188188 Encodes data with MIME base64
189189 This encoding is designed to make binary data survive transport through transport layers that
190190 are not 8-bit clean, such as mail bodies.
191+ parameter: musst be bytes not str for python3 at least
192+ e.g. base64_encode(b"some string")
191193 .. versionadded:: 1.0.0
192194 """
193195 return base64 .b64encode (string )
@@ -196,6 +198,8 @@ def base64_encode(string):
196198def base64_decode (string ):
197199 """
198200 Decodes data encoded with MIME base64
201+ parameter: musst be bytes not str for python3 at least
202+ e.g. base64_decode(b"ZGFzIHN0aW5rdCB6dW0gSGltbWVs")
199203 .. versionadded:: 1.0.0
200204 """
201205 return base64 .b64decode (string )
Original file line number Diff line number Diff line change 11#! /bin/bash
22rm -rf .pytest_cache htmlcov tests/__pycache___
33py.test --cov-report html --cov=hexonet.apiconnector tests/
4+ # NOTE: this does not use the current repository
5+ # it uses the last released version's source code
6+ # maybe this can be reviewed - but not sure if this is possible
Original file line number Diff line number Diff line change @@ -70,4 +70,11 @@ def test_listresponse():
7070 assert response .nextpage () == None
7171 assert response .nextpagefirst () == None
7272 assert type (response .lastpagefirst ()) is float
73- assert response .lastpagefirst () == 9.0
73+ assert response .lastpagefirst () == 9.0
74+
75+ Response (response .as_hash ())
76+ # to cover isinstance dict check branch
77+
78+ response = Response (b"[RESPONSE]\r \n CODE=421\r \n DESCRIPTION=Command failed due to server error. Client should try again\r \n EOF\r \n " )
79+ assert response .is_tmp_error () == True
80+
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ def test_utilmethods():
1212 )
1313 response = api .call ({
1414 "COMMAND" : "QueryDomainPendingDeleteList" ,
15+ "ZONE" : ["COM" , "NET" ],
1516 "LIMIT" : 10 ,
1617 "FIRST" : 20
1718 })
@@ -38,6 +39,7 @@ def test_utilmethods():
3839 assert dec == "+"
3940
4041 # base64_encode / base64_decode
41- key = "das stinkt zum Himmel"
42+ key = b "das stinkt zum Himmel"
4243 enc = base64_encode (key )
43- assert enc == "wirklich"
44+ assert enc == b"ZGFzIHN0aW5rdCB6dW0gSGltbWVs"
45+ assert base64_decode (enc ) == key
You can’t perform that action at this time.
0 commit comments