bddrest
bddrest copied to clipboard
Provide a mockup server
Please provide a mockup server to serve the generate yaml files as HTTP REST api.
For example:
bddrest mockup --bind [9.9.9.9:]8090 --base-url apiv1 myfile.yml yourfile.yml *.yml
According to the discussion with Vahid and the rest of the back-end team, it is been decided to go through this task with this sequential parts:
-
Test: Write bunch of tests that will satisfy our needs from our mockup server -
Wsgi server and wsgi application: For satisfy our tests we should have a wsgi server and application -
Controllers: Rest controllers with regex dispaching -
Cli: Argument parser for bring this feature into bash cli
This http-server in restfulpy.testing.mockup.http.py is going to be so useful:
@contextlib.contextmanager
def http_server(app=None, handler_class=WSGIRequestHandler, server_class=WSGIServer, bind=('', 0)):
server = server_class(bind, handler_class)
if app:
assert isinstance(server, WSGIServer)
server.set_app(app)
thread = threading.Thread(target=server.serve_forever, name='sa-media test server.', daemon=True)
thread.start()
url = 'http://localhost:%s' % server.server_address[1]
yield server, url
server.shutdown()
thread.join()
But there is a few things that should be mentioned here:
- we need to bind our mockup-server to given port(not random), it means that if user didn't set a port we should have default port
Nice, Thanks.