Comments (8)
That seems like a reasonable feature. Is it something you could create yourself and provide a pull request? Or at least a starting point from which we can collaborate?
One area where things might get a bit messy is that the fundamental architecture of wsgi-intercept is rather old so we'd need to decide if we just want to hack something into that structure, or tune up things in general (for example there's been discussion of using context managers throughout).
Anyway: Do you want the callbacks to happen directly before and after an intercepted request happens, or before the intercept it established? I assume the former?
from wsgi-intercept.
Assuming you only support 2.6 and above, I think a general overhaul of the code is due, which is good. However, I think a basic callback can be established even with the existing codebase. I will try to hack on it and see what I come up with.
Regarding your question -- what I want is a hook to be called after we've decided a request is to be intercepted, but before calling the actual backing wsgi app to handle the request, and also a hook to call just before returning the data to the mocked interfaces (requests/urllib2/whatever)
from wsgi-intercept.
@vmalloc did you ever make any headway on this?
I'm still wanting to do a general overhaul on the code but haven't had the time or head space to do so but maybe able to eek some time now that I've created gabbi and it uses wsgi-intercept and thus both are getting some use within OpenStack.
from wsgi-intercept.
@cdent nope, couldn't find the time to hack on it - it requires a lot of work. I'm using our own Flask-Loopback for now, which is less flexible but gets the job done for our needs...
from wsgi-intercept.
It has occured to me while working on 9d73597 that perhaps the easiest way to make this happen is to not use hooks at all. Instead just wrap the wsgi app being tested in another wsgi app callable? That covers the use case doesn't it? The ability to add code before and after the app is run?
If not, could you provide a bit more clarity on what you're trying to do? Thanks.
from wsgi-intercept.
I currently use Flask-Loopback to simulate a 3rd party product, and want to be able to change its state before each request is made to it. All this should be done without changing any client code - so I keep all of my simulation code in the test setup area. I guess we can make it work with a wsgi wrapper, but it would be nice to add a dedicated hook because the library knows when it intercepts a call anyways.
from wsgi-intercept.
I'll continue thinking about this but right now I don't have a clear idea on how to best implement it. If you've got some ideas please add them here.
In the meantime I'm releasing a new version today that has the context manager stuff referenced above. I'm hoping that's going to start a process of refactoring that will make things like hooks a bit easier.
from wsgi-intercept.
Perhaps for your needs is suitable a special module https://pypi.python.org/pypi/before_after
from wsgi-intercept.
Related Issues (20)
- kwarg error when $http_proxy is set in environ HOT 7
- Including LICENSE file in the code repository and Adding it in the Manifest file HOT 4
- unexpected keyword argument 'source_address' HOT 3
- Please allow to disable internet tests HOT 3
- wsgi_intercept.make_environ turns headers into unicode HOT 3
- When using the url arg to an Interceptor, if there is no port in the url an error happens
- wsgi-intercept should build in some character encoding checks
- Write ignores response body when first item in iterable is an empty string HOT 1
- urllib3 intercept cause TypeError with https URL HOT 8
- Logs / errors are lost due to `wsgi.errors` not extracted HOT 4
- Interceptor.uninstall_interceptor turns off intercept for all intercepts using the same module
- Pypi sdist tarball doesn't have README.rst HOT 3
- Missing 2 required positional arguments: 'environ' and 'start_response' with Django 2.2 HOT 4
- With httplib2 0.14.0 many tests fail HOT 9
- HTTPS connections with Requests library don't support verify=False to outside domains HOT 7
- Support aiohttp HOT 2
- Simple example fails with Python 2 HOT 5
- PEP517 HOT 4
- Incompatibility with pytest 7.2.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wsgi-intercept.