Debian Codegraph @

testenv/conf/server_files.py

raw
1 from conf import hook
2
3 """ Pre-Test Hook: ServerFiles
4 This hook is used to define a set of files on the server's virtual file system.
5 server_files is expected to be dictionary that maps filenames to their
6 contents. In the future, this can be used to add additional metadata to the
7 files using the WgetFile class too.
8
9 This hook also does some additional processing on the contents of the file. Any
10 text between {{and}} is replaced by the contents of a class variable of the
11 same name. This is useful in creating files that contain an absolute link to
12 another file on the same server. """
13
14
15 @hook()
16 class 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 files_content = {f.name: test_obj._replace_substring(f.content)
23 for f in files}
24 files_rules = {f.name: test_obj.get_server_rules(f)
25 for f in files}
26 server.server_conf(files_content, files_rules)