Darshit Shah <[email protected]> writes: > Ugh. Missed adding a file to the commit. Here's an updated patch > > > On Fri, Aug 8, 2014 at 11:27 AM, Darshit Shah <[email protected]> wrote: >> Hi, >> >> I've spent some time cleaning up the test suite and adding some extra >> documentation so that it is easier for others to add new tests. >> Attaching a patch which adds docstrings and fixes quite a few >> indentation issues in the test suite code. I'll probably take some >> time out and add new tests soon. >> >> -- >> Thanking You, >> Darshit Shah > > > > -- > Thanking You, > Darshit Shah > > From f1caf2f74c19ff561495ad50ab78cc4a312edab2 Mon Sep 17 00:00:00 2001 > From: Darshit Shah <[email protected]> > Date: Fri, 8 Aug 2014 11:24:08 +0530 > Subject: [PATCH] Documentation and code cleanup in test suite > > Add (lots) of documentation for various parts of the test suite in the > form of Python docstrings. Also, clean up some of the redundant code and > fix indentation issues. > --- > testenv/ChangeLog | 37 ++++++++ > testenv/conf/__init__.py | 1 + > testenv/conf/authentication.py | 13 +++ > testenv/conf/expect_header.py | 5 + > testenv/conf/expected_files.py | 11 ++- > testenv/conf/expected_ret_code.py | 8 ++ > testenv/conf/files_crawled.py | 9 ++ > testenv/conf/hook_sample.py | 9 +- > testenv/conf/local_files.py | 6 ++ > testenv/conf/reject_header.py | 6 ++ > testenv/conf/response.py | 4 + > testenv/conf/send_header.py | 5 + > testenv/conf/server_files.py | 11 +++ > testenv/conf/urls.py | 4 + > testenv/conf/wget_commands.py | 5 + > testenv/exc/server_error.py | 7 ++ > testenv/misc/colour_terminal.py | 43 ++++++--- > testenv/server/http/http_server.py | 190 > +++++++++++++++++++------------------ > testenv/test/base_test.py | 6 +- > testenv/test/http_test.py | 7 +- > 20 files changed, 275 insertions(+), 112 deletions(-) > create mode 100644 testenv/exc/server_error.py > > diff --git a/testenv/ChangeLog b/testenv/ChangeLog > index 64d75af..0149368 100644 > --- a/testenv/ChangeLog > +++ b/testenv/ChangeLog > @@ -1,3 +1,40 @@ > +2014-08-08 Darshit Shah <[email protected]> > + > + * conf/__init__.py: Add extra newline according to PEP8 > + * conf/{authentication,expect_header,expected_files,expected_ret_code, > + > files_crawled,hook_sample,local_files,reject_header,response,send_header, > + server_files,urls,wget_commands}.py: Add docstrings explaining the conf > file > + and how it should be used > + * server/http/http_server (InvalidRangeHeader): Clear TODO and eliminate > + this exception. Use ServerError for all such purposes. > + (_Handler): Remove reference to InvalidRangeHeader > + (_handler.parse_range_header): User ServerError instead of > InvalidRangeHeader > + (_Handler.do_GET): Add docstring > + (_Handler.do_POST): Add docstring. Also create an empty dict for rules > if > + no rules are supplied. Send the Location header as suggested in RFC 7231 > + (_Handler.do_PUT): Don't pop the server file already. Push it to later > in .. > + (_Handler.send_put): .. Here. If the file exists respond with a 204 No > + Content message and pop the file for replacement. Do not send the > + Content-Length, Content-Type headers since PUT requests should not > respond > + with data. > + (_Handler.parse_auth_header): Fit line within 80 chars > + (_Handler.check_response): Better visual indent > + (_Handler.authorize_digest): Better visual indent. > + (_Handler.expect_headers): Remove unused function > + (_Handler.guess_type): Fix indentation > + (HTTPd): Add newline according to PEP8 guidelines > + (HTTPSd): Fix indentation > + (StoppableHTTPServer): Add docstring > + (HTTPSServer): Fix indentation > + (WgetHTTPRequestHandler): Merge class into _handler. > + (_Handler): Add docstring > + (_Handler.parse_range_header): Fix indentation > + (ServerError): Split exception into separate file ... > + * exc/server_error.py: ... Here > + * misc/colour_terminal.py: Add docstring, fix indentation > + * test/base_test.py: Fix visual indent > + * test/http_test.py: Fit within 80 char lines > + > 2014-08-04 Darshit Shah <[email protected]> > > * conf/server_conf.py: Delete file. Server configuration is now done > via the > diff --git a/testenv/conf/__init__.py b/testenv/conf/__init__.py > index 156e9b6..603bd62 100644 > --- a/testenv/conf/__init__.py > +++ b/testenv/conf/__init__.py > @@ -3,6 +3,7 @@ import os > # this file implements the mechanism of conf class auto-registration, > # don't modify this file if you have no idea what you're doing > > + > def gen_hook(): > hook_table = {} > > diff --git a/testenv/conf/authentication.py b/testenv/conf/authentication.py > index 58cbaff..9932d93 100644 > --- a/testenv/conf/authentication.py > +++ b/testenv/conf/authentication.py > @@ -1,5 +1,18 @@ > from conf import rule > > +""" Rule: Authentication > +This file defines an authentication rule which when applied to any file will > +cause the server to prompt the client for the required authentication details > +before serving it. > +auth_type must be either of: Basic, Digest, Both or Both-inline > +When auth_type is Basic or Digest, the server asks for the respective > +authentication in its response. When auth_type is Both, the server sends two > +Authenticate headers, one requesting Basic and the other requesting Digest > +authentication. If auth_type is Both-inline, the the server sends only one
duplicated "the". Seems fine, feel free to push with the small change. Thanks, Giuseppe
