From be0a0ba616eb7a413c92e25c8d7e86d8633972bc Mon Sep 17 00:00:00 2001 From: Darshit Shah Date: Sun, 22 Jun 2014 00:58:53 +0530 Subject: [PATCH] Test case showing User agent bug --- testenv/Test--UA.py | 112 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100755 testenv/Test--UA.py diff --git a/testenv/Test--UA.py b/testenv/Test--UA.py new file mode 100755 index 0000000..5f87f7e --- /dev/null +++ b/testenv/Test--UA.py @@ -0,0 +1,112 @@ +#!/usr/bin/env python3 +from sys import exit +from test.http_test import HTTPTest +from misc.wget_file import WgetFile + +""" + This test executed Wget in Spider mode with recursive retrieval. +""" +TEST_NAME = "Recursive Spider" +############# File Definitions ############################################### +mainpage = """ + + + Main Page + + +

+ Some text and a link to a second page. + Also, a broken link. +

+ + +""" + +robots = """ +# robots.txt generated at http://www.mcanerin.com +User-agent: wget +Disallow: secondpage.html +""" + +secondpage = """ + + + Second Page + + +

+ Some text and a link to a third page. + Also, a broken link. +

+ + +""" + +thirdpage = """ + + + Third Page + + +

+ Some text and a link to a text file. + Also, another broken link. +

+ + +""" + +dummyfile = "Don't care." + + +index_html = WgetFile ("index.html", mainpage) +secondpage_html = WgetFile ("secondpage.html", secondpage) +thirdpage_html = WgetFile ("thirdpage.html", thirdpage) +dummy_txt = WgetFile ("dummy.txt", dummyfile) +robots_txt = WgetFile ("robots.txt", robots) + +Request_List = [ + [ + "HEAD /", + "GET /", + "GET /robots.txt", + "HEAD /secondpage.html", + "GET /secondpage.html", + "HEAD /nonexistent", + "HEAD /thirdpage.html", + "GET /thirdpage.html", + "HEAD /dummy.txt", + "HEAD /againnonexistent" + ] +] + +WGET_OPTIONS = "-d --spider --user-agent='Test bot' -r" +WGET_URLS = [[""]] + +Files = [[index_html, secondpage_html, thirdpage_html, dummy_txt, robots_txt]] + +ExpectedReturnCode = 8 +ExpectedDownloadedFiles = [] + +################ Pre and Post Test Hooks ##################################### +pre_test = { + "ServerFiles" : Files +} +test_options = { + "WgetCommands" : WGET_OPTIONS, + "Urls" : WGET_URLS +} +post_test = { + "ExpectedFiles" : ExpectedDownloadedFiles, + "ExpectedRetcode" : ExpectedReturnCode, + "FilesCrawled" : Request_List +} + +err = HTTPTest ( + name=TEST_NAME, + pre_hook=pre_test, + test_params=test_options, + post_hook=post_test +).begin () + +exit (err) -- 2.0.0