From 712ede22ec4eaf397dba32dc297ba9fd54356ee1 Mon Sep 17 00:00:00 2001 From: Elita Lobo Date: Sat, 28 Mar 2015 23:07:44 +0530 Subject: [PATCH] Test-E-k.py: Tests -E -k feature of Wget --- testenv/Test-E-k.py | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100755 testenv/Test-E-k.py diff --git a/testenv/Test-E-k.py b/testenv/Test-E-k.py new file mode 100755 index 0000000..e4cf729 --- /dev/null +++ b/testenv/Test-E-k.py @@ -0,0 +1,87 @@ +#!/usr/bin/env python3 +from sys import exit +from test.http_test import HTTPTest +from misc.wget_file import WgetFile + +""" + Tests if Wget appends suffix ".html" to files of type + "application/xhtml+xml" or "text/html" when downloaded + (specified by --adjust-extension or -E) and also checks + if it converts links in document to make them suitable + for local viewing (specified by --convert-links or -k). +""" + +TEST_NAME = "Test -E -k" +############# File Definitions ################################################ +mainpage = """ + + + Main Page Title + + + Secondary Page + + +""" +mainpagemangled = """ + + + Main Page Title + + + Secondary Page + + +""" + +subpage = """ + + + Secondary Page Title + + +

Some text

+ + +""" + +File_Rules = { + "SendHeader" : { + "Content-Type" : "text/html" + } +} + +A_File = WgetFile("index.php", mainpage, rules=File_Rules) +B_File = WgetFile("subpage.php", subpage, rules=File_Rules) +C_File = WgetFile("index.php.html", mainpagemangled) +D_File = WgetFile("subpage.php.html", subpage) + +WGET_OPTIONS = "-r -nd -E -k" +WGET_URLS = [["index.php"]] + +Files = [[A_File, B_File]] + +ExpectedReturnCode = 0 +ExpectedDownloadedFiles = [C_File, D_File] + +################### Pre and Post Test Hooks ############################### +pre_test = { + "ServerFiles" : Files +} +test_options = { + "WgetCommands" : WGET_OPTIONS, + "Urls" : WGET_URLS +} +post_test = { + "ExpectedFiles" : ExpectedDownloadedFiles, + "ExpectedRetcode" : ExpectedReturnCode +} + +err = HTTPTest ( + name=TEST_NAME, + pre_hook=pre_test, + test_params=test_options, + post_hook=post_test +).begin () + +exit(err) -- 2.1.4