Debian Codegraph @

testenv/test_css_url.py

raw
1 #!/usr/bin/env python3
2
3 """Ensure that Wget correctly encodes url() parameters in CSS."""
4
5 from test.base_test import HTTP
6 from test.http_test import HTTPTest
7
8 from misc.wget_file import WgetFile
9
10 ############################## File Definitions ###############################
11 FILE1 = """<html>
12 <head>
13 <style>
14 body {
15 background-image: url(image%201.html);
16 }
17 </style>
18 </head>
19 <body>Hello</body>
20 </html>"""
21
22
23 FILE2 = "This is an image"
24
25 File1_File = WgetFile("index.html", FILE1)
26 File2_File = WgetFile("image 1.html", FILE2)
27 File2_ServerFile = WgetFile("image%201.html", FILE2)
28
29 WGET_OPTIONS = "--recursive --convert-links --no-host-directories"
30 WGET_URLS = [[""]]
31
32 Servers = [HTTP]
33
34 Files = [[File1_File, File2_ServerFile]]
35 Existing_Files = []
36
37 ExpectedReturnCode = 0
38 ExpectedDownloadedFiles = [File1_File, File2_File]
39 # Request_List = [["GET /",
40 # "GET /image 1.html"]]
41
42 ################ Pre and Post Test Hooks #####################################
43 pre_test = {
44 "ServerFiles" : Files,
45 "LocalFiles" : Existing_Files
46 }
47 test_options = {
48 "WgetCommands" : WGET_OPTIONS,
49 "Urls" : WGET_URLS
50 }
51 post_test = {
52 "ExpectedFiles" : ExpectedDownloadedFiles,
53 "ExpectedRetcode" : ExpectedReturnCode
54 }
55
56 err = HTTPTest (
57 pre_hook=pre_test,
58 test_params=test_options,
59 post_hook=post_test,
60 protocols=Servers
61 ).begin ()
62
63 exit (err)