summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorAndrei Zeliankou <zelenkov@nginx.com>2020-04-14 02:35:04 +0100
committerAndrei Zeliankou <zelenkov@nginx.com>2020-04-14 02:35:04 +0100
commit0bfa09dfa0ec6a1474ba30d0e1f8aea832fbc1fc (patch)
tree99dd1db9a07c82aafd61b3afb03d12e65e0d399d /test
parent58cc13ab291cac5b13462006e3feb780178ef5f3 (diff)
downloadunit-0bfa09dfa0ec6a1474ba30d0e1f8aea832fbc1fc.tar.gz
unit-0bfa09dfa0ec6a1474ba30d0e1f8aea832fbc1fc.tar.bz2
Tests: minor fixes and style.
Diffstat (limited to 'test')
-rw-r--r--test/test_go_application.py10
-rw-r--r--test/test_java_application.py10
-rw-r--r--test/test_java_websockets.py26
-rw-r--r--test/test_node_application.py8
-rw-r--r--test/test_node_websockets.py26
-rw-r--r--test/test_perl_application.py10
-rw-r--r--test/test_php_application.py10
-rw-r--r--test/test_php_basic.py56
-rw-r--r--test/test_python_application.py16
-rw-r--r--test/test_python_basic.py69
-rw-r--r--test/test_python_procman.py6
-rw-r--r--test/test_routing.py2
-rw-r--r--test/test_ruby_application.py10
-rw-r--r--test/test_tls.py5
-rw-r--r--test/test_usr1.py2
-rw-r--r--test/unit/http.py8
16 files changed, 99 insertions, 175 deletions
diff --git a/test/test_go_application.py b/test/test_go_application.py
index 42429be7..c9d4ba77 100644
--- a/test/test_go_application.py
+++ b/test/test_go_application.py
@@ -89,6 +89,7 @@ class TestGoApplication(TestApplicationGo):
self.assertEqual(self.get()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -96,12 +97,13 @@ class TestGoApplication(TestApplicationGo):
'Content-Type': 'text/html',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
- self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ self.assertEqual(resp['body'], body, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Host': 'localhost',
@@ -109,10 +111,10 @@ class TestGoApplication(TestApplicationGo):
'Connection': 'close',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_go_application_cookies(self):
self.load('cookies')
diff --git a/test/test_java_application.py b/test/test_java_application.py
index 9d873d6b..7bd351a4 100644
--- a/test/test_java_application.py
+++ b/test/test_java_application.py
@@ -1085,6 +1085,7 @@ class TestJavaApplication(TestApplicationJava):
self.assertEqual(self.post()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Connection': 'keep-alive',
@@ -1092,12 +1093,13 @@ class TestJavaApplication(TestApplicationJava):
'Host': 'localhost',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
- self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ self.assertEqual(resp['body'], body, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Connection': 'close',
@@ -1105,10 +1107,10 @@ class TestJavaApplication(TestApplicationJava):
'Host': 'localhost',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_java_application_http_10(self):
self.load('empty')
diff --git a/test/test_java_websockets.py b/test/test_java_websockets.py
index e0dbf539..7ea04620 100644
--- a/test/test_java_websockets.py
+++ b/test/test_java_websockets.py
@@ -26,7 +26,7 @@ class TestJavaWebsockets(TestApplicationJava):
)
def close_connection(self, sock):
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
self.ws.frame_write(sock, self.ws.OP_CLOSE, self.ws.serialize_close())
@@ -441,12 +441,12 @@ class TestJavaWebsockets(TestApplicationJava):
_, sock, _ = self.ws.upgrade()
self.ws.frame_write(sock, self.ws.OP_PONG, '')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_7')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_7')
# 2_8
self.ws.frame_write(sock, self.ws.OP_PONG, 'unsolicited pong payload')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_8')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_8')
# 2_9
@@ -512,7 +512,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.check_close(sock, 1002, no_close=True)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_2')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_2')
sock.close()
# 3_3
@@ -530,7 +530,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.check_close(sock, 1002, no_close=True)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_3')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_3')
sock.close()
# 3_4
@@ -548,7 +548,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.check_close(sock, 1002, no_close=True)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_4')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_4')
sock.close()
# 3_5
@@ -734,7 +734,7 @@ class TestJavaWebsockets(TestApplicationJava):
# 5_4
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_4')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_4')
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2', fin=True)
frame = self.ws.frame_read(sock)
@@ -771,7 +771,7 @@ class TestJavaWebsockets(TestApplicationJava):
ping_payload = 'ping payload'
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_7')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_7')
self.ws.frame_write(sock, self.ws.OP_PING, ping_payload)
@@ -955,7 +955,7 @@ class TestJavaWebsockets(TestApplicationJava):
frame = self.ws.frame_read(sock)
self.check_frame(frame, True, self.ws.OP_PONG, 'pongme 2!')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_20')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_20')
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment5')
self.check_frame(
@@ -1088,7 +1088,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.check_close(sock, no_close=True)
self.ws.frame_write(sock, self.ws.OP_PING, '')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
@@ -1100,7 +1100,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.check_close(sock, no_close=True)
self.ws.frame_write(sock, self.ws.OP_TEXT, payload)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
@@ -1113,7 +1113,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.check_close(sock, no_close=True)
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
@@ -1128,7 +1128,7 @@ class TestJavaWebsockets(TestApplicationJava):
self.recvall(sock, read_timeout=1)
self.ws.frame_write(sock, self.ws.OP_PING, '')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
diff --git a/test/test_node_application.py b/test/test_node_application.py
index b80d17d3..174af15d 100644
--- a/test/test_node_application.py
+++ b/test/test_node_application.py
@@ -112,6 +112,7 @@ class TestNodeApplication(TestApplicationNode):
self.assertEqual(self.get()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -119,12 +120,13 @@ class TestNodeApplication(TestApplicationNode):
'Content-Type': 'text/html',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Host': 'localhost',
@@ -132,10 +134,10 @@ class TestNodeApplication(TestApplicationNode):
'Content-Type': 'text/html',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_node_application_write_buffer(self):
self.load('write_buffer')
diff --git a/test/test_node_websockets.py b/test/test_node_websockets.py
index cb6bf137..4ce727db 100644
--- a/test/test_node_websockets.py
+++ b/test/test_node_websockets.py
@@ -26,7 +26,7 @@ class TestNodeWebsockets(TestApplicationNode):
)
def close_connection(self, sock):
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
self.ws.frame_write(sock, self.ws.OP_CLOSE, self.ws.serialize_close())
@@ -460,12 +460,12 @@ class TestNodeWebsockets(TestApplicationNode):
_, sock, _ = self.ws.upgrade()
self.ws.frame_write(sock, self.ws.OP_PONG, '')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_7')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_7')
# 2_8
self.ws.frame_write(sock, self.ws.OP_PONG, 'unsolicited pong payload')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '2_8')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '2_8')
# 2_9
@@ -531,7 +531,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.check_close(sock, 1002, no_close=True)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_2')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_2')
sock.close()
# 3_3
@@ -549,7 +549,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.check_close(sock, 1002, no_close=True)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_3')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_3')
sock.close()
# 3_4
@@ -567,7 +567,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.check_close(sock, 1002, no_close=True)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty 3_4')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty 3_4')
sock.close()
# 3_5
@@ -753,7 +753,7 @@ class TestNodeWebsockets(TestApplicationNode):
# 5_4
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_4')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_4')
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2', fin=True)
frame = self.ws.frame_read(sock)
@@ -790,7 +790,7 @@ class TestNodeWebsockets(TestApplicationNode):
ping_payload = 'ping payload'
self.ws.frame_write(sock, self.ws.OP_TEXT, 'fragment1', fin=False)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_7')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_7')
self.ws.frame_write(sock, self.ws.OP_PING, ping_payload)
@@ -974,7 +974,7 @@ class TestNodeWebsockets(TestApplicationNode):
frame = self.ws.frame_read(sock)
self.check_frame(frame, True, self.ws.OP_PONG, 'pongme 2!')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', '5_20')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', '5_20')
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment5')
self.check_frame(
@@ -1107,7 +1107,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.check_close(sock, no_close=True)
self.ws.frame_write(sock, self.ws.OP_PING, '')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
@@ -1119,7 +1119,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.check_close(sock, no_close=True)
self.ws.frame_write(sock, self.ws.OP_TEXT, payload)
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
@@ -1132,7 +1132,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.check_close(sock, no_close=True)
self.ws.frame_write(sock, self.ws.OP_CONT, 'fragment2')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
@@ -1147,7 +1147,7 @@ class TestNodeWebsockets(TestApplicationNode):
self.recvall(sock, read_timeout=1)
self.ws.frame_write(sock, self.ws.OP_PING, '')
- self.assertEqual(self.recvall(sock, read_timeout=1), b'', 'empty sock')
+ self.assertEqual(self.recvall(sock, read_timeout=0.1), b'', 'empty soc')
sock.close()
diff --git a/test/test_perl_application.py b/test/test_perl_application.py
index a4bac623..cc4eb915 100644
--- a/test/test_perl_application.py
+++ b/test/test_perl_application.py
@@ -197,6 +197,7 @@ class TestPerlApplication(TestApplicationPerl):
self.assertEqual(self.get()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -204,12 +205,13 @@ class TestPerlApplication(TestApplicationPerl):
'Content-Type': 'text/html',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
- self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ self.assertEqual(resp['body'], body, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Host': 'localhost',
@@ -217,10 +219,10 @@ class TestPerlApplication(TestApplicationPerl):
'Content-Type': 'text/html',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_perl_body_io_fake(self):
self.load('body_io_fake')
diff --git a/test/test_php_application.py b/test/test_php_application.py
index c3645a99..48e1e815 100644
--- a/test/test_php_application.py
+++ b/test/test_php_application.py
@@ -183,6 +183,7 @@ class TestPHPApplication(TestApplicationPHP):
self.assertEqual(self.get()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -190,12 +191,13 @@ class TestPHPApplication(TestApplicationPHP):
'Content-Type': 'text/html',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
- self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ self.assertEqual(resp['body'], body, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Host': 'localhost',
@@ -203,10 +205,10 @@ class TestPHPApplication(TestApplicationPHP):
'Content-Type': 'text/html',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_php_application_conditional(self):
self.load('conditional')
diff --git a/test/test_php_basic.py b/test/test_php_basic.py
index 7ecff1b2..5fde3e00 100644
--- a/test/test_php_basic.py
+++ b/test/test_php_basic.py
@@ -37,9 +37,6 @@ class TestPHPBasic(TestControl):
'applications',
)
- def test_php_get_applications_prefix(self):
- self.conf(self.conf_app, 'applications')
-
self.assertEqual(
self.conf_get('applications'),
{
@@ -53,9 +50,6 @@ class TestPHPBasic(TestControl):
'applications prefix',
)
- def test_php_get_applications_prefix_2(self):
- self.conf(self.conf_app, 'applications')
-
self.assertEqual(
self.conf_get('applications/app'),
{
@@ -67,9 +61,6 @@ class TestPHPBasic(TestControl):
'applications prefix 2',
)
- def test_php_get_applications_prefix_3(self):
- self.conf(self.conf_app, 'applications')
-
self.assertEqual(self.conf_get('applications/app/type'), 'php', 'type')
self.assertEqual(
self.conf_get('applications/app/processes/spare'),
@@ -86,18 +77,12 @@ class TestPHPBasic(TestControl):
'listeners',
)
- def test_php_get_listeners_prefix(self):
- self.conf(self.conf_basic)
-
self.assertEqual(
self.conf_get('listeners'),
{"*:7080": {"pass": "applications/app"}},
'listeners prefix',
)
- def test_php_get_listeners_prefix_2(self):
- self.conf(self.conf_basic)
-
self.assertEqual(
self.conf_get('listeners/*:7080'),
{"pass": "applications/app"},
@@ -147,49 +132,24 @@ class TestPHPBasic(TestControl):
def test_php_delete(self):
self.conf(self.conf_basic)
- self.assertIn(
- 'error',
- self.conf_delete('applications/app'),
- 'delete app before listener',
- )
- self.assertIn(
- 'success', self.conf_delete('listeners/*:7080'), 'delete listener'
- )
- self.assertIn(
- 'success',
- self.conf_delete('applications/app'),
- 'delete app after listener',
- )
- self.assertIn(
- 'error', self.conf_delete('applications/app'), 'delete app again'
- )
+ self.assertIn('error', self.conf_delete('applications/app'))
+ self.assertIn('success', self.conf_delete('listeners/*:7080'))
+ self.assertIn('success', self.conf_delete('applications/app'))
+ self.assertIn('error', self.conf_delete('applications/app'))
def test_php_delete_blocks(self):
self.conf(self.conf_basic)
- self.assertIn(
- 'success',
- self.conf_delete('listeners'),
- 'listeners delete',
- )
-
- self.assertIn(
- 'success',
- self.conf_delete('applications'),
- 'applications delete',
- )
-
- self.assertIn(
- 'success',
- self.conf(self.conf_app, 'applications'),
- 'listeners restore',
- )
+ self.assertIn('success', self.conf_delete('listeners'))
+ self.assertIn('success', self.conf_delete('applications'))
+ self.assertIn('success', self.conf(self.conf_app, 'applications'))
self.assertIn(
'success',
self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'),
'applications restore',
)
+
if __name__ == '__main__':
TestPHPBasic.main()
diff --git a/test/test_python_application.py b/test/test_python_application.py
index 460cc804..5741d2d8 100644
--- a/test/test_python_application.py
+++ b/test/test_python_application.py
@@ -187,6 +187,7 @@ class TestPythonApplication(TestApplicationPython):
self.assertEqual(self.get()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -194,12 +195,13 @@ class TestPythonApplication(TestApplicationPython):
'Content-Type': 'text/html',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
- self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ self.assertEqual(resp['body'], body, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Host': 'localhost',
@@ -207,10 +209,10 @@ class TestPythonApplication(TestApplicationPython):
'Content-Type': 'text/html',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_python_keepalive_reconfigure(self):
self.skip_alerts.extend(
@@ -340,14 +342,16 @@ class TestPythonApplication(TestApplicationPython):
self.assertEqual(self.get()['status'], 200, 'init')
- (resp, sock) = self.http(
+ (_, sock) = self.http(
b"""GET / HTTP/1.1
""",
start=True,
raw=True,
- read_timeout=5,
+ no_recv=True,
)
+ self.assertEqual(self.get()['status'], 200)
+
self.assertIn(
'success',
self.conf({"listeners": {}, "applications": {}}),
diff --git a/test/test_python_basic.py b/test/test_python_basic.py
index 67a5f548..3233fca2 100644
--- a/test/test_python_basic.py
+++ b/test/test_python_basic.py
@@ -19,17 +19,9 @@ class TestPythonBasic(TestControl):
}
def test_python_get_empty(self):
- self.assertEqual(
- self.conf_get(), {'listeners': {}, 'applications': {}}, 'empty'
- )
-
- def test_python_get_prefix_listeners(self):
- self.assertEqual(self.conf_get('listeners'), {}, 'listeners prefix')
-
- def test_python_get_prefix_applications(self):
- self.assertEqual(
- self.conf_get('applications'), {}, 'applications prefix'
- )
+ self.assertEqual(self.conf_get(), {'listeners': {}, 'applications': {}})
+ self.assertEqual(self.conf_get('listeners'), {})
+ self.assertEqual(self.conf_get('applications'), {})
def test_python_get_applications(self):
self.conf(self.conf_app, 'applications')
@@ -50,9 +42,6 @@ class TestPythonBasic(TestControl):
'applications',
)
- def test_python_get_applications_prefix(self):
- self.conf(self.conf_app, 'applications')
-
self.assertEqual(
self.conf_get('applications'),
{
@@ -66,9 +55,6 @@ class TestPythonBasic(TestControl):
'applications prefix',
)
- def test_python_get_applications_prefix_2(self):
- self.conf(self.conf_app, 'applications')
-
self.assertEqual(
self.conf_get('applications/app'),
{
@@ -80,9 +66,6 @@ class TestPythonBasic(TestControl):
'applications prefix 2',
)
- def test_python_get_applications_prefix_3(self):
- self.conf(self.conf_app, 'applications')
-
self.assertEqual(
self.conf_get('applications/app/type'), 'python', 'type'
)
@@ -99,18 +82,12 @@ class TestPythonBasic(TestControl):
'listeners',
)
- def test_python_get_listeners_prefix(self):
- self.conf(self.conf_basic)
-
self.assertEqual(
self.conf_get('listeners'),
{"*:7080": {"pass": "applications/app"}},
'listeners prefix',
)
- def test_python_get_listeners_prefix_2(self):
- self.conf(self.conf_basic)
-
self.assertEqual(
self.conf_get('listeners/*:7080'),
{"pass": "applications/app"},
@@ -160,44 +137,18 @@ class TestPythonBasic(TestControl):
def test_python_delete(self):
self.conf(self.conf_basic)
- self.assertIn(
- 'error',
- self.conf_delete('applications/app'),
- 'delete app before listener',
- )
- self.assertIn(
- 'success', self.conf_delete('listeners/*:7080'), 'delete listener'
- )
- self.assertIn(
- 'success',
- self.conf_delete('applications/app'),
- 'delete app after listener',
- )
- self.assertIn(
- 'error', self.conf_delete('applications/app'), 'delete app again'
- )
+ self.assertIn('error', self.conf_delete('applications/app'))
+ self.assertIn('success', self.conf_delete('listeners/*:7080'))
+ self.assertIn('success', self.conf_delete('applications/app'))
+ self.assertIn('error', self.conf_delete('applications/app'))
def test_python_delete_blocks(self):
self.conf(self.conf_basic)
- self.assertIn(
- 'success',
- self.conf_delete('listeners'),
- 'listeners delete',
- )
-
- self.assertIn(
- 'success',
- self.conf_delete('applications'),
- 'applications delete',
- )
-
- self.assertIn(
- 'success',
- self.conf(self.conf_app, 'applications'),
- 'listeners restore',
- )
+ self.assertIn('success', self.conf_delete('listeners'))
+ self.assertIn('success', self.conf_delete('applications'))
+ self.assertIn('success', self.conf(self.conf_app, 'applications'))
self.assertIn(
'success',
self.conf({"*:7081": {"pass": "applications/app"}}, 'listeners'),
diff --git a/test/test_python_procman.py b/test/test_python_procman.py
index 8fb499f7..a2e6126c 100644
--- a/test/test_python_procman.py
+++ b/test/test_python_procman.py
@@ -196,7 +196,7 @@ class TestPythonProcman(TestApplicationPython):
)
self.assertIn(
'error',
- self.conf({"idle_timeout": -1}, self.app_proc,),
+ self.conf({"idle_timeout": -1}, self.app_proc),
'negative idle_timeout',
)
self.assertIn(
@@ -206,12 +206,12 @@ class TestPythonProcman(TestApplicationPython):
)
self.assertIn(
'error',
- self.conf({"spare": 2, "max": 1}, self.app_proc,),
+ self.conf({"spare": 2, "max": 1}, self.app_proc),
'spare gt max',
)
self.assertIn(
'error',
- self.conf({"spare": 0, "max": 0}, self.app_proc,),
+ self.conf({"spare": 0, "max": 0}, self.app_proc),
'max zero',
)
diff --git a/test/test_routing.py b/test/test_routing.py
index bf741706..ad793662 100644
--- a/test/test_routing.py
+++ b/test/test_routing.py
@@ -605,7 +605,7 @@ class TestRouting(TestApplicationProto):
self.assertIn(
'success',
self.conf_post(
- {"match": {"method": "POST"}, "action": {"return": 200},},
+ {"match": {"method": "POST"}, "action": {"return": 200}},
'routes',
),
'routes edit configure 6',
diff --git a/test/test_ruby_application.py b/test/test_ruby_application.py
index 83a71f96..bdaabe51 100644
--- a/test/test_ruby_application.py
+++ b/test/test_ruby_application.py
@@ -322,6 +322,7 @@ class TestRubyApplication(TestApplicationRuby):
self.assertEqual(self.get()['status'], 200, 'init')
+ body = '0123456789' * 500
(resp, sock) = self.post(
headers={
'Host': 'localhost',
@@ -329,12 +330,13 @@ class TestRubyApplication(TestApplicationRuby):
'Content-Type': 'text/html',
},
start=True,
- body='0123456789' * 500,
+ body=body,
read_timeout=1,
)
- self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
+ self.assertEqual(resp['body'], body, 'keep-alive 1')
+ body = '0123456789'
resp = self.post(
headers={
'Host': 'localhost',
@@ -342,10 +344,10 @@ class TestRubyApplication(TestApplicationRuby):
'Content-Type': 'text/html',
},
sock=sock,
- body='0123456789',
+ body=body,
)
- self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
+ self.assertEqual(resp['body'], body, 'keep-alive 2')
def test_ruby_application_constants(self):
self.load('constants')
diff --git a/test/test_tls.py b/test/test_tls.py
index 475e9919..d9dcf237 100644
--- a/test/test_tls.py
+++ b/test/test_tls.py
@@ -521,7 +521,6 @@ basicConstraints = critical,CA:TRUE"""
)
def test_tls_application_respawn(self):
- self.skip_alerts.append(r'process \d+ exited on signal 9')
self.load('mirror')
self.certificate()
@@ -530,7 +529,7 @@ basicConstraints = critical,CA:TRUE"""
self.add_tls(application='mirror')
- (resp, sock) = self.post_ssl(
+ (_, sock) = self.post_ssl(
headers={
'Host': 'localhost',
'Connection': 'keep-alive',
@@ -545,6 +544,8 @@ basicConstraints = critical,CA:TRUE"""
subprocess.call(['kill', '-9', app_id])
+ self.skip_alerts.append(r'process %s exited on signal 9' % app_id)
+
self.wait_for_record(
re.compile(
' (?!' + app_id + '#)(\d+)#\d+ "mirror" application started'
diff --git a/test/test_usr1.py b/test/test_usr1.py
index 204e2e0c..155303ea 100644
--- a/test/test_usr1.py
+++ b/test/test_usr1.py
@@ -55,7 +55,7 @@ class TestUSR1(TestApplicationPython):
self.load('log_body')
log_new = 'new.log'
- log_path = self.testdir + '/' + 'unit.log'
+ log_path = self.testdir + '/unit.log'
log_path_new = self.testdir + '/' + log_new
os.rename(log_path, log_path_new)
diff --git a/test/unit/http.py b/test/unit/http.py
index 8aacf18b..13384dc8 100644
--- a/test/unit/http.py
+++ b/test/unit/http.py
@@ -279,12 +279,8 @@ class TestHTTP(TestUnit):
def _parse_json(self, resp):
headers = resp['headers']
- self.assertIn('Content-Type', headers, 'Content-Type header set')
- self.assertEqual(
- headers['Content-Type'],
- 'application/json',
- 'Content-Type header is application/json',
- )
+ self.assertIn('Content-Type', headers)
+ self.assertEqual(headers['Content-Type'], 'application/json')
resp['body'] = json.loads(resp['body'])