| 1 |
from misc.colour_terminal import print_red |
| 2 |
from conf import hook |
| 3 |
from exc.test_failed import TestFailed |
| 4 |
|
| 5 |
""" Post-Test Hook: FilesCrawled |
| 6 |
This is a post test hook that is invoked in tests that check wget's behaviour |
| 7 |
in recursive mode. It expects an ordered list of the request lines that Wget |
| 8 |
must send to the server. If the requests received by the server do not match |
| 9 |
the provided list, IN THE GIVEN ORDER, then it raises a TestFailed exception. |
| 10 |
Such a test can be used to check the implementation of the recursion algorithm |
| 11 |
in Wget too. |
| 12 |
""" |
| 13 |
|
| 14 |
|
| 15 |
@hook() |
| 16 |
class 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.') |