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