From: Naoki Kambe Date: Tue, 16 Oct 2012 02:15:01 +0000 (+0900) Subject: [2298] add CONST_BASETIME and use it in MockBoss and MyStats classes X-Git-Tag: trac2487_base~1^2~26^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a00c610e108ccffbeff043241e0be556c6c8d950;p=thirdparty%2Fkea.git [2298] add CONST_BASETIME and use it in MockBoss and MyStats classes 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. --- diff --git a/src/bin/stats/tests/test_utils.py b/src/bin/stats/tests/test_utils.py index 0af3c82a8c..96f7046e87 100644 --- a/src/bin/stats/tests/test_utils.py +++ b/src/bin/stats/tests/test_utils.py @@ -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)