2014-07-24 07:16:50 -04:00
|
|
|
from conf import hook
|
|
|
|
|
2014-08-08 01:54:08 -04:00
|
|
|
""" 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
|
2015-01-30 06:16:13 -05:00
|
|
|
contents. In the future, this can be used to add additional metadata to the
|
2014-08-08 01:54:08 -04:00
|
|
|
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. """
|
|
|
|
|
2014-07-24 07:16:50 -04:00
|
|
|
|
|
|
|
@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):
|
2015-01-30 06:16:13 -05:00
|
|
|
files_content = {f.name: test_obj._replace_substring(f.content)
|
2014-07-24 07:16:50 -04:00
|
|
|
for f in files}
|
2015-01-30 06:16:13 -05:00
|
|
|
files_rules = {f.name: test_obj.get_server_rules(f)
|
2014-07-24 07:16:50 -04:00
|
|
|
for f in files}
|
2015-01-30 06:16:13 -05:00
|
|
|
server.server_conf(files_content, files_rules)
|