1from conf import hook 2 3""" Pre-Test Hook: ServerFiles 4This hook is used to define a set of files on the server's virtual filesystem. 5server_files is expected to be dictionary that maps filenames to their 6contents. In the future, this can be used to add additional metadat to the 7files using the WgetFile class too. 8 9This hook also does some additional processing on the contents of the file. Any 10text between {{and}} is replaced by the contents of a class variable of the 11same name. This is useful in creating files that contain an absolute link to 12another file on the same server. """ 13 14 15@hook() 16class ServerFiles: 17 def __init__(self, server_files): 18 self.server_files = server_files 19 20 def __call__(self, test_obj): 21 for server, files in zip(test_obj.servers, self.server_files): 22 rules = {f.name: test_obj.get_server_rules(f) 23 for f in files} 24 files = {f.name: test_obj._replace_substring(f.content) 25 for f in files} 26 server.server_conf(files, rules) 27