[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug-wget] [GSoC PATCH 07/11] create package test for test case classes
From: |
Zihang Chen |
Subject: |
[Bug-wget] [GSoC PATCH 07/11] create package test for test case classes |
Date: |
Fri, 14 Mar 2014 21:18:23 +0800 |
delete mode 100644 testenv/WgetTest.py
create mode 100644 testenv/test/__init__.py
create mode 100644 testenv/test/base_test.py
create mode 100644 testenv/test/http_test.py
diff --git a/testenv/Test--https.py b/testenv/Test--https.py
index 066f2d9..81196b5 100755
--- a/testenv/Test--https.py
+++ b/testenv/Test--https.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest, HTTPS, HTTP
+from test.http_test import HTTPTest
+from misc.constants import HTTP, HTTPS
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test--spider-r.py b/testenv/Test--spider-r.py
index c099f5a..df023d3 100755
--- a/testenv/Test--spider-r.py
+++ b/testenv/Test--spider-r.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-Content-disposition-2.py
b/testenv/Test-Content-disposition-2.py
index 423ea27..3bf4940 100755
--- a/testenv/Test-Content-disposition-2.py
+++ b/testenv/Test-Content-disposition-2.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-Content-disposition.py
b/testenv/Test-Content-disposition.py
index 45914b2..ce24599 100755
--- a/testenv/Test-Content-disposition.py
+++ b/testenv/Test-Content-disposition.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-Head.py b/testenv/Test-Head.py
index d0fad75..e356252 100755
--- a/testenv/Test-Head.py
+++ b/testenv/Test-Head.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-O.py b/testenv/Test-O.py
index 4b3c26a..784a229 100755
--- a/testenv/Test-O.py
+++ b/testenv/Test-O.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-Parallel-Proto.py b/testenv/Test-Parallel-Proto.py
index 6e09bfb..9719712 100755
--- a/testenv/Test-Parallel-Proto.py
+++ b/testenv/Test-Parallel-Proto.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest, HTTP, HTTPS
+from test.http_test import HTTPTest
+from misc.constants import HTTP, HTTPS
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-Post.py b/testenv/Test-Post.py
index d7ad616..8983454 100755
--- a/testenv/Test-Post.py
+++ b/testenv/Test-Post.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-Proto.py b/testenv/Test-Proto.py
index 90fca8b..650f43c 100755
--- a/testenv/Test-Proto.py
+++ b/testenv/Test-Proto.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest, HTTP, HTTPS
+from test.http_test import HTTPTest
+from misc.constants import HTTP, HTTPS
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-basic-fail.py b/testenv/Test-auth-basic-fail.py
index e2890d5..263f756 100755
--- a/testenv/Test-auth-basic-fail.py
+++ b/testenv/Test-auth-basic-fail.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-basic.py b/testenv/Test-auth-basic.py
index 2cafa40..102bf8c 100755
--- a/testenv/Test-auth-basic.py
+++ b/testenv/Test-auth-basic.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-both.py b/testenv/Test-auth-both.py
index 214ef0e..2da2840 100755
--- a/testenv/Test-auth-both.py
+++ b/testenv/Test-auth-both.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-digest.py b/testenv/Test-auth-digest.py
index 44e261f..f6d28c7 100755
--- a/testenv/Test-auth-digest.py
+++ b/testenv/Test-auth-digest.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-no-challenge-url.py
b/testenv/Test-auth-no-challenge-url.py
index e0f851f..c39ebaa 100755
--- a/testenv/Test-auth-no-challenge-url.py
+++ b/testenv/Test-auth-no-challenge-url.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-no-challenge.py
b/testenv/Test-auth-no-challenge.py
index 1d0e355..f02c030 100755
--- a/testenv/Test-auth-no-challenge.py
+++ b/testenv/Test-auth-no-challenge.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-retcode.py b/testenv/Test-auth-retcode.py
index 5619f9f..8719bd0 100755
--- a/testenv/Test-auth-retcode.py
+++ b/testenv/Test-auth-retcode.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-auth-with-content-disposition.py
b/testenv/Test-auth-with-content-disposition.py
index a28b088..f74a959 100755
--- a/testenv/Test-auth-with-content-disposition.py
+++ b/testenv/Test-auth-with-content-disposition.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-c-full.py b/testenv/Test-c-full.py
index 5b035fd..3cdcd76 100755
--- a/testenv/Test-c-full.py
+++ b/testenv/Test-c-full.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-cookie-401.py b/testenv/Test-cookie-401.py
index 3161d1d..9488c34 100755
--- a/testenv/Test-cookie-401.py
+++ b/testenv/Test-cookie-401.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-cookie-domain-mismatch.py
b/testenv/Test-cookie-domain-mismatch.py
index e6bf7bb..92487f4 100755
--- a/testenv/Test-cookie-domain-mismatch.py
+++ b/testenv/Test-cookie-domain-mismatch.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-cookie-expires.py b/testenv/Test-cookie-expires.py
index 78bc8b9..48a93b9 100755
--- a/testenv/Test-cookie-expires.py
+++ b/testenv/Test-cookie-expires.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/Test-cookie.py b/testenv/Test-cookie.py
index df62d14..b70316d 100755
--- a/testenv/Test-cookie.py
+++ b/testenv/Test-cookie.py
@@ -1,6 +1,6 @@
#!/usr/bin/env python3
from sys import exit
-from WgetTest import HTTPTest
+from test.http_test import HTTPTest
from misc.wget_file import WgetFile
"""
diff --git a/testenv/WgetTest.py b/testenv/WgetTest.py
deleted file mode 100644
index 92e4138..0000000
--- a/testenv/WgetTest.py
+++ /dev/null
@@ -1,236 +0,0 @@
-import os
-import shutil
-import shlex
-import sys
-import traceback
-import re
-import time
-from subprocess import call
-from difflib import unified_diff
-
-import conf
-from exc.test_failed import TestFailed
-from misc.colour_terminal import print_red, print_green, print_blue
-from misc.constants import HTTP, HTTPS
-from server.http import http_server
-
-
-""" Class that defines methods common to both HTTP and FTP Tests. """
-
-class CommonMethods:
- TestFailed = TestFailed
-
- def init_test_env (self, name):
- testDir = name + "-test"
- try:
- os.mkdir (testDir)
- except FileExistsError:
- shutil.rmtree (testDir)
- os.mkdir (testDir)
- os.chdir (testDir)
- self.tests_passed = True
-
- def get_domain_addr (self, addr):
- self.port = str (addr[1])
- return addr[0] + ":" + str(addr[1]) + "/"
-
- def exec_wget (self, options, urls, domain_list):
- cmd_line = self.get_cmd_line (options, urls, domain_list)
- params = shlex.split (cmd_line)
- print (params)
- if os.getenv ("SERVER_WAIT"):
- time.sleep (float (os.getenv ("SERVER_WAIT")))
- try:
- retcode = call (params)
- except FileNotFoundError as filenotfound:
- raise TestFailed (
- "The Wget Executable does not exist at the expected path")
- return retcode
-
- def get_cmd_line (self, options, urls, domain_list):
- TEST_PATH = os.path.abspath (".")
- WGET_PATH = os.path.join (TEST_PATH, "..", "..", "src", "wget")
- WGET_PATH = os.path.abspath (WGET_PATH)
- cmd_line = WGET_PATH + " " + options + " "
- for i in range (0, self.servers):
- for url in urls[i]:
- protocol = "http://" if self.server_types[i] is "HTTP" else
"https://"
- cmd_line += protocol + domain_list[i] + url + " "
-# for url in urls:
-# cmd_line += domain_list[0] + url + " "
- print (cmd_line)
- return cmd_line
-
- def __test_cleanup (self):
- testDir = self.name + "-test"
- os.chdir ('..')
- try:
- if os.getenv ("NO_CLEANUP") is None:
- shutil.rmtree (testDir)
- except Exception as ae:
- print ("Unknown Exception while trying to remove Test
Environment.")
-
- def _exit_test (self):
- self.__test_cleanup ()
-
- def begin (self):
- return 0 if self.tests_passed else 100
-
- """ Methods to check if the Test Case passes or not. """
-
- def __gen_local_filesys (self):
- file_sys = dict ()
- for parent, dirs, files in os.walk ('.'):
- for name in files:
- onefile = dict ()
- # Create the full path to file, removing the leading ./
- # Might not work on non-unix systems. Someone please test.
- filepath = os.path.join (parent, name)
- file_handle = open (filepath, 'r')
- file_content = file_handle.read ()
- onefile['content'] = file_content
- filepath = filepath[2:]
- file_sys[filepath] = onefile
- file_handle.close ()
- return file_sys
-
-
- def _check_downloaded_files (self, exp_filesys):
- local_filesys = self.__gen_local_filesys ()
- for files in exp_filesys:
- if files.name in local_filesys:
- local_file = local_filesys.pop (files.name)
- if files.content != local_file ['content']:
- for line in unified_diff (local_file['content'],
files.content, fromfile="Actual", tofile="Expected"):
- sys.stderr.write (line)
- raise TestFailed ("Contents of " + files.name + " do not
match")
- else:
- raise TestFailed ("Expected file " + files.name + " not
found")
- if local_filesys:
- print (local_filesys)
- raise TestFailed ("Extra files downloaded.")
-
- def _replace_substring (self, string):
- pattern = re.compile ('\{\{\w+\}\}')
- match_obj = pattern.search (string)
- if match_obj is not None:
- rep = match_obj.group()
- temp = getattr (self, rep.strip ('{}'))
- string = string.replace (rep, temp)
- return string
-
-
- def get_server_rules (self, file_obj):
- """ The handling of expect header could be made much better when the
- options are parsed in a true and better fashion. For an example,
- see the commented portion in Test-basic-auth.py.
- """
- server_rules = dict ()
- for rule in file_obj.rules:
- r_obj = conf.find_conf(rule)(file_obj.rules[rule])
- server_rules[rule] = r_obj
- return server_rules
-
-
-""" Class for HTTP Tests. """
-
-class HTTPTest (CommonMethods):
-
-# Temp Notes: It is expected that when pre-hook functions are executed, only
an empty test-dir exists.
-# pre-hook functions are executed just prior to the call to Wget is made.
-# post-hook functions will be executed immediately after the call to Wget
returns.
-
- def __init__ (
- self,
- name="Unnamed Test",
- pre_hook=dict(),
- test_params=dict(),
- post_hook=dict(),
- servers=[HTTP]
- ):
- try:
- self.Server_setup (name, pre_hook, test_params, post_hook, servers)
- except TestFailed as tf:
- print_red("Error: " + tf.error)
- self.tests_passed = False
- except Exception as ae:
- print_red("Unhandled Exception Caught.")
- print ( ae.__str__ ())
- traceback.print_exc ()
- self.tests_passed = False
- else:
- print_green("Test Passed")
- finally:
- self._exit_test ()
-
- def Server_setup (self, name, pre_hook, test_params, post_hook, servers):
- self.name = name
- self.server_types = servers
- self.servers = len (servers)
- print_blue("Running Test " + self.name)
- self.init_test_env (name)
- self.server_list = list()
- self.domain_list = list()
- for server_type in servers:
- server_inst = getattr (self, "init_" + server_type + "_Server") ()
- self.server_list.append (server_inst)
- domain = self.get_domain_addr (server_inst.server_address)
- self.domain_list.append (domain)
- #self.server = self.init_HTTP_Server ()
- #self.domain = self.get_domain_addr (self.server.server_address)
-
- self.pre_hook_call (pre_hook)
- self.call_test (test_params)
- self.post_hook_call (post_hook)
-
-
- def hook_call(self, configs, name):
- for conf_name, conf_arg in configs.items():
- try:
- # conf.find_conf(conf_name) returns the required conf class,
- # then the class is instantiated with conf_arg, then the
- # conf instance is called with this test instance itself to
- # invoke the desired hook
- conf.find_conf(conf_name)(conf_arg)(self)
- except AttributeError as e:
- print(e)
- self.stop_HTTP_Server()
- raise TestFailed("%s %s not defined." %
- (name, conf_name))
-
-
- def pre_hook_call (self, pre_hook):
- self.hook_call(pre_hook, 'Pre Test Function')
-
- def call_test (self, test_params):
- self.hook_call(test_params, 'Test Option')
-
- try:
- self.act_retcode = self.exec_wget (self.options, self.urls,
self.domain_list)
- except TestFailed as tf:
- self.stop_HTTP_Server ()
- raise TestFailed (tf.__str__ ())
- self.stop_HTTP_Server ()
-
- def post_hook_call (self, post_hook):
- self.hook_call(post_hook, 'Post Test Function')
-
- def init_HTTP_Server (self):
- server = http_server.HTTPd ()
- server.start ()
- return server
-
- def init_HTTPS_Server (self):
- server = http_server.HTTPSd ()
- server.start ()
- return server
-
- def stop_HTTP_Server (self):
- self.Request_remaining = list ()
- for server in self.server_list:
- server_req = server.server_inst.get_req_headers ()
- self.Request_remaining.append (server_req)
- server.server_inst.shutdown ()
-
-
-# vim: set ts=4 sts=4 sw=4 tw=80 et :
diff --git a/testenv/test/__init__.py b/testenv/test/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/testenv/test/base_test.py b/testenv/test/base_test.py
new file mode 100644
index 0000000..fecc9c5
--- /dev/null
+++ b/testenv/test/base_test.py
@@ -0,0 +1,128 @@
+from difflib import unified_diff
+import os
+import re
+import shlex
+import shutil
+from subprocess import call
+import time
+import sys
+import conf
+from exc.test_failed import TestFailed
+
+
+class CommonMethods:
+
+ """ Class that defines methods common to both HTTP and FTP Tests. """
+
+ TestFailed = TestFailed
+
+ def init_test_env (self, name):
+ testDir = name + "-test"
+ try:
+ os.mkdir (testDir)
+ except FileExistsError:
+ shutil.rmtree (testDir)
+ os.mkdir (testDir)
+ os.chdir (testDir)
+ self.tests_passed = True
+
+ def get_domain_addr (self, addr):
+ self.port = str (addr[1])
+ return addr[0] + ":" + str(addr[1]) + "/"
+
+ def exec_wget (self, options, urls, domain_list):
+ cmd_line = self.get_cmd_line (options, urls, domain_list)
+ params = shlex.split (cmd_line)
+ print (params)
+ if os.getenv ("SERVER_WAIT"):
+ time.sleep (float (os.getenv ("SERVER_WAIT")))
+ try:
+ retcode = call (params)
+ except FileNotFoundError as filenotfound:
+ raise TestFailed (
+ "The Wget Executable does not exist at the expected path")
+ return retcode
+
+ def get_cmd_line (self, options, urls, domain_list):
+ TEST_PATH = os.path.abspath (".")
+ WGET_PATH = os.path.join (TEST_PATH, "..", "..", "src", "wget")
+ WGET_PATH = os.path.abspath (WGET_PATH)
+ cmd_line = WGET_PATH + " " + options + " "
+ for i in range (0, self.servers):
+ for url in urls[i]:
+ protocol = "http://" if self.server_types[i] is "HTTP" else
"https://"
+ cmd_line += protocol + domain_list[i] + url + " "
+# for url in urls:
+# cmd_line += domain_list[0] + url + " "
+ print (cmd_line)
+ return cmd_line
+
+ def __test_cleanup (self):
+ testDir = self.name + "-test"
+ os.chdir ('..')
+ try:
+ if os.getenv ("NO_CLEANUP") is None:
+ shutil.rmtree (testDir)
+ except Exception as ae:
+ print ("Unknown Exception while trying to remove Test
Environment.")
+
+ def _exit_test (self):
+ self.__test_cleanup ()
+
+ def begin (self):
+ return 0 if self.tests_passed else 100
+
+ """ Methods to check if the Test Case passes or not. """
+
+ def __gen_local_filesys (self):
+ file_sys = dict ()
+ for parent, dirs, files in os.walk ('.'):
+ for name in files:
+ onefile = dict ()
+ # Create the full path to file, removing the leading ./
+ # Might not work on non-unix systems. Someone please test.
+ filepath = os.path.join (parent, name)
+ file_handle = open (filepath, 'r')
+ file_content = file_handle.read ()
+ onefile['content'] = file_content
+ filepath = filepath[2:]
+ file_sys[filepath] = onefile
+ file_handle.close ()
+ return file_sys
+
+
+ def _check_downloaded_files (self, exp_filesys):
+ local_filesys = self.__gen_local_filesys ()
+ for files in exp_filesys:
+ if files.name in local_filesys:
+ local_file = local_filesys.pop (files.name)
+ if files.content != local_file ['content']:
+ for line in unified_diff (local_file['content'],
files.content, fromfile="Actual", tofile="Expected"):
+ sys.stderr.write (line)
+ raise TestFailed ("Contents of " + files.name + " do not
match")
+ else:
+ raise TestFailed ("Expected file " + files.name + " not
found")
+ if local_filesys:
+ print (local_filesys)
+ raise TestFailed ("Extra files downloaded.")
+
+ def _replace_substring (self, string):
+ pattern = re.compile ('\{\{\w+\}\}')
+ match_obj = pattern.search (string)
+ if match_obj is not None:
+ rep = match_obj.group()
+ temp = getattr (self, rep.strip ('{}'))
+ string = string.replace (rep, temp)
+ return string
+
+
+ def get_server_rules (self, file_obj):
+ """ The handling of expect header could be made much better when the
+ options are parsed in a true and better fashion. For an example,
+ see the commented portion in Test-basic-auth.py.
+ """
+ server_rules = dict ()
+ for rule in file_obj.rules:
+ r_obj = conf.find_conf(rule)(file_obj.rules[rule])
+ server_rules[rule] = r_obj
+ return server_rules
\ No newline at end of file
diff --git a/testenv/test/http_test.py b/testenv/test/http_test.py
new file mode 100644
index 0000000..3d4c9c9
--- /dev/null
+++ b/testenv/test/http_test.py
@@ -0,0 +1,108 @@
+import traceback
+import conf
+from exc.test_failed import TestFailed
+from misc.colour_terminal import print_red, print_green, print_blue
+from misc.constants import HTTP
+from server.http import http_server
+from test.base_test import CommonMethods
+
+
+class HTTPTest (CommonMethods):
+
+ """ Class for HTTP Tests. """
+
+# Temp Notes: It is expected that when pre-hook functions are executed, only
an empty test-dir exists.
+# pre-hook functions are executed just prior to the call to Wget is made.
+# post-hook functions will be executed immediately after the call to Wget
returns.
+
+ def __init__ (
+ self,
+ name="Unnamed Test",
+ pre_hook=dict(),
+ test_params=dict(),
+ post_hook=dict(),
+ servers=[HTTP]
+ ):
+ try:
+ self.Server_setup (name, pre_hook, test_params, post_hook, servers)
+ except TestFailed as tf:
+ print_red("Error: " + tf.error)
+ self.tests_passed = False
+ except Exception as ae:
+ print_red("Unhandled Exception Caught.")
+ print ( ae.__str__ ())
+ traceback.print_exc ()
+ self.tests_passed = False
+ else:
+ print_green("Test Passed")
+ finally:
+ self._exit_test ()
+
+ def Server_setup (self, name, pre_hook, test_params, post_hook, servers):
+ self.name = name
+ self.server_types = servers
+ self.servers = len (servers)
+ print_blue("Running Test " + self.name)
+ self.init_test_env (name)
+ self.server_list = list()
+ self.domain_list = list()
+ for server_type in servers:
+ server_inst = getattr (self, "init_" + server_type + "_Server") ()
+ self.server_list.append (server_inst)
+ domain = self.get_domain_addr (server_inst.server_address)
+ self.domain_list.append (domain)
+ #self.server = self.init_HTTP_Server ()
+ #self.domain = self.get_domain_addr (self.server.server_address)
+
+ self.pre_hook_call (pre_hook)
+ self.call_test (test_params)
+ self.post_hook_call (post_hook)
+
+
+ def hook_call(self, configs, name):
+ for conf_name, conf_arg in configs.items():
+ try:
+ # conf.find_conf(conf_name) returns the required conf class,
+ # then the class is instantiated with conf_arg, then the
+ # conf instance is called with this test instance itself to
+ # invoke the desired hook
+ conf.find_conf(conf_name)(conf_arg)(self)
+ except AttributeError as e:
+ print(e)
+ self.stop_HTTP_Server()
+ raise TestFailed("%s %s not defined." %
+ (name, conf_name))
+
+
+ def pre_hook_call (self, pre_hook):
+ self.hook_call(pre_hook, 'Pre Test Function')
+
+ def call_test (self, test_params):
+ self.hook_call(test_params, 'Test Option')
+
+ try:
+ self.act_retcode = self.exec_wget (self.options, self.urls,
self.domain_list)
+ except TestFailed as tf:
+ self.stop_HTTP_Server ()
+ raise TestFailed (tf.__str__ ())
+ self.stop_HTTP_Server ()
+
+ def post_hook_call (self, post_hook):
+ self.hook_call(post_hook, 'Post Test Function')
+
+ def init_HTTP_Server (self):
+ server = http_server.HTTPd ()
+ server.start ()
+ return server
+
+ def init_HTTPS_Server (self):
+ server = http_server.HTTPSd ()
+ server.start ()
+ return server
+
+ def stop_HTTP_Server (self):
+ self.Request_remaining = list ()
+ for server in self.server_list:
+ server_req = server.server_inst.get_req_headers ()
+ self.Request_remaining.append (server_req)
+ server.server_inst.shutdown ()
\ No newline at end of file
--
1.8.3.2
- [Bug-wget] [GSoC PATCH 00/11] Refactor Test Suite, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 01/11] create package misc, move ColourTerm.py to misc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 02/11] from WgetTest.py move WgetFile to misc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 03/11] fix a typo in Test-Proto.py, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 04/11] create package exc and move TestFailed to exc, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 05/11] create package conf where rules and hooks are put, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 06/11] move server classes to package server.protocol, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 07/11] create package test for test case classes,
Zihang Chen <=
- [Bug-wget] [GSoC PATCH 08/11] refactor a lot, see ChangeLog for detail, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 09/11] update README, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 10/11] ensure line feed at EOF and one blank line between methods, Zihang Chen, 2014/03/14
- [Bug-wget] [GSoC PATCH 11/11] in conf, rename register to rule and hook, Zihang Chen, 2014/03/14