Module: check_mk
Branch: master
Commit: 7bc569e8f67af1f689ac61ae1bda0843a255170f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7bc569e8f67af1…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Dec 17 07:46:37 2018 +0100
test_win_license: Add explicit test ids to prevent too long automatically computed IDS
Change-Id: I25de70ae7c91d50a299af7b1f8ecd72e13ac0b2a
---
tests/unit/checks/test_win_license.py | 102 ++++++++++++++++------------------
1 file changed, 49 insertions(+), 53 deletions(-)
diff --git a/tests/unit/checks/test_win_license.py
b/tests/unit/checks/test_win_license.py
index 03eecbc..90c6a43 100644
--- a/tests/unit/checks/test_win_license.py
+++ b/tests/unit/checks/test_win_license.py
@@ -66,27 +66,29 @@ def splitter(text):
return [line.split() for line in text.split("\n")]
-(a)pytest.mark.parametrize("capturepture, result",
- zip(agent_out, [
- {
- "License": "Initial grace period",
- "expiration": "12960 minute(s) (9
day(s))",
- "expiration_time": 12960 * 60,
- },
- {
- "License": "Licensed",
- "expiration": "253564 minute(s) (177
day(s))",
- "expiration_time": 253564 * 60,
- },
- {
- "License": "Licensed",
- "expiration": "251100 minute(s) (174
day(s))",
- "expiration_time": 251100 * 60,
- },
- {
- "License": "Licensed",
- },
- ]))
+(a)pytest.mark.parametrize(
+ "capture, result",
+ zip(agent_out, [
+ {
+ "License": "Initial grace period",
+ "expiration": "12960 minute(s) (9 day(s))",
+ "expiration_time": 12960 * 60,
+ },
+ {
+ "License": "Licensed",
+ "expiration": "253564 minute(s) (177 day(s))",
+ "expiration_time": 253564 * 60,
+ },
+ {
+ "License": "Licensed",
+ "expiration": "251100 minute(s) (174 day(s))",
+ "expiration_time": 251100 * 60,
+ },
+ {
+ "License": "Licensed",
+ },
+ ]),
+ ids=["win7", "win2012", "win2008", "win10"])
def test_parse_win_license(check_manager, capture, result):
check = check_manager.get_check("win_license")
assert result == check.run_parse(splitter(capture))
@@ -100,51 +102,45 @@ check_ref = namedtuple('result', ['parameters',
'check_output'])
zip(agent_out, [
check_ref({
'status': ['Licensed', 'Initial grace period'],
- 'expiration_time': (8*24*60*60, 5*24*60*60),
+ 'expiration_time': (8 * 24 * 60 * 60, 5 * 24 * 60 * 60),
+ }, CheckResult([
+ (0, "Software is Initial grace period"),
+ (0, "License will expire in 9 d"),
+ ])),
+ check_ref({
+ 'status': ['Licensed', 'Initial grace period'],
+ 'expiration_time': (180 * 24 * 60 * 60, 90 * 24 * 60 * 60),
+ },
+ CheckResult([
+ (0, "Software is Licensed"),
+ (1, "License will expire in 176 d (warn/crit at 180 d/90
d)"),
+ ])),
+ check_ref({
+ 'status': ['Licensed', 'Initial grace period'],
+ 'expiration_time': (360 * 24 * 60 * 60, 180 * 24 * 60 * 60),
},
CheckResult([
- (0, "Software is Initial grace period"),
- (0, "License will expire in 9 d"),
+ (0, "Software is Licensed"),
+ (2, "License will expire in 174 d (warn/crit at 360 d/180
d)"),
])),
- check_ref(
- {
- 'status': ['Licensed', 'Initial grace period'],
- 'expiration_time': (180*24*60*60, 90*24*60*60),
- },
- CheckResult([
- (0, "Software is Licensed"),
- (1,
- "License will expire in 176 d (warn/crit at 180 d/90 d)"),
- ])),
- check_ref(
- {
- 'status': ['Licensed', 'Initial grace period'],
- 'expiration_time': (360*24*60*60, 180*24*60*60),
- },
- CheckResult([
- (0, "Software is Licensed"),
- (2,
- "License will expire in 174 d (warn/crit at 360 d/180 d)"
- ),
- ])),
check_ref({
'status': ['Licensed', 'Initial grace period'],
- 'expiration_time': (14*24*60*60, 7*24*60*60),
+ 'expiration_time': (14 * 24 * 60 * 60, 7 * 24 * 60 * 60),
}, CheckResult([(0, "Software is Licensed")])),
]) + zip(agent_out, [
check_ref({
'status': ["Registered"],
- 'expiration_time': (8*24*60*60, 5*24*60*60),
+ 'expiration_time': (8 * 24 * 60 * 60, 5 * 24 * 60 * 60),
},
CheckResult([(2, "Software is Initial grace period Required:
Registered"),
(0, 'License will expire in 9 d')])),
- check_ref(
- None,
- CheckResult([(0, "Software is Licensed"),
- (0, 'License will expire in 176 d')])),
- ]))
+ check_ref(None,
+ CheckResult([(0, "Software is Licensed"), (0, 'License
will expire in 176 d')])),
+ ]),
+ ids=map(str, range(6)))
def test_check_win_license(check_manager, capture, result):
check = check_manager.get_check("win_license")
- output = check.run_check(None, result.parameters or check.default_parameters(),
check.run_parse(splitter(capture)))
+ output = check.run_check(None, result.parameters or check.default_parameters(),
+ check.run_parse(splitter(capture)))
assertCheckResultsEqual(CheckResult(output), result.check_output)