Tests: more perl tests.
This commit is contained in:
9
test/perl/header_equal_names/psgi.pl
Normal file
9
test/perl/header_equal_names/psgi.pl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
my $app = sub {
|
||||||
|
my ($environ) = @_;
|
||||||
|
|
||||||
|
return ['200', [
|
||||||
|
'Content-Length' => 0,
|
||||||
|
'Set-Cookie' => 'tc=one,two,three',
|
||||||
|
'Set-Cookie' => 'tc=four,five,six'
|
||||||
|
], []];
|
||||||
|
};
|
||||||
10
test/perl/input_read_parts/psgi.pl
Normal file
10
test/perl/input_read_parts/psgi.pl
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
my $app = sub {
|
||||||
|
my ($environ) = @_;
|
||||||
|
|
||||||
|
$len_1 = $environ->{'psgi.input'}->read(my $body_1, 4);
|
||||||
|
$len_2 = $environ->{'psgi.input'}->read(my $body_2, 4);
|
||||||
|
$len_3 = $environ->{'psgi.input'}->read(my $body_3, 2);
|
||||||
|
|
||||||
|
return ['200', ['Content-Length' => $len_1 + $len_2 + $len_3],
|
||||||
|
[$body_1 . $body_2 . $body_3]];
|
||||||
|
};
|
||||||
@@ -57,6 +57,12 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl):
|
|||||||
|
|
||||||
self.assertEqual(self.get()['body'], '', 'read empty')
|
self.assertEqual(self.get()['body'], '', 'read empty')
|
||||||
|
|
||||||
|
def test_perl_application_input_read_parts(self):
|
||||||
|
self.load('input_read_parts')
|
||||||
|
|
||||||
|
self.assertEqual(self.post(body='0123456789')['body'], '0123456789',
|
||||||
|
'input read parts')
|
||||||
|
|
||||||
@unittest.expectedFailure
|
@unittest.expectedFailure
|
||||||
def test_perl_application_input_read_offset(self):
|
def test_perl_application_input_read_offset(self):
|
||||||
self.load('input_read_offset')
|
self.load('input_read_offset')
|
||||||
@@ -80,6 +86,12 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl):
|
|||||||
|
|
||||||
self.assertIsNotNone(m, 'errors log')
|
self.assertIsNotNone(m, 'errors log')
|
||||||
|
|
||||||
|
def test_perl_application_header_equal_names(self):
|
||||||
|
self.load('header_equal_names')
|
||||||
|
|
||||||
|
self.assertListEqual(self.get()['headers']['Set-Cookie'],
|
||||||
|
['tc=one,two,three', 'tc=four,five,six'], 'header equal names')
|
||||||
|
|
||||||
def test_perl_application_header_pairs(self):
|
def test_perl_application_header_pairs(self):
|
||||||
self.load('header_pairs')
|
self.load('header_pairs')
|
||||||
|
|
||||||
@@ -100,7 +112,7 @@ class TestUnitPerlApplication(unit.TestUnitApplicationPerl):
|
|||||||
|
|
||||||
body = '0123456789' * 1000
|
body = '0123456789' * 1000
|
||||||
|
|
||||||
resp = self.get(body=body)['body']
|
resp = self.post(body=body)['body']
|
||||||
|
|
||||||
self.assertEqual(resp, body, 'body large')
|
self.assertEqual(resp, body, 'body large')
|
||||||
|
|
||||||
|
|||||||
@@ -237,7 +237,13 @@ class TestUnitHTTP(TestUnit):
|
|||||||
headers = {}
|
headers = {}
|
||||||
for line in headers_lines:
|
for line in headers_lines:
|
||||||
m = re.search('(.*)\:\s(.*)', line)
|
m = re.search('(.*)\:\s(.*)', line)
|
||||||
|
|
||||||
|
if m.group(1) not in headers:
|
||||||
headers[m.group(1)] = m.group(2)
|
headers[m.group(1)] = m.group(2)
|
||||||
|
elif isinstance(headers[m.group(1)], list):
|
||||||
|
headers[m.group(1)].append(m.group(2))
|
||||||
|
else:
|
||||||
|
headers[m.group(1)] = [headers[m.group(1)], m.group(2)]
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'status': int(status),
|
'status': int(status),
|
||||||
|
|||||||
Reference in New Issue
Block a user