Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide a mockup server #16

Open
pylover opened this issue Jun 19, 2018 · 4 comments
Open

Provide a mockup server #16

pylover opened this issue Jun 19, 2018 · 4 comments
Assignees
Labels
feature add some ability
Milestone

Comments

@pylover
Copy link
Owner

pylover commented Jun 19, 2018

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
@mehrdad1373pedramfar
Copy link

mehrdad1373pedramfar commented Jun 25, 2018

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:

  1. Test: Write bunch of tests that will satisfy our needs from our mockup server
  2. Wsgi server and wsgi application: For satisfy our tests we should have a wsgi server and application
  3. Controllers: Rest controllers with regex dispaching
  4. Cli: Argument parser for bring this feature into bash cli

@mehrdad1373pedramfar
Copy link

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()

@mehrdad1373pedramfar
Copy link

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

@pylover
Copy link
Owner Author

pylover commented Jun 26, 2018

Nice, Thanks.

@mehrdad1373pedramfar mehrdad1373pedramfar self-assigned this Jun 27, 2018
mehrdad1373pedramfar added a commit that referenced this issue Jun 27, 2018
@pylover pylover added this to the WhenPigsFly milestone Aug 10, 2018
@pylover pylover added the feature add some ability label Aug 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature add some ability
Projects
None yet
Development

No branches or pull requests

2 participants