Module: check_mk
Branch: master
Commit: fc503afa6b3ca18e2ea4d0be800680858fda9d35
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fc503afa6b3ca1…
Author: Florian Kromer <fk(a)mathias-kettner.de>
Date: Thu Apr 4 14:59:35 2019 +0200
fix freeze of current time during regression test creation
Change-Id: Icd5ac310d251a5320665ee3a91c4a512566e827b
---
tests/unit/checks/generictests/__init__.py | 5 +++--
tests/unit/checks/generictests/regression.py | 6 +++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/tests/unit/checks/generictests/__init__.py
b/tests/unit/checks/generictests/__init__.py
index 8566940..6dc0abf 100644
--- a/tests/unit/checks/generictests/__init__.py
+++ b/tests/unit/checks/generictests/__init__.py
@@ -38,8 +38,9 @@ check function(s)). In the following, 'sc-dict' refers to a
dictionary with
Some more advanced ones are
* `freeze_time` : [str] Mocked time.
- If present, its value are passed to
- `freezegun.freeze_time`
+ If present its value is passed to `freezegun.freeze_time`.
+ If you specify the empty string it will be replaced by the
+ current time if processed by generictests.regression.
* `extra_sections` : [sc-dict] Extra sections that are appended to the info
/ parsed variable.
If present, its values are extra sections (the actual
diff --git a/tests/unit/checks/generictests/regression.py
b/tests/unit/checks/generictests/regression.py
index ce1d580..5672aa0 100644
--- a/tests/unit/checks/generictests/regression.py
+++ b/tests/unit/checks/generictests/regression.py
@@ -39,6 +39,7 @@ Make sure the file(s name) is a valid python module:
import os
import sys
import pprint
+import time
from importlib import import_module
import generictests.run
@@ -61,7 +62,10 @@ class WritableDataset(object):
)
self.checkname = init_dict.get('checkname', None)
self.info = init_dict.get('info', None)
- self.freeze_time = init_dict.get('freeze_time', None)
+ freeze_time = init_dict.get('freeze_time', None)
+ if freeze_time == "":
+ freeze_time = time.strftime("%Y-%m-%d %H:%M:%S")
+ self.freeze_time = freeze_time
self.parsed = init_dict.get('parsed', None)
self.discovery = init_dict.get('discovery', {})
self.checks = {}