Commit e18a678b authored by Naoki Kambe's avatar Naoki Kambe
Browse files

[trac930] modify b10-stats_test.py

 - set the constant variables in the setUp method in the TestUtilties class,
   and compare values returned from the functions with these constants in
   testing methods.

[trac930] remove the tearDown method which has no test case in the TestCallback
          class
parent 1d1a8793
......@@ -56,6 +56,13 @@ class TestUtilties(unittest.TestCase):
{ 'item_name': 'test_none', 'item_type': 'none' }
]
def setUp(self):
self.const_timestamp = 1308730448.965706
self.const_timetuple = (2011, 6, 22, 8, 14, 8, 2, 173, 0)
self.const_datetime = '2011-06-22T08:14:08Z'
stats.time = lambda : self.const_timestamp
stats.gmtime = lambda : self.const_timetuple
def test_get_spec_defaults(self):
self.assertEqual(
stats.get_spec_defaults(self.items), {
......@@ -76,14 +83,12 @@ class TestUtilties(unittest.TestCase):
self.assertRaises(KeyError, stats.get_spec_defaults, [{'item_name':'Foo'}])
def test_get_timestamp(self):
self.assertEqual(stats.get_timestamp(), 1308730448.965706)
self.assertEqual(stats.get_timestamp(), self.const_timestamp)
def test_get_datetime(self):
stats.time = lambda : 1308730448.965706
stats.gmtime = lambda : (2011, 6, 22, 8, 14, 8, 2, 173, 0)
self.assertEqual(stats.get_datetime(), '2011-06-22T08:14:08Z')
self.assertEqual(stats.get_datetime(), self.const_datetime)
self.assertNotEqual(stats.get_datetime(
(2011, 6, 22, 8, 23, 40, 2, 173, 0)), '2011-06-22T08:14:08Z')
(2011, 6, 22, 8, 23, 40, 2, 173, 0)), self.const_datetime)
class TestCallback(unittest.TestCase):
def setUp(self):
......@@ -108,9 +113,6 @@ class TestCallback(unittest.TestCase):
args=self.dummy_args
)
def tearDown(self):
pass
def test_init(self):
self.assertEqual((self.cback1.command, self.cback1.args, self.cback1.kwargs),
(self.dummy_func, self.dummy_args, self.dummy_kwargs))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment