conftest.py
Go to the documentation of this file.
1 import threading
2 from http.server import HTTPServer, BaseHTTPRequestHandler
3 
4 import pytest
5 
6 
7 class ParameterServerMock(BaseHTTPRequestHandler):
8  """ mock server for unittest
9 
10  Parameter Server API: http://wiki.ros.org/ROS/Parameter%20Server%20API
11  Master Slave APIs: http://wiki.ros.org/ROS/Master_Slave_APIs
12  """
13  def do_POST(self):
14  self.send_response(200)
15  self.send_header("Content-type", "application/xml")
16  self.end_headers()
17  body = """<?xml version="1.0"?>
18  <methodResponse>
19  <params>
20  <param><value><int>-1</int></value></param>
21  <param><value><string>this is a dummy error response</string></value></param>
22  <param><value><int>0</int></value></param>
23  </params>
24  </methodResponse>"""
25  self.wfile.write(body.encode())
26 
27 
28 @pytest.fixture(scope="session", autouse=True)
30  server_address = ('', 11311)
31  httpd = HTTPServer(server_address, ParameterServerMock)
32  thread = threading.Thread(target=httpd.serve_forever)
33  thread.daemon = True
34  thread.start()
def run_mock_parameter_server(request)
Definition: conftest.py:29


mqtt_bridge
Author(s): Junya Hayashi
autogenerated on Mon Feb 15 2021 03:57:51