belyalov / tinyweb

Simple and lightweight HTTP async server for micropython
MIT License
247 stars 40 forks source link

Cleanup tests for MicroPython v1.13 #31

Closed timhughes closed 3 years ago

timhughes commented 3 years ago

Fixes #29 Looks like the code on this branch works fine with the new asyncio in 1.13. I have only done a minor cleanup of tests.

https://travis-ci.com/github/timhughes/tinyweb

I have added a script for a local CI using the unix port. You may not want it but it helps me iterate through errors rapidly - it only runs on Linux because it depends on inotify. Feel free to tell me to delete.

Tested on an ESP32 with MicroPython v1.13 using esp32-idf3-20200902-v1.13.bin

The following is the way i tested it which may be useful to add to CONTRIBUTING.txt

Copy files onto board

thughes@silicon [0] $ rshell -p /dev/ttyUSB0 rm -rf /pyboard/*
thughes@silicon [0] $ rshell -p /dev/ttyUSB0 mkdir /pyboard/lib
thughes@silicon [0] $ rshell -p /dev/ttyUSB0 cp lib/unittest.py /pyboard/lib/
thughes@silicon [0] $ rshell -p /dev/ttyUSB0 cp -r tinyweb test /pyboard/

Run Tests

thughes@silicon [0] $ pyboard --device /dev/ttyUSB0 -b 115200 -c 'import sys;from test.test_server import *; print("=== %s v%s on %s ===" % (sys.implementation[0], ".".join([str(c) for c in sys.implementation[1]]), sys.platform)); unittest.main();'
=== micropython v1.13.0 on esp32 ===
testUrldecode (Utils) ... ok
testParseQueryString (Utils) ... ok
testRequestLine (ServerParts) ... ok
testRequestLineEmptyLinesBefore (ServerParts) ... ok
testRequestLineNegative (ServerParts) ... ok
testHeadersSimple (ServerParts) ... ok
testHeadersSpaces (ServerParts) ... ok
testHeadersEmptyValue (ServerParts) ... ok
testHeadersMultiple (ServerParts) ... ok
testUrlFinderExplicit (ServerParts) ... ok
testUrlFinderParameterized (ServerParts) ... ok
testUrlFinderNegative (ServerParts) ... ok
testRouteDecorator1 (ServerFull) ... ok
testRouteDecorator2 (ServerFull) ... ok
testResourceDecorator1 (ServerFull) ... ok
testResourceDecorator2 (ServerFull) ... ok
testStartHTML (ServerFull) ... ok
testRedirect (ServerFull) ... ok
testRequestBodyUnknownType (ServerFull) ... ok
testRequestBodyJson (ServerFull) ... ok
testRequestBodyUrlencoded (ServerFull) ... ok
testRequestBodyNegative (ServerFull) ... ok
testRequestLargeBody (ServerFull) ... ok
testRouteParameterized (ServerFull) ... ok
testParseHeadersOnOff (ServerFull) ... ok
testDisallowedMethod (ServerFull) ... ok
testAutoOptionsMethod (ServerFull) ... ok
testPageNotFound (ServerFull) ... ok
testMalformedRequest (ServerFull) ... ok
testOptions (ServerResource) ... ok
testGet (ServerResource) ... ok
testGetWithParam (ServerResource) ... ok
testGetWithArgs (ServerResource) ... ok
testGenerator (ServerResource) ... ok
testPost (ServerResource) ... ok
testInvalidMethod (ServerResource) ... ok
testException (ServerResource) ...ERROR: something
 ok
testBrokenPipe (ServerResource) ... ok
testSendFileManual (StaticContent) ... ok
testSendFileNotFound (StaticContent) ... ok
testSendFileConnectionReset (StaticContent) ... ok
Ran 41 tests

OK
metachris commented 3 years ago

Is this PR still valid and has improvements?

I think everything already works now, and this might get closed 🤔

timhughes commented 3 years ago

Yeah feel free , there was nothing important from memory, just striping some things out