FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
UnrealEnginePython/tests/test_http.py at pr_array_params · dfb/UnrealEnginePython · GitHub
dfb
UnrealEnginePython
Repository navigation
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
UnrealEnginePython
/
tests
/
test_http.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
50 lines (41 loc) · 1.72 KB
Breadcrumbs
UnrealEnginePython
/
tests
/
test_http.py
Copy path
File metadata and controls
50 lines (41 loc) · 1.72 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import
unittest
import
unreal_engine
as
ue
from
unreal_engine
import
IHttpRequest
import
json
class
TestHttp
(
unittest
.
TestCase
):
def
test_user_agent
(
self
):
request
=
IHttpRequest
(
'GET'
,
'http://httpbin.org/user-agent'
)
request
.
set_header
(
'User-Agent'
,
'UnrealEnginePython_test'
)
request
.
process_request
()
while
request
.
get_status
()
<
2
:
request
.
tick
(
0.01
)
j
=
json
.
loads
(
request
.
get_response
().
get_content_as_string
())
self
.
assertEqual
(
j
[
'user-agent'
],
'UnrealEnginePython_test'
)
def
test_post_data
(
self
):
request
=
IHttpRequest
(
'POST'
,
'http://httpbin.org/post'
)
request
.
set_content
(
'test'
)
request
.
process_request
()
while
request
.
get_status
()
<
2
:
request
.
tick
(
0.01
)
response
=
request
.
get_response
()
self
.
assertEqual
(
response
.
get_response_code
(),
200
)
j
=
json
.
loads
(
response
.
get_content_as_string
())
self
.
assertEqual
(
j
[
'form'
][
'test'
],
''
)
def
test_headers
(
self
):
request
=
IHttpRequest
()
request
.
set_header
(
'One'
,
'Two'
)
request
.
set_header
(
'Test1'
,
'Test2'
)
self
.
assertEqual
(
request
.
get_all_headers
(), [
'One: Two'
,
'Test1: Test2'
])
def
test_get_url
(
self
):
request
=
IHttpRequest
()
self
.
assertEqual
(
request
.
get_url
(),
''
)
request
.
set_url
(
'http://unrealengine.com'
)
self
.
assertEqual
(
request
.
get_url
(),
'http://unrealengine.com'
)
def
test_get_url_parameter
(
self
):
request
=
IHttpRequest
()
request
.
set_url
(
'http://unrealengine.com/?test=17&bar=30'
)
self
.
assertEqual
(
request
.
get_url_parameter
(
'bar'
),
'30'
)
# fail ! (maybe a bug ?)
#self.assertEqual(request.get_url_parameter('test'), '17')
if
__name__
==
'__main__'
:
unittest
.
main
(
exit
=
False
)
Back
|
FazBrowse Home
|
New Git URL