Skip to content

Commit b300c9c

Browse files
committed
black
1 parent 176a94f commit b300c9c

File tree

5 files changed

+36
-14
lines changed

5 files changed

+36
-14
lines changed

tests/header_test.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
host = "httpbin.org"
88
response_headers = b"HTTP/1.0 200 OK\r\nContent-Length: 0\r\n\r\n"
99

10+
1011
def test_json():
1112
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)
1213
sock = mocket.Mocket(response_headers)

tests/mocket.py

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

99
interface = mock.MagicMock()
1010

11+
1112
class Mocket:
1213
def __init__(self, response):
1314
self.settimeout = mock.Mock()
@@ -21,12 +22,12 @@ def __init__(self, response):
2122

2223
def _readline(self):
2324
i = self._response.find(b"\r\n", self._position)
24-
r = self._response[self._position:i+2]
25+
r = self._response[self._position : i + 2]
2526
self._position = i + 2
2627
return r
2728

2829
def _recv(self, count):
2930
end = self._position + count
30-
r = self._response[self._position:end]
31+
r = self._response[self._position : end]
3132
self._position = end
3233
return r

tests/parse_test.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
host = "httpbin.org"
88
response = {"Date": "July 25, 2019"}
99
encoded = json.dumps(response).encode("utf-8")
10-
headers = "HTTP/1.0 200 OK\r\nContent-Length: {}\r\n\r\n".format(len(encoded)).encode("utf-8")
10+
headers = "HTTP/1.0 200 OK\r\nContent-Length: {}\r\n\r\n".format(len(encoded)).encode(
11+
"utf-8"
12+
)
13+
1114

1215
def test_json():
1316
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)

tests/post_test.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
host = "httpbin.org"
88
response = {}
99
encoded = json.dumps(response).encode("utf-8")
10-
headers = "HTTP/1.0 200 OK\r\nContent-Length: {}\r\n\r\n".format(len(encoded)).encode("utf-8")
10+
headers = "HTTP/1.0 200 OK\r\nContent-Length: {}\r\n\r\n".format(len(encoded)).encode(
11+
"utf-8"
12+
)
13+
1114

1215
def test_method():
1316
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)
@@ -17,8 +20,10 @@ def test_method():
1720
adafruit_requests.set_socket(mocket, mocket.interface)
1821
r = adafruit_requests.post("http://" + host + "/post")
1922
sock.connect.assert_called_once_with((ip, 80), mocket.interface.TCP_MODE)
20-
sock.send.assert_has_calls([mock.call(b'POST /post HTTP/1.0\r\n'),
21-
mock.call(b'Host: httpbin.org\r\n')])
23+
sock.send.assert_has_calls(
24+
[mock.call(b"POST /post HTTP/1.0\r\n"), mock.call(b"Host: httpbin.org\r\n")]
25+
)
26+
2227

2328
def test_string():
2429
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)
@@ -29,7 +34,8 @@ def test_string():
2934
data = "31F"
3035
r = adafruit_requests.post("http://" + host + "/post", data=data)
3136
sock.connect.assert_called_once_with((ip, 80), mocket.interface.TCP_MODE)
32-
sock.send.assert_called_with(b'31F')
37+
sock.send.assert_called_with(b"31F")
38+
3339

3440
def test_json():
3541
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)

tests/protocol_test.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,41 @@
88
text = b"This is a test of Adafruit WiFi!\r\nIf you can read this, its working :)"
99
response = b"HTTP/1.0 200 OK\r\nContent-Length: 70\r\n\r\n" + text
1010

11+
1112
def test_get_https_text():
12-
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip,80)),)
13+
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)
1314
sock = mocket.Mocket(response)
1415
mocket.socket.return_value = sock
1516

1617
adafruit_requests.set_socket(mocket, mocket.interface)
1718
r = adafruit_requests.get("https://" + host + path)
18-
19+
1920
sock.connect.assert_called_once_with((host, 443), mocket.interface.TLS_MODE)
20-
sock.send.assert_has_calls([mock.call(b'GET /testwifi/index.html HTTP/1.0\r\n'),
21-
mock.call(b'Host: wifitest.adafruit.com\r\n')])
21+
sock.send.assert_has_calls(
22+
[
23+
mock.call(b"GET /testwifi/index.html HTTP/1.0\r\n"),
24+
mock.call(b"Host: wifitest.adafruit.com\r\n"),
25+
]
26+
)
2227
assert r.text == str(text, "utf-8")
2328

29+
2430
def test_get_http_text():
25-
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip,80)),)
31+
mocket.getaddrinfo.return_value = ((None, None, None, None, (ip, 80)),)
2632
sock = mocket.Mocket(response)
2733
mocket.socket.return_value = sock
2834

2935
adafruit_requests.set_socket(mocket, mocket.interface)
3036
r = adafruit_requests.get("http://" + host + path)
3137

3238
sock.connect.assert_called_once_with((ip, 80), mocket.interface.TCP_MODE)
33-
sock.send.assert_has_calls([mock.call(b'GET /testwifi/index.html HTTP/1.0\r\n'),
34-
mock.call(b'Host: wifitest.adafruit.com\r\n')])
39+
sock.send.assert_has_calls(
40+
[
41+
mock.call(b"GET /testwifi/index.html HTTP/1.0\r\n"),
42+
mock.call(b"Host: wifitest.adafruit.com\r\n"),
43+
]
44+
)
3545
assert r.text == str(text, "utf-8")
3646

47+
3748
# Add a chunked response test when we support HTTP 1.1

0 commit comments

Comments
 (0)