Skip to content

Commit e47d7d5

Browse files
authored
Merge pull request #356 from Helene/conf_unit_test
Add unit test for checkForInvalidsettings
2 parents 67a20fd + cccf157 commit e47d7d5

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

source/confParser.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,12 @@ def checkCAsettings(args):
9292

9393

9494
def checkForInvalidsettings(args):
95-
if not all(args.values()):
95+
if all(args.values()):
96+
return True, ''
97+
else:
9698
for key, value in args.items():
9799
if value is None or value == '':
98100
return False, MSG['InvalidConfigParm'].format(key)
99-
else:
100101
return True, ''
101102

102103

tests/test_params.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
from source.confParser import (ConfigManager, merge_defaults_and_args,
22
parse_cmd_args, checkCAsettings,
33
checkApplicationPort,
4-
checkBasicAuthsettings)
4+
checkBasicAuthsettings,
5+
checkForInvalidsettings)
56
from source.__version__ import __version__ as version
67
from nose2.tools.decorators import with_setup
78

@@ -209,3 +210,18 @@ def test_case17():
209210
assert len(result.keys()) > 0
210211
assert 'rawCounters' in result.keys()
211212
assert result.get('rawCounters') == eval("False")
213+
214+
215+
@with_setup(my_setup)
216+
def test_case18():
217+
if version > "8.0.9":
218+
z = y.copy()
219+
z['apiKeyValue'] = ''
220+
result = merge_defaults_and_args(y, r)
221+
result1 = merge_defaults_and_args(z, r)
222+
valid, msg = checkForInvalidsettings(result)
223+
valid1, msg1 = checkForInvalidsettings(result1)
224+
assert valid
225+
assert not valid1
226+
assert msg == ''
227+
assert len(msg1) > 1

tests/test_parser.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@
44

55
def test_case01():
66
result = os.system('python ./source/zimonGrafanaIntf.py')
7-
assert result > 0
7+
print(result)
8+
assert result == 0
89

910

1011
def test_case02():
1112
result = os.system('python ./source/zimonGrafanaIntf.py -a 2')
12-
assert result > 0
13+
assert result == 0
1314

1415

1516
def test_case03():
@@ -19,7 +20,7 @@ def test_case03():
1920

2021
def test_case04():
2122
result = os.system('python ./source/zimonGrafanaIntf.py -c 10 -m "/opt/registry/certs"')
22-
assert result > 0
23+
assert result == 0
2324

2425

2526
def test_case05():

0 commit comments

Comments
 (0)