GithubHelp home page GithubHelp logo

brunns / mbtest Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 13.0 551 KB

Opinionated Python wrapper & utils for the Mountebank over the wire test double tool

License: MIT License

Python 98.62% Makefile 1.38%

mbtest's People

Contributors

brunns avatar colinschoen avatar danjou avatar dependabot-preview[bot] avatar dependabot[bot] avatar erakli avatar jbackman avatar jbackman1 avatar pyup-bot avatar shimkomike avatar sshatun avatar yevhen-m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mbtest's Issues

Create a Imposter with Config File

Hello,

Thank you so much for developing this wonderful library! I want to know if there is anyway to create Imposter with config file?

I try to parse in the config file as json object via from_structure but it did not work for me.

` with open(f'C:\Users\wuwei\test-sv\test\imposters\test.json') as f:
data = json.load(f)

imposter = Imposter.from_structure(data['imposters'])`

And this is my config file
{ "imposters" : [{ "port": 1001, "protocol": "https", "name": "Tutorial", "stubs": [{ "predicates" : [{ "equals": { "method": "GET", "path": "/tutorial" } }], "responses" : [{ "is": { "statusCode": 200, "headers": { "Content-Type": "application/json" }, "body": { "message": "success" } } }]} ] }] }

Issue with MountebankServer.query_all_imposters()

it seems that when parsing the response of a mountebank imposter, it is expected that if a body is provided, a mode will also exist

response.mode = Response.Mode(inner["_mode"])
This is not always the case. If you submit the body as JSON, it does not require a mode and thus the mode is not provided. This causes the following issue when calling list(MountebankServer.query_all_imposters())

cls = <class 'mbtest.imposters.responses.HttpResponse'>, inner = {'body': {'hostname': '${HOSTNAME}'}, 'statusCode': 200}

    @classmethod
    def from_structure(cls, inner: JsonStructure) -> "HttpResponse":
        response = cls()
        if "body" in inner:
            response._body = inner["body"]
>       response.mode = Response.Mode(inner["_mode"])
E       KeyError: '_mode'

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

Initial Update

The bot created this issue to inform you that pyup.io has been set up on this repo.
Once you have closed it, the bot will open pull requests for updates as soon as they are available.

HttpRequest with with body as dict when Content-Type is JSON

Would it be possible to add support for converting the body to a dict when the response is of Content-Type JSON?
That way, the matcher could be rewritten to support has_entries() rather than matching the whole string.

Or is this already possible in some other way?

Allow retrieval of proxied request responses via the API using the replayable option

The record and replay functionality of Mountebank is really useful in that it allows creation of imposters based on real requests and responses - it's a big workflow win. Mountebank offers this functionality natively (see http://www.mbtest.org/docs/api/overview#get-imposter), but it would be nice if this library wrapped the API calls for usability. I'm new to the codebase, but on first glance it seems like it'd be fairly easy to add this as a new method to the MountebankServerclass.

Allow modification of an existing mountebank server

The MountebankServer allows addition of imposters to an already running Mountebank mock server, but does not have the ability to update or add to existing stubs or services.

It would be useful to be able to read the configuration of an existing mountebank mock server (which MountebankServer .query_all_imposters() can already do) and set that as the MountebankServer._running_imposters. This would allow manipulation of existing impostors as well as addition of new stubs to existing impostors,

Python 2.7 support

Are you set on dropping Python 2.7 support? I'd be happy to help maintain this if you are willing to keep it.

Look for Mountebank install as a default

Running integration tests fail because the mountebank installation must be installed in a specific location.

The DEFAULT_MB_EXECUTABLE points to a location that doesn't always exist.

#55 to fix this

2.6.0 version latest in PyPi

As I can see the latest version on that moment is 2.5.2

But the latest version in PyPi is 2.6.0 - https://pypi.org/project/mbtest/

And if you run pip install mbtest it will install 2.6.0 version:

Installing collected packages: mbtest
  Attempting uninstall: mbtest
    Found existing installation: mbtest 2.5.2
    Uninstalling mbtest-2.5.2:
      Successfully uninstalled mbtest-2.5.2
Successfully installed mbtest-2.6.0

Minor version release to include support for PATCH in predicates

Support for PATCH requests in HTTP predicates was merged a few days after the last release (#22) - are there plans for a new release version any time soon? Would be super useful for us to have this functionality included from a PyPi release, rather than having to install it via Git.

Cheers,

Garry

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.