| 1 |
#!/usr/bin/env python3 |
| 2 |
from sys import exit |
| 3 |
from test.http_test import HTTPTest |
| 4 |
from misc.wget_file import WgetFile |
| 5 |
|
| 6 |
""" |
| 7 |
This test ensures that Wget parses the Content-Disposition header |
| 8 |
correctly and creates the appropriate file when the said filename exists. |
| 9 |
""" |
| 10 |
############# File Definitions ############################################### |
| 11 |
File1 = "Teapot" |
| 12 |
File2 = "The Teapot Protocol" |
| 13 |
|
| 14 |
# use upper case 'I' to provoke Wget failure with turkish locale |
| 15 |
File2_rules = { |
| 16 |
"SendHeader" : { |
| 17 |
"Content-DIsposition" : "Attachment; FILENAME=HTTP.Teapot" |
| 18 |
} |
| 19 |
} |
| 20 |
A_File = WgetFile ("HTTP.Teapot", File1) |
| 21 |
B_File = WgetFile ("File2", File2, rules=File2_rules) |
| 22 |
|
| 23 |
WGET_OPTIONS = "--content-disposition" |
| 24 |
WGET_URLS = [["File2"]] |
| 25 |
|
| 26 |
Files = [[B_File]] |
| 27 |
Existing_Files = [A_File] |
| 28 |
|
| 29 |
ExpectedReturnCode = 0 |
| 30 |
ExpectedDownloadedFiles = [WgetFile ("HTTP.Teapot.1", File2), A_File] |
| 31 |
|
| 32 |
################ Pre and Post Test Hooks ##################################### |
| 33 |
pre_test = { |
| 34 |
"ServerFiles" : Files, |
| 35 |
"LocalFiles" : Existing_Files |
| 36 |
} |
| 37 |
test_options = { |
| 38 |
"WgetCommands" : WGET_OPTIONS, |
| 39 |
"Urls" : WGET_URLS |
| 40 |
} |
| 41 |
post_test = { |
| 42 |
"ExpectedFiles" : ExpectedDownloadedFiles, |
| 43 |
"ExpectedRetcode" : ExpectedReturnCode |
| 44 |
} |
| 45 |
|
| 46 |
err = HTTPTest ( |
| 47 |
pre_hook=pre_test, |
| 48 |
test_params=test_options, |
| 49 |
post_hook=post_test |
| 50 |
).begin () |
| 51 |
|
| 52 |
exit (err) |