1from misc.colour_terminal import print_red 2from conf import hook 3from exc.test_failed import TestFailed 4 5""" Post-Test Hook: FilesCrawled 6This is a post test hook that is invoked in tests that check wget's behaviour 7in recursive mode. It expects an ordered list of the request lines that Wget 8must send to the server. If the requests received by the server do not match 9the provided list, IN THE GIVEN ORDER, then it raises a TestFailed exception. 10Such a test can be used to check the implementation of the recursion algorithm 11in Wget too. 12""" 13 14 15@hook() 16class FilesCrawled: 17 def __init__(self, request_headers): 18 self.request_headers = request_headers 19 20 def __call__(self, test_obj): 21 for headers, remaining in zip(map(set, self.request_headers), 22 test_obj.request_remaining()): 23 diff = headers.symmetric_difference(remaining) 24 25 if diff: 26 print_red (str(diff)) 27 raise TestFailed('Not all files were crawled correctly.') 28