]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2298] add CONST_BASETIME and use it in MockBoss and MyStats classes
authorNaoki Kambe <kambe@jprs.co.jp>
Tue, 16 Oct 2012 02:15:01 +0000 (11:15 +0900)
committerNaoki Kambe <kambe@jprs.co.jp>
Fri, 26 Oct 2012 11:36:26 +0000 (20:36 +0900)
Add fixed BASETIME not depending on the time module. And modify
MockBoss and MockStats classes in order that they return time values
of that. This is for testing b10-stats and b10-stats-httpd.

src/bin/stats/tests/test_utils.py

index 0af3c82a8c81ce6f72b93953547b80293d45986c..96f7046e87e36116c53d5f2612d78f02cc80bcdc 100644 (file)
@@ -31,6 +31,8 @@ import isc.config.cfgmgr
 import stats
 import stats_httpd
 
+CONST_BASETIME = (2011, 6, 22, 8, 14, 8, 2, 173, 0)
+
 class SignalHandler():
     """A signal handler class for deadlock in unittest"""
     def __init__(self, fail_handler, timeout=20):
@@ -237,7 +239,7 @@ class MockBoss:
   }
 }
 """
-    _BASETIME = (2011, 6, 22, 8, 14, 8, 2, 173, 0)
+    _BASETIME = CONST_BASETIME
 
     def __init__(self):
         self._started = threading.Event()
@@ -472,6 +474,11 @@ class MockAuth:
         return isc.config.create_answer(1, "Unknown Command")
 
 class MyStats(stats.Stats):
+
+    stats._BASETIME = CONST_BASETIME
+    stats.get_timestamp = lambda: time.mktime(CONST_BASETIME)
+    stats.get_datetime = lambda x=None: time.strftime("%Y-%m-%dT%H:%M:%SZ", CONST_BASETIME)
+
     def __init__(self):
         self._started = threading.Event()
         stats.Stats.__init__(self)