11
11
path = "/testwifi/index.html"
12
12
text = b"This is a test of Adafruit WiFi!\r \n If you can read this, its working :)"
13
13
headers = b"HTTP/1.0 200 OK\r \n Transfer-Encoding: chunked\r \n \r \n "
14
+ headers_extra_space = b"HTTP/1.0 200 OK\r \n Transfer-Encoding: chunked\r \n \r \n "
14
15
15
16
16
17
def _chunk (response , split , extra = b"" ):
@@ -111,3 +112,33 @@ def test_close_flush():
111
112
112
113
def test_close_flush_extra ():
113
114
do_test_close_flush (b";blahblah; blah" )
115
+
116
+
117
+ def do_test_get_text_extra_space (extra = b"" ):
118
+ pool = mocket .MocketPool ()
119
+ pool .getaddrinfo .return_value = ((None , None , None , None , (ip , 80 )),)
120
+ c = _chunk (text , 33 , extra )
121
+ print (c )
122
+ sock = mocket .Mocket (headers_extra_space + c )
123
+ pool .socket .return_value = sock
124
+
125
+ s = adafruit_requests .Session (pool )
126
+ r = s .get ("http://" + host + path )
127
+
128
+ sock .connect .assert_called_once_with ((ip , 80 ))
129
+
130
+ sock .send .assert_has_calls (
131
+ [
132
+ mock .call (b"GET" ),
133
+ mock .call (b" /" ),
134
+ mock .call (b"testwifi/index.html" ),
135
+ mock .call (b" HTTP/1.1\r \n " ),
136
+ ]
137
+ )
138
+ sock .send .assert_has_calls (
139
+ [
140
+ mock .call (b"Host: " ),
141
+ mock .call (b"wifitest.adafruit.com" ),
142
+ ]
143
+ )
144
+ assert r .text == str (text , "utf-8" )
0 commit comments