Main Page
+
Namespaces
Namespace List
+
Namespace Members
+
All
a
b
c
f
h
i
m
n
o
s
t
u
w
Functions
+
Variables
a
b
c
f
i
m
n
o
s
u
Typedefs
+
Classes
Class List
Class Hierarchy
+
Class Members
+
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
~
+
Functions
a
b
c
f
g
h
i
o
p
r
s
t
w
~
+
Variables
a
b
c
d
f
h
i
k
l
m
n
p
q
r
s
t
u
v
w
Typedefs
Enumerations
+
Enumerator
a
b
c
e
f
h
i
l
m
n
o
s
t
u
Related Functions
+
Files
File List
+
File Members
All
Functions
Variables
Macros
test
websocket_test.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
3
import
websocket
4
import
rospy
5
import
unittest
6
import
time
7
8
class
TestWebsocket
(unittest.TestCase):
9
def
setUp
(self):
10
self.
ws
= websocket.create_connection(
"ws://localhost:9849/websocket_echo"
)
11
12
def
tearDown
(self):
13
self.
ws
.close()
14
15
def
test_ok
(self):
16
self.
ws
.send(
"hello"
)
17
self.assertEqual(
"hello"
, self.
ws
.recv())
18
self.
ws
.send(
"test"
)
19
self.assertEqual(
"test"
, self.
ws
.recv())
20
self.
ws
.send(
"hi"
)
21
self.assertEqual(
"hi"
, self.
ws
.recv())
22
23
self.
ws
.ping(b
"test ping"
)
24
ping_echo = self.
ws
.recv_frame()
25
self.assertEqual(9, ping_echo.opcode)
26
self.assertEqual(b
"test ping"
, ping_echo.data)
27
28
self.
ws
.pong(b
"test pong"
)
29
pong_echo = self.
ws
.recv_frame()
30
self.assertEqual(10, pong_echo.opcode)
31
self.assertEqual(b
"test pong"
, pong_echo.data)
32
33
if
__name__ ==
'__main__'
:
34
time.sleep(1)
# ensure server is up
35
36
import
rostest
37
rospy.init_node(
'websocket_test'
)
38
rostest.rosrun(
'async_web_server_cpp'
,
'websocket'
, TestWebsocket)
websocket_test.TestWebsocket
Definition:
websocket_test.py:8
websocket_test.TestWebsocket.tearDown
def tearDown(self)
Definition:
websocket_test.py:12
websocket_test.TestWebsocket.setUp
def setUp(self)
Definition:
websocket_test.py:9
websocket_test.TestWebsocket.ws
ws
Definition:
websocket_test.py:10
websocket_test.TestWebsocket.test_ok
def test_ok(self)
Definition:
websocket_test.py:15
async_web_server_cpp
Author(s): Mitchell Wills
, Russel Toris
autogenerated on Mon Feb 28 2022 21:54:08