summaryrefslogtreecommitdiffhomepage
path: root/test/test_node_application.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_node_application.py')
-rw-r--r--test/test_node_application.py54
1 files changed, 29 insertions, 25 deletions
diff --git a/test/test_node_application.py b/test/test_node_application.py
index 5dedb5a3..cd64fefa 100644
--- a/test/test_node_application.py
+++ b/test/test_node_application.py
@@ -28,7 +28,8 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
resp = self.post(headers={
'Host': 'localhost',
'Content-Type': 'text/html',
- 'Custom-Header': 'blah'
+ 'Custom-Header': 'blah',
+ 'Connection': 'close'
}, body=body)
self.assertEqual(resp['status'], 200, 'status')
@@ -43,10 +44,11 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
raw_headers = headers.pop('Request-Raw-Headers')
self.assertRegex(raw_headers, r'^(?:Host|localhost|Content-Type|' \
- 'text\/html|Custom-Header|blah|Content-Length|17|,)+$',
- 'raw headers')
+ 'text\/html|Custom-Header|blah|Content-Length|17|Connection|' \
+ 'close|,)+$', 'raw headers')
self.assertDictEqual(headers, {
+ 'Connection': 'close',
'Content-Length': str(len(body)),
'Content-Type': 'text/html',
'Request-Method': 'POST',
@@ -91,17 +93,17 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.load('mirror')
(resp, sock) = self.post(headers={
+ 'Host': 'localhost',
'Connection': 'keep-alive',
- 'Content-Type': 'text/html',
- 'Host': 'localhost'
+ 'Content-Type': 'text/html'
}, start=True, body='0123456789' * 500)
self.assertEqual(resp['body'], '0123456789' * 500, 'keep-alive 1')
resp = self.post(headers={
+ 'Host': 'localhost',
'Connection': 'close',
- 'Content-Type': 'text/html',
- 'Host': 'localhost'
+ 'Content-Type': 'text/html'
}, sock=sock, body='0123456789')
self.assertEqual(resp['body'], '0123456789', 'keep-alive 2')
@@ -112,7 +114,6 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.get()['body'], '6\r\nbuffer\r\n0\r\n\r\n',
'write buffer')
- @unittest.expectedFailure
def test_node_application_write_callback(self):
self.load('write_callback')
@@ -121,11 +122,10 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback'),
'write callback')
- def test_node_application_write_before_writeHead(self):
- self.skip_alerts.append(r'process \d+ exited on signal')
+ def test_node_application_write_before_write_head(self):
self.load('write_before_write_head')
- self.get()
+ self.assertEqual(self.get()['status'], 200, 'write before writeHead')
def test_node_application_double_end(self):
self.load('double_end')
@@ -144,7 +144,8 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
resp = self.get(headers={
'Host': 'localhost',
- 'X-Remove': 'X-Header'
+ 'X-Remove': 'X-Header',
+ 'Connection': 'close'
})
self.assertEqual(resp['headers']['Was-Header'], 'true', 'was header')
self.assertEqual(resp['headers']['Has-Header'], 'false', 'has header')
@@ -155,7 +156,8 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.get(headers={
'Host': 'localhost',
- 'X-Remove': 'blah'
+ 'X-Remove': 'blah',
+ 'Connection': 'close'
})['headers']['Has-Header'], 'true', 'remove header nonexisting')
def test_node_application_update_header(self):
@@ -182,7 +184,6 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.get()['headers']['X-Type'], 'number',
'get header type')
- @unittest.expectedFailure
def test_node_application_header_name_case(self):
self.load('header_name_case')
@@ -197,20 +198,20 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.post(headers={
'Host': 'localhost',
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html',
+ 'Connection': 'close'
}, body='callback')['status'], 200, 'promise handler request')
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback'),
'promise handler')
- @unittest.expectedFailure
def test_node_application_promise_handler_write_after_end(self):
- self.skip_alerts.append(r'process \d+ exited on signal')
self.load('promise_handler')
self.assertEqual(self.post(headers={
'Host': 'localhost',
'Content-Type': 'text/html',
- 'X-Write-Call': '1'
+ 'X-Write-Call': '1',
+ 'Connection': 'close'
}, body='callback')['status'], 200,
'promise handler request write after end')
@@ -219,7 +220,8 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.post(headers={
'Host': 'localhost',
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html',
+ 'Connection': 'close'
}, body='end')['status'], 200, 'promise end request')
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback'),
'promise end')
@@ -229,7 +231,8 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.post(headers={
'Host': 'localhost',
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html',
+ 'Connection': 'close'
}, body='callback1')
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback1'),
@@ -237,7 +240,8 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.post(headers={
'Host': 'localhost',
- 'Content-Type': 'text/html'
+ 'Content-Type': 'text/html',
+ 'Connection': 'close'
}, body='callback2')
self.assertTrue(self.waitforfiles(self.testdir + '/node/callback2'),
@@ -249,13 +253,11 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertNotIn('status', self.get(), 'header name valid')
- @unittest.expectedFailure
def test_node_application_header_value_object(self):
self.load('header_value_object')
self.assertIn('X-Header', self.get()['headers'], 'header value object')
- @unittest.expectedFailure
def test_node_application_get_header_names(self):
self.load('get_header_names')
@@ -267,12 +269,14 @@ class TestUnitNodeApplication(unit.TestUnitApplicationNode):
self.assertEqual(self.get(headers={
'Host': 'localhost',
- 'X-Header': 'length'
+ 'X-Header': 'length',
+ 'Connection': 'close'
})['headers']['X-Has-Header'], 'false', 'has header length')
self.assertEqual(self.get(headers={
'Host': 'localhost',
- 'X-Header': 'Date'
+ 'X-Header': 'Date',
+ 'Connection': 'close'
})['headers']['X-Has-Header'], 'false', 'has header date')
def test_node_application_write_multiple(self):