Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/pi-hole/pi-hole.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorChristian König <ckoenig@posteo.de>2022-07-26 20:33:38 +0300
committerChristian König <ckoenig@posteo.de>2022-07-26 20:33:38 +0300
commitab6b37bdcfab2c64683a6a7386f3afc749f1017e (patch)
tree0f31e9a8cf9d25bc19343eb21fd08f2404a760ff /test
parentc8c4eb59b774de7ad7ae5b3afd017626de7c20f3 (diff)
Fix stickler and codefactor complaintsmove_getFTLPIDFile
Signed-off-by: Christian König <ckoenig@posteo.de>
Diffstat (limited to 'test')
-rw-r--r--test/test_any_utils.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/test/test_any_utils.py b/test/test_any_utils.py
index 0668b9d1..5126f263 100644
--- a/test/test_any_utils.py
+++ b/test/test_any_utils.py
@@ -49,6 +49,7 @@ def test_key_removal_works(host):
expected_stdout = 'KEY_ONE=value1\nKEY_THREE=value3\n'
assert expected_stdout == output.stdout
+
def test_getFTLAPIPortFile_default(host):
''' Confirms getFTLAPIPortFile returns the default API port file path '''
output = host.run('''
@@ -72,8 +73,9 @@ def test_getFTLAPIPort_default(host):
def test_getFTLAPIPortFile_and_getFTLAPIPort_custom(host):
''' Confirms getFTLAPIPort returns a custom API port in a custom PORTFILE location '''
host.run('''
- echo "PORTFILE=/tmp/port.file" > /etc/pihole/pihole-FTL.conf
- echo "1234" > /tmp/port.file
+ tmpfile=$(mktemp)
+ echo "PORTFILE=${tmpfile}" > /etc/pihole/pihole-FTL.conf
+ echo "1234" > ${tmpfile}
''')
output = host.run('''
source /opt/pihole/utils.sh
@@ -83,6 +85,7 @@ def test_getFTLAPIPortFile_and_getFTLAPIPort_custom(host):
expected_stdout = '1234\n'
assert expected_stdout == output.stdout
+
def test_getFTLPIDFile_default(host):
''' Confirms getFTLPIDFile returns the default PID file path '''
output = host.run('''
@@ -92,6 +95,7 @@ def test_getFTLPIDFile_default(host):
expected_stdout = '/run/pihole-FTL.pid\n'
assert expected_stdout == output.stdout
+
def test_getFTLPID_default(host):
''' Confirms getFTLPID returns the default value if FTL is not running '''
output = host.run('''
@@ -101,17 +105,18 @@ def test_getFTLPID_default(host):
expected_stdout = '-1\n'
assert expected_stdout == output.stdout
+
def test_getFTLPIDFile_and_getFTLPID_custom(host):
''' Confirms getFTLPIDFile returns a custom PID file path '''
host.run('''
- echo "PIDFILE=/tmp/pid.file" > /etc/pihole/pihole-FTL.conf
- echo "1234" > /tmp/pid.file
+ tmpfile=$(mktemp)
+ echo "PIDFILE=${tmpfile}" > /etc/pihole/pihole-FTL.conf
+ echo "1234" > ${tmpfile}
''')
output = host.run('''
source /opt/pihole/utils.sh
FTL_PID_FILE=$(getFTLPIDFile)
getFTLPID "${FTL_PID_FILE}"
''')
- expected_stdout = '/tmp/pid.file\n'
+ expected_stdout = '1234\n'
assert expected_stdout == output.stdout
-