Fixes to test script for flake8
This commit is contained in:
@ -2,4 +2,6 @@ language: python
|
|||||||
python:
|
python:
|
||||||
- "2.7"
|
- "2.7"
|
||||||
|
|
||||||
script: python test/wait-for-it.py
|
script:
|
||||||
|
- python test/wait-for-it.py
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import unittest
|
import unittest
|
||||||
import subprocess
|
|
||||||
import shlex
|
import shlex
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import os
|
import os
|
||||||
@ -11,14 +10,13 @@ MISSING_ARGS_TEXT = "Error: you need to provide a host and port to test."
|
|||||||
HELP_TEXT = "Usage:" # Start of help text
|
HELP_TEXT = "Usage:" # Start of help text
|
||||||
DIVIDE_LINE = '-'*71 # Output line of dashes
|
DIVIDE_LINE = '-'*71 # Output line of dashes
|
||||||
|
|
||||||
|
|
||||||
|
class TestWaitForIt(unittest.TestCase):
|
||||||
"""
|
"""
|
||||||
TestWaitForIt tests the wait-for-it.sh shell script.
|
TestWaitForIt tests the wait-for-it.sh shell script.
|
||||||
|
The wait-for-it.sh script is assumed to be in the parent directory to
|
||||||
The wait-for-it.sh script is assumed to be in the parent directory to the
|
the test script.
|
||||||
test script.
|
|
||||||
"""
|
"""
|
||||||
class TestWaitForIt(unittest.TestCase):
|
|
||||||
|
|
||||||
|
|
||||||
def execute(self, cmd):
|
def execute(self, cmd):
|
||||||
"""Executes a command and returns exit code, STDOUT, STDERR"""
|
"""Executes a command and returns exit code, STDOUT, STDERR"""
|
||||||
@ -62,8 +60,8 @@ class TestWaitForIt(unittest.TestCase):
|
|||||||
|
|
||||||
def test_no_args(self):
|
def test_no_args(self):
|
||||||
"""
|
"""
|
||||||
Check that no aruments returns the missing args text and the correct
|
Check that no aruments returns the missing args text and the
|
||||||
return code
|
correct return code
|
||||||
"""
|
"""
|
||||||
self.check_args(
|
self.check_args(
|
||||||
"",
|
"",
|
||||||
@ -134,7 +132,7 @@ class TestWaitForIt(unittest.TestCase):
|
|||||||
self.check_args(
|
self.check_args(
|
||||||
"localhost:8929 --timeout=1",
|
"localhost:8929 --timeout=1",
|
||||||
"",
|
"",
|
||||||
".*wait-for-it.sh: timeout occurred after waiting 1 seconds for localhost:8929",
|
".*timeout occurred after waiting 1 seconds for localhost:8929",
|
||||||
124
|
124
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -151,11 +149,10 @@ class TestWaitForIt(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
soc.close()
|
soc.close()
|
||||||
|
|
||||||
|
|
||||||
def test_failed_command_execution(self):
|
def test_failed_command_execution(self):
|
||||||
"""
|
"""
|
||||||
Check command failure. The command in question outputs STDERR and an
|
Check command failure. The command in question outputs STDERR and
|
||||||
exit code of 2
|
an exit code of 2
|
||||||
"""
|
"""
|
||||||
soc = self.open_local_port(port=8929)
|
soc = self.open_local_port(port=8929)
|
||||||
self.check_args(
|
self.check_args(
|
||||||
@ -166,7 +163,6 @@ class TestWaitForIt(unittest.TestCase):
|
|||||||
)
|
)
|
||||||
soc.close()
|
soc.close()
|
||||||
|
|
||||||
|
|
||||||
def test_command_after_connection_failure(self):
|
def test_command_after_connection_failure(self):
|
||||||
"""
|
"""
|
||||||
Test that a command still runs even if a connection times out
|
Test that a command still runs even if a connection times out
|
||||||
@ -175,10 +171,9 @@ class TestWaitForIt(unittest.TestCase):
|
|||||||
self.check_args(
|
self.check_args(
|
||||||
"localhost:8929 --timeout=1 -- echo \"CMD OUTPUT\"",
|
"localhost:8929 --timeout=1 -- echo \"CMD OUTPUT\"",
|
||||||
"CMD OUTPUT",
|
"CMD OUTPUT",
|
||||||
".*wait-for-it.sh: timeout occurred after waiting 1 seconds for localhost:8929",
|
".*timeout occurred after waiting 1 seconds for localhost:8929",
|
||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user