Commit db13f180 authored by Yijie Deng's avatar Yijie Deng
Browse files

made weekly CICD a constant

parent af9a4c83
Tests for WBE Chapter 1
=======================
Test support for HTTP/1.1 `Transfer-Encoding: chunked`
Here's the testing boilerplate.
>>> import test
>>> _ = test.socket.patch().start()
>>> _ = test.ssl.patch().start()
>>> import browser
Testing `Transfer-Encoding: chunked` support
-----------------
To test it, we simulate a `chunked` response with `body_text_chunks`
>>> url = 'http://test.test/example1'
>>> body_text = ""
>>> body_text_chunks = ["this\n", "body is\n", "chunked!😈\n"]
>>> for chunk in body_text_chunks:
... body_text += hex(len(chunk.encode())).split('x')[-1] + "\r\n" + chunk + "\r\n"
>>> body_text += hex(0).split('x')[-1] + "\r\n" + "" + "\r\n"
>>> test.socket.respond(url=url,
... response=("HTTP/1.1 200 OK\r\n" +
... "Header1: Value1\r\n" +
... "Transfer-Encoding: chunked\r\n" +
... "\r\n" +
... body_text).encode())
And check that the browser parsed the response properly:
>>> response_headers, response_body = browser.request(url)
>>> command, path, version, headers = test.socket.parse_last_request(url)
>>> version in {"HTTP/1.1"}
True
>>> response_body
'this\nbody is\nchunked!😈\n'
\ No newline at end of file
......@@ -9,13 +9,15 @@ import re
sys.path.append(os.getcwd())
DEFAULT_CICD = "chapter3"
CURRENT_TESTS = {
"chapter1": ["chapter1-base-tests.md",
"chapter1-exercise-http-1-1-tests.md",
"chapter1-exercise-file-urls-tests.md",
"chapter1-exercise-redirects-tests.md",
"chapter1-exercise-caching-tests.md",
"chapter1-binary-tests.md",
# "chapter1-binary-tests.md",
],
"chapter2": ["chapter2-base-tests.md",
"chapter2-exercise-line-breaks-tests.md",
......@@ -199,7 +201,7 @@ def parse_arguments(argv):
parser = argparse.ArgumentParser(description='WBE test runner')
parser.add_argument("chapter",
nargs="?",
default="chapter3",
default=DEFAULT_CICD,
choices=list(CURRENT_TESTS),
help="Which chapter's tests to run")
parser.add_argument("--index",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment