From 55b0bb821496f324f133283c8c7ba35c3a64ee63 Mon Sep 17 00:00:00 2001 From: Satyam Zode Date: Sun, 15 Mar 2015 02:35:06 +0530 Subject: [PATCH] Added wget http test for 503 Service unavailable --- testenv/Makefile.am | 1 + testenv/Test-503.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) mode change 100644 => 100755 testenv/Makefile.am create mode 100755 testenv/Test-503.py diff --git a/testenv/Makefile.am b/testenv/Makefile.am old mode 100644 new mode 100755 index a4e0352..5360eb6 --- a/testenv/Makefile.am +++ b/testenv/Makefile.am @@ -52,6 +52,7 @@ if HAVE_PYTHON3 Test-O.py \ Test-Post.py \ Test-504.py \ + Test-503.py \ Test--spider-r.py \ Test-redirect-crash.py diff --git a/testenv/Test-503.py b/testenv/Test-503.py new file mode 100755 index 0000000..21049ec --- /dev/null +++ b/testenv/Test-503.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python3 +from sys import exit +from test.http_test import HTTPTest +from misc.wget_file import WgetFile + +""" + This test ensures that Wget handles a 503 Service Unavailable response + correctly. +""" +TEST_NAME = "503 Service Unavailable" +############# File Definitions ############################################### +File1 = """ You have to learn the rules of the game. And then you have to play better than anyone else. - Albert Einstein""" + + +File1_rules = { + + "Response" : 503 +} + +A_File = WgetFile ("File1", File1, rules=File1_rules) + +Request_List = [ + [ + "GET /File1" + + ] +] + + +WGET_OPTIONS = " " +WGET_URLS = [["File1"]] + +Files = [[A_File]] + +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) -- 1.9.1