diff options
author | yubiuser <ckoenig@posteo.de> | 2022-04-05 00:25:54 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-05 00:25:54 +0300 |
commit | d3e94cbceb5cf2697c722bb365ef489328b96435 (patch) | |
tree | 04fdf0501b3e70c56455884c69571daa2572aa0a /test | |
parent | 9878477896883b0d43c25d62d98d980f78208199 (diff) | |
parent | 9b4f6c84cd770d333bca1579a8494472bfe5fa62 (diff) |
Merge pull request #4653 from pi-hole/refactor-utils-redux
Tweaks to functions in utils.sh and refactored usages in webpage.sh
Diffstat (limited to 'test')
-rw-r--r-- | test/test_any_utils.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/test/test_any_utils.py b/test/test_any_utils.py index 8ad27997..998c1c84 100644 --- a/test/test_any_utils.py +++ b/test/test_any_utils.py @@ -2,15 +2,33 @@ def test_key_val_replacement_works(host): ''' Confirms addOrEditKeyValPair provides the expected output ''' host.run(''' source /opt/pihole/utils.sh - addOrEditKeyValPair "KEY_ONE" "value1" "./testoutput" - addOrEditKeyValPair "KEY_TWO" "value2" "./testoutput" - addOrEditKeyValPair "KEY_ONE" "value3" "./testoutput" - addOrEditKeyValPair "KEY_FOUR" "value4" "./testoutput" + addOrEditKeyValPair "./testoutput" "KEY_ONE" "value1" + addOrEditKeyValPair "./testoutput" "KEY_TWO" "value2" + addOrEditKeyValPair "./testoutput" "KEY_ONE" "value3" + addOrEditKeyValPair "./testoutput" "KEY_FOUR" "value4" + addOrEditKeyValPair "./testoutput" "KEY_FIVE_NO_VALUE" + addOrEditKeyValPair "./testoutput" "KEY_FIVE_NO_VALUE" ''') output = host.run(''' cat ./testoutput ''') - expected_stdout = 'KEY_ONE=value3\nKEY_TWO=value2\nKEY_FOUR=value4\n' + expected_stdout = 'KEY_ONE=value3\nKEY_TWO=value2\nKEY_FOUR=value4\nKEY_FIVE_NO_VALUE\n' + assert expected_stdout == output.stdout + + +def test_key_val_removal_works(host): + ''' Confirms removeKey provides the expected output ''' + host.run(''' + source /opt/pihole/utils.sh + addOrEditKeyValPair "./testoutput" "KEY_ONE" "value1" + addOrEditKeyValPair "./testoutput" "KEY_TWO" "value2" + addOrEditKeyValPair "./testoutput" "KEY_THREE" "value3" + removeKey "./testoutput" "KEY_TWO" + ''') + output = host.run(''' + cat ./testoutput + ''') + expected_stdout = 'KEY_ONE=value1\nKEY_THREE=value3\n' assert expected_stdout == output.stdout |