1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00
wget/testenv/conf/server_files.py
Darshit Shah 8e0dd0d870 PEP8'ify the Python Test Suite
* testenv/conf/{__init__,authentication,files_crawled,
      hook_sample,reject_header,server_files}.py: Aesthetic changes to
      meet Python PEP8 guidelines
    * testenv/exc/{server_error,test_failed}.py: Same
    * testenv/misc/{colour_terminal,wget_file}.py: Same
    * testenv/server/http/http_server.py: Same
    * testenv/test/base_test.py: Same
2015-04-14 10:59:17 +05:30

27 lines
1.1 KiB
Python

from conf import hook
""" Pre-Test Hook: ServerFiles
This hook is used to define a set of files on the server's virtual filesystem.
server_files is expected to be dictionary that maps filenames to their
contents. In the future, this can be used to add additional metadata to the
files using the WgetFile class too.
This hook also does some additional processing on the contents of the file. Any
text between {{and}} is replaced by the contents of a class variable of the
same name. This is useful in creating files that contain an absolute link to
another file on the same server. """
@hook()
class ServerFiles:
def __init__(self, server_files):
self.server_files = server_files
def __call__(self, test_obj):
for server, files in zip(test_obj.servers, self.server_files):
files_content = {f.name: test_obj._replace_substring(f.content)
for f in files}
files_rules = {f.name: test_obj.get_server_rules(f)
for f in files}
server.server_conf(files_content, files_rules)