| 1 |
#!/usr/bin/env python3 |
| 2 |
from sys import exit |
| 3 |
from test.http_test import HTTPTest |
| 4 |
from test.base_test import HTTP, HTTPS |
| 5 |
from misc.wget_file import WgetFile |
| 6 |
|
| 7 |
""" |
| 8 |
This is a Prototype Test File. |
| 9 |
Ideally this File should be copied and edited to write new tests. |
| 10 |
""" |
| 11 |
############# File Definitions ############################################### |
| 12 |
File2 = "Would you like some Tea?" |
| 13 |
|
| 14 |
File1_rules = { |
| 15 |
"Response" : 301, |
| 16 |
"SendHeader" : {"Location" : "/File2.txt"} |
| 17 |
} |
| 18 |
|
| 19 |
# /File1.txt is only a redirect, and so has no file content. |
| 20 |
File1_File = WgetFile ("File1.txt", "", rules=File1_rules) |
| 21 |
# File1_Retrieved is what will be retrieved for URL /File1.txt. |
| 22 |
File1_Retrieved = WgetFile ("File1.txt", File2) |
| 23 |
File2_File = WgetFile ("File2.txt", File2) |
| 24 |
|
| 25 |
WGET_OPTIONS = "" |
| 26 |
WGET_URLS = [["File1.txt"]] |
| 27 |
|
| 28 |
Servers = [HTTP] |
| 29 |
|
| 30 |
Files = [[File1_File, File2_File]] |
| 31 |
Existing_Files = [] |
| 32 |
|
| 33 |
ExpectedReturnCode = 0 |
| 34 |
ExpectedDownloadedFiles = [File1_Retrieved] |
| 35 |
|
| 36 |
################ Pre and Post Test Hooks ##################################### |
| 37 |
pre_test = { |
| 38 |
"ServerFiles" : Files, |
| 39 |
"LocalFiles" : Existing_Files |
| 40 |
} |
| 41 |
test_options = { |
| 42 |
"WgetCommands" : WGET_OPTIONS, |
| 43 |
"Urls" : WGET_URLS |
| 44 |
} |
| 45 |
post_test = { |
| 46 |
"ExpectedFiles" : ExpectedDownloadedFiles, |
| 47 |
"ExpectedRetcode" : ExpectedReturnCode |
| 48 |
} |
| 49 |
|
| 50 |
err = HTTPTest ( |
| 51 |
pre_hook=pre_test, |
| 52 |
test_params=test_options, |
| 53 |
post_hook=post_test, |
| 54 |
protocols=Servers |
| 55 |
).begin () |
| 56 |
|
| 57 |
exit (err) |