1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-07-27 18:02:17 +03:00

fix device tests (#6861)

* help in makefile

* fix some device tests, http_server is pending

* fix webserver test, one test is disabled due to general python2->3 failure

* remove debug strings

* minimize diff

* set reset method back to the default one on generic board

* fix vcc range check from datasheet
vcc is read as 2.9V here, datasheet says 2.5-3.6, old low limit was 3v

* tell python to decode string
This commit is contained in:
david gauchard
2019-12-03 23:26:54 +01:00
committed by GitHub
parent 2309a1c9cb
commit ee24cffc5a
8 changed files with 56 additions and 32 deletions

View File

@ -4,18 +4,20 @@ from threading import Thread
from poster3.encode import MultipartParam
from poster3.encode import multipart_encode
from poster3.streaminghttp import register_openers
import sys
import urllib
def http_test(res, url, get=None, post=None):
response = ''
try:
if get:
url += '?' + urllib.urlencode(get)
url += '?' + urllib.parse.urlencode(get)
if post:
post = urllib.parse.quote(post)
post = bytes(urllib.parse.urlencode(post).encode('utf-8'))
request = urllib.request.urlopen(url, post, 2)
response = request.read()
except:
except Exception as e:
print('http_test: Exception: ', e, file=sys.stderr)
return 1
if response != res:
return 1
@ -51,23 +53,25 @@ def setup_http_getpost_params(e):
def teardown_http_getpost_params(e):
return 0
@setup('HTTP Upload')
def setup_http_upload(e):
def testRun():
response = ''
try:
register_openers()
p = MultipartParam("file", "0123456789abcdef", "test.txt", "text/plain; charset=utf8")
datagen, headers = multipart_encode( [("var4", "val with spaces"), p] )
request = urllib.request('http://etd.local/upload', datagen, headers)
response = urllib.request.urlopen(request, None, 2).read()
except:
return 1
if response != 'test.txt:16\nvar4 = val with spaces':
return 1
return 0
Thread(target=testRun).start()
@teardown('HTTP Upload')
def teardown_http_upload(e):
return 0
#@setup('HTTP Upload')
#def setup_http_upload(e):
# def testRun():
# response = ''
# try:
# register_openers()
# p = MultipartParam("file", "0123456789abcdef", "test.txt", "text/plain; charset=utf8")
# datagen, headers = multipart_encode( [("var4", "val with spaces"), p] )
# request = urllib.request.Request('http://etd.local/upload', datagen, headers)
# opener = urllib.request.build_opener()
# response = opener.open(request)
# except Exception as e:
# print('testRun: Exception: ', e, file=sys.stderr)
# return 1
# if response != 'test.txt:16\nvar4 = val with spaces':
# return 1
# return 0
# Thread(target=testRun).start()
#
#@teardown('HTTP Upload')
#def teardown_http_upload(e):
# return 0