summaryrefslogtreecommitdiffstats
path: root/testenv/test_css_url.py
blob: 1c1c8f8b5b3d1cf13b21a61ae92bd35125a7643d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3

"""Ensure that Wget correctly encodes url() parameters in CSS."""

from test.base_test import HTTP
from test.http_test import HTTPTest

from misc.wget_file import WgetFile

############################## File Definitions ###############################
FILE1 = """<html>
    <head>
<style>
body {
    background-image: url(image%201.html);
}
</style>
    </head>
    <body>Hello</body>
</html>"""


FILE2 = "This is an image"

File1_File = WgetFile("index.html", FILE1)
File2_File = WgetFile("image 1.html", FILE2)
File2_ServerFile = WgetFile("image%201.html", FILE2)

WGET_OPTIONS = "--recursive --convert-links --no-host-directories"
WGET_URLS = [[""]]

Servers = [HTTP]

Files = [[File1_File, File2_ServerFile]]
Existing_Files = []

ExpectedReturnCode = 0
ExpectedDownloadedFiles = [File1_File, File2_File]
# Request_List = [["GET /",
#                  "GET /image 1.html"]]

################ Pre and Post Test Hooks #####################################
pre_test = {
    "ServerFiles"       : Files,
    "LocalFiles"        : Existing_Files
}
test_options = {
    "WgetCommands"      : WGET_OPTIONS,
    "Urls"              : WGET_URLS
}
post_test = {
    "ExpectedFiles"     : ExpectedDownloadedFiles,
    "ExpectedRetcode"   : ExpectedReturnCode
}

err = HTTPTest (
                pre_hook=pre_test,
                test_params=test_options,
                post_hook=post_test,
                protocols=Servers
).begin ()

exit (err)