Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gevent
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
gevent
Commits
9b9a9ab1
Commit
9b9a9ab1
authored
Apr 08, 2010
by
Denis Bilenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove some unnecessary tests
parent
6049ae43
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
48 deletions
+46
-48
greentest/wsgi_test.py
greentest/wsgi_test.py
+46
-48
No files found.
greentest/wsgi_test.py
View file @
9b9a9ab1
...
...
@@ -222,27 +222,19 @@ class TestCase(greentest.TestCase):
return
socket
.
create_connection
((
'127.0.0.1'
,
self
.
port
))
class
TestHttpdBasic
(
TestCase
):
class
CommonTests
(
TestCase
):
@
staticmethod
def
application
(
env
,
start_response
):
path
=
env
[
'PATH_INFO'
]
if
path
==
'/'
:
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
"hello world"
]
else
:
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
"not found"
]
def
test_001_server
(
self
):
sock
=
self
.
connect
()
sock
.
sendall
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
Connection: close
\
r
\
n
\
r
\
n
'
)
result
=
sock
.
makefile
().
read
()
sock
.
close
()
self
.
assert_
(
result
.
startswith
(
'HTTP/1.1 200 OK
\
r
\
n
'
),
result
)
self
.
assert_
(
result
.
endswith
(
'hello world'
),
result
)
def
test_basic
(
self
):
fd
=
self
.
connect
().
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
,
body
=
'hello world'
)
fd
.
write
(
'GET /notexist HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
,
code
=
404
,
reason
=
'Not Found'
,
body
=
'not found'
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
,
body
=
'hello world'
)
fd
.
close
()
def
SKIP_test_002
_pipeline
(
self
):
def
XXXtest
_pipeline
(
self
):
fd
=
self
.
connect
().
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
+
'GET /notexist HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
,
body
=
'hello world'
)
...
...
@@ -254,16 +246,7 @@ class TestHttpdBasic(TestCase):
finally
:
timeout
.
cancel
()
def
test_003_passing_non_int_to_read
(
self
):
# This should go in greenio_test
fd
=
self
.
connect
().
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
cancel
=
gevent
.
Timeout
.
start_new
(
1
,
RuntimeError
)
self
.
assertRaises
(
TypeError
,
fd
.
read
,
"This shouldn't work"
)
cancel
.
cancel
()
fd
.
close
()
def
test_004_connection_close
(
self
):
def
test_connection_close
(
self
):
fd
=
self
.
connect
().
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
)
...
...
@@ -290,39 +273,53 @@ class TestHttpdBasic(TestCase):
self
.
assertEqual
(
status
,
'414'
)
fd
.
close
()
def
test_008_correctresponse
(
self
):
class
TestNoChunks
(
CommonTests
):
# when returning a list of strings a shortcut is employed by the server:
# it calculates the content-length and joins all the chunks before sending
validator
=
None
@
staticmethod
def
application
(
env
,
start_response
):
path
=
env
[
'PATH_INFO'
]
if
path
==
'/'
:
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
'hello '
,
'world'
]
else
:
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/plain'
)])
return
[
'not '
,
'found'
]
def
test
(
self
):
fd
=
self
.
connect
().
makefile
(
bufsize
=
1
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
)
fd
.
write
(
'GET /notexist HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
,
code
=
404
,
reason
=
'Not Found'
)
fd
.
write
(
'GET / HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
read_http
(
fd
)
fd
.
close
()
response
=
read_http
(
fd
,
body
=
'hello world'
)
assert
response
.
chunks
is
None
,
response
.
chunks
response
.
assertHeader
(
'Content-Length'
,
'11'
)
fd
.
write
(
'GET /not-found HTTP/1.1
\
r
\
n
Host: localhost
\
r
\
n
\
r
\
n
'
)
response
=
read_http
(
fd
,
code
=
404
,
reason
=
'Not Found'
,
body
=
'not found'
)
assert
response
.
chunks
is
None
,
response
.
chunks
response
.
assertHeader
(
'Content-Length'
,
'9'
)
class
TestExplicitContentLength
(
TestHttpdBasic
):
class
TestExplicitContentLength
(
TestNoChunks
):
# when returning a list of strings a shortcut is empoyed by the server - it caculates the content-length
@
staticmethod
def
application
(
env
,
start_response
):
path
=
env
[
'PATH_INFO'
]
if
path
==
'/'
:
msg
=
'hello world'
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
),
(
'Content-Length'
,
str
(
len
(
msg
)))])
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
),
(
'Content-Length'
,
'11'
)])
return
[
'hello '
,
'world'
]
else
:
msg
=
'not found'
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/plain'
),
(
'Content-Length'
,
str
(
len
(
msg
)))])
return
[
msg
]
start_response
(
'404 Not Found'
,
[(
'Content-Type'
,
'text/plain'
),
(
'Content-Length'
,
'9'
)])
return
[
'not '
,
'found'
]
class
TestYield
(
TestHttpdBasic
):
class
TestYield
(
CommonTests
):
@
staticmethod
def
hello_world_yield
(
env
,
start_response
):
def
application
(
env
,
start_response
):
path
=
env
[
'PATH_INFO'
]
if
path
==
'/'
:
start_response
(
'200 OK'
,
[(
'Content-Type'
,
'text/plain'
)])
...
...
@@ -617,6 +614,7 @@ class HTTPRequest(urllib2.Request):
def
get_method
(
self
):
return
self
.
method
del
CommonTests
if
__name__
==
'__main__'
:
greentest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment