Debian Codegraph @

testenv/Test-Content-disposition.py

raw
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 a local file accordingly.
9 """
10 ############# File Definitions ###############################################
11 File1 = """All that is gold does not glitter,
12 Not all those who wander are lost;
13 The old that is strong does not wither,
14 Deep roots are not reached by the frost.
15 From the ashes a fire shall be woken,
16 A light from the shadows shall spring;
17 Renewed shall be blade that was broken,
18 The crownless again shall be king."""
19
20 File1_rules = {
21 "SendHeader" : {
22 "Content-Disposition" : "Attachment; filename=JRR.Tolkien"
23 }
24 }
25 A_File = WgetFile ("LOTR", File1, rules=File1_rules)
26
27 WGET_OPTIONS = "--content-disposition"
28 WGET_URLS = [["LOTR"]]
29
30 Files = [[A_File]]
31
32 ExpectedReturnCode = 0
33 ExpectedDownloadedFiles = [WgetFile ("JRR.Tolkien", File1)]
34
35 ################ Pre and Post Test Hooks #####################################
36 pre_test = {
37 "ServerFiles" : Files
38 }
39 test_options = {
40 "WgetCommands" : WGET_OPTIONS,
41 "Urls" : WGET_URLS
42 }
43 post_test = {
44 "ExpectedFiles" : ExpectedDownloadedFiles,
45 "ExpectedRetcode" : ExpectedReturnCode
46 }
47
48 err = HTTPTest (
49 pre_hook=pre_test,
50 test_params=test_options,
51 post_hook=post_test
52 ).begin ()
53
54 exit (err)