Revision: 721
Author: keith.dart
Date: Mon May 6 20:21:06 2013
Log: Updated some tests.
http://code.google.com/p/pycopia/source/detail?r=721
Added:
/testing/testcases/unittests/QA/core/params.py
Modified:
/testing/testcases/unittests/Apple.py
/testing/testcases/unittests/WWW/client.py
/testing/testcases/unittests/core/scheduler.py
=======================================
--- /dev/null
+++ /testing/testcases/unittests/QA/core/params.py Mon May 6 20:21:06 2013
@@ -0,0 +1,122 @@
+#!/usr/bin/python
+# -*- coding: us-ascii -*-
+# vim:ts=4:sw=4:softtabstop=0:smarttab
+
+"""
+Parameter Reporting target
+--------------------------
+
+This test module exists only for being the target of some test reporting
and
+analyzing functions.
+"""
+
+from pycopia.QA import core
+
+
+class ParameterBase(core.Test):
+
+ def do_something(self):
+ p1 = self.config.get("do_something_p1", "dsdefault1")
+
+
+class ParameterPopulateTest(ParameterBase):
+ """
+ Purpose
+ +++++++
+
+ Check handling of parameter usage inspection.
+
+ Pass Criteria
+ +++++++++++++
+
+ Database param set is populated with all fetched parameters.
+
+ Start Condition
+ +++++++++++++++
+
+ Nothing special
+
+ End Condition
+ +++++++++++++
+
+ No change.
+
+ Reference
+ +++++++++
+
+ None
+
+ Prerequisites
+ +++++++++++++
+
+ None
+
+ Procedure
+ +++++++++
+
+ 1. Fetch several parameters using the config.get() method.
+ 2. Report them.
+
+ """
+ def execute(self):
+ p1 = self.config.get("param1", "default1")
+ p2 = self.config.get("param2", "default2")
+ p3 = self.config.get("param3", "default3")
+
self.info("param1: {!r} param2: {!r} param3: {!r}".format(p1, p2,
p3))
+ return self.passed("Fetched and reported parameters")
+
+
+class TestWithParameters(ParameterBase):
+ """
+ Purpose
+ +++++++
+
+ Check handling of parameter usage inspection.
+
+ Pass Criteria
+ +++++++++++++
+
+ Database param set is populated with all fetched parameters.
+
+ Start Condition
+ +++++++++++++++
+
+ Nothing special
+
+ End Condition
+ +++++++++++++
+
+ No change.
+
+ Reference
+ +++++++++
+
+ None
+
+ Prerequisites
+ +++++++++++++
+
+ None
+
+ Procedure
+ +++++++++
+
+ 1. Fetch several parameters using the config.get() method.
+ 2. Report them.
+
+ """
+ def execute(self, p1, p2, p3, kwp=2):
+
self.info("param1: {!r} param2: {!r} param3: {!r}".format(p1, p2,
p3))
+ return self.passed("Fetched and reported parameters")
+
+
+def get_suite(config):
+ suite = core.TestSuite(config, name="ParamTestSUite")
+ suite.add_test(ParameterPopulateTest)
+ suite.add_test(TestWithParameters, 1, 2, 3)
+ return suite
+
+def run(config):
+ suite = get_suite(config)
+ return suite.run()
+
=======================================
--- /testing/testcases/unittests/Apple.py Fri Jul 16 02:09:58 2010
+++ /testing/testcases/unittests/Apple.py Mon May 6 20:21:06 2013
@@ -42,7 +42,7 @@
Prerequisites
+++++++++++++
-
+
Procedure
+++++++++
@@ -57,7 +57,7 @@
</ol>
"""
-
+
def execute(self):
return self.manual()
@@ -65,9 +65,8 @@
def get_suite(config):
suite = core.TestSuite(config, name="Apple")
suite.add_test(EatTheApple)
-
return suite
def run(config):
suite = get_suite(config)
- suite.run()
+ return suite.run()
=======================================
--- /testing/testcases/unittests/WWW/client.py Wed Sep 5 05:09:59 2012
+++ /testing/testcases/unittests/WWW/client.py Mon May 6 20:21:06 2013
@@ -58,7 +58,7 @@
"""
def execute(self):
- resp = client.get_page(TESTURL)
+ resp = client.get_page(self.config.get("testurl", TESTURL))
self.assertEqual(resp.status.code, 200, "bad response code")
self.info(str(resp.timing))
self.save_data(resp.timing.todict())
@@ -282,7 +282,7 @@
@staticmethod
def get_suite(config):
suite = core.TestSuite(config, name="HTTPTimingSuite")
- suite.add_tests([HTTPPageFetch]*100)
+ suite.add_tests([HTTPPageFetch]*10)
return suite
@staticmethod
=======================================
--- /testing/testcases/unittests/core/scheduler.py Wed Sep 8 22:53:52 2010
+++ /testing/testcases/unittests/core/scheduler.py Mon May 6 20:21:06 2013
@@ -69,6 +69,16 @@
self.assertApproximatelyEqual(now() - start, 8, 1)
return self.passed("passed all assertions")
+class SubsecondTimer(SchedulerBaseTest):
+ """Test that a series of time events fire at approximately correct
times."""
+ def execute(self):
+ start = now()
+ self.sched.add(0.1, 0, self._tp, (0.1, start))
+ self.sched.add(0.12, 0, self._tp, (0.12, start))
+ self.sched.sleep(1)
+ self.assertApproximatelyEqual(now() - start, 1, 0.01)
+ return self.passed("passed all assertions")
+
class BasicSleepTest(SchedulerBaseTest):
"""Test that scheduler sleep function is accurate."""
def execute(self):
@@ -218,6 +228,7 @@
suite = SchedulerSuite(conf)
suite.add_test(BasicTimer)
+ suite.add_test(SubsecondTimer)
suite.add_test(BasicSleepTest)
suite.add_test(TimeoutTest)
suite.add_test(SubTimeoutLongerTest)