brunns / mbtest Goto Github PK
View Code? Open in Web Editor NEWOpinionated Python wrapper & utils for the Mountebank over the wire test double tool
License: MIT License
Opinionated Python wrapper & utils for the Mountebank over the wire test double tool
License: MIT License
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" } } }]} ] }] }
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
mbtest/src/mbtest/imposters/responses.py
Line 77 in ef7b875
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'
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.
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.
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?
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 MountebankServer
class.
This would ensure that the from_structure functions are added to any new JsonSerializable subclasses. Like so:
@staticmethod
@abstractmethod
def from_structure(structure): # pragma: no cover
raise NotImplementedError()
CC @colinschoen
Hi Simon,
I think a mistake may have been made when cutting a release for mbtest
1.3.0
and 1.4.0
.
https://github.com/brunns/mbtest/compare/1.2.0..1.4.0
Notice that python2.7 support is removed however the 1.x-backports-2.7-compatible
branch looks good:
https://github.com/brunns/mbtest/blob/1.x-backports-2.7-compatible/setup.py#L50
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,
Travis seems to have pretty much abandoned free support for OSS, so try GitHub actions instead.
Are you set on dropping Python 2.7 support? I'd be happy to help maintain this if you are willing to keep it.
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
Build broken due to actions/runner-images#8104
I can see you have Predicate.xpath
, but there's no jsonpath
. Any plans to add it?
The library does not work without a local installation, this can be a drawback in CI/CD environments where a docker based configuration is preferable.
I'm see it in master, but latest release 2.7.0 don't include it...
https://github.com/brunns/mbtest/blob/master/src/mbtest/imposters/imposters.py
mbtest/src/mbtest/imposters/responses.py
Line 152 in 685bc0e
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
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
Dependabot couldn't authenticate with https://pypi.python.org/simple/.
You can provide authentication details in your Dependabot dashboard by clicking into the account menu (in the top right) and selecting 'Config variables'.
It's the right thing to do.
Question is, do we want main
or trunk
?
Add and test new attributes introduced in version 2.4.
Hi,
if I understand these docs correctly, proxies can have decorate behavior: https://www.mbtest.org/docs/api/proxies#proxy-add-decorate-behavior
Can this be supported in the library?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.