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
Adding an in-memory stub version of treq #96
Conversation
…sure that it has the same interface and will return stubbed responses if given an appropriate resource.
… that we can have a synchronous IBodyProducer instead of something that requires a cooperator.
…quests should have no body.
…we want to check if the expected headers is a strict subset of the actual headers. Fix bugs.
…equests and responses.
This is failing due to #97 |
Just a quick point of order to track provenance; @cyli is a Rackspace employee, and although this code originates from the APL2-licensed Mimic, the files in question have only been touched by other Rackspace employees and so she is authorized to relicense it as MIT to contribute it upstream to Treq. |
I just merged master to update the Travis results. |
self._agent = agent | ||
self._cookiejar = cookiejar or cookiejar_from_dict({}) | ||
self._bodyproducer = bodyproducer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This attribute should probably be called something more like dataToBodyProducer
since it is not itself an IBodyProducer
but rather the way that you get one.
Current coverage is
|
I think the codecov report is in fact noticing a problem - there are more 'partial' and 'missed' lines in this branch. That said - who added codecov to this repo? |
There are a couple of missing lines of coverage in
|
That should be what happens, yes. |
…ed the version requirement of twisted up to 13.2.0
I think that a pragma is a reasonable choice for now. |
…d ensure that it only accepts bytes or unicode.
…add test for AbortableStringTransport.abortConnection
Conflicts: setup.py
self.successResultOf(stub.content(resp))) | ||
|
||
|
||
class SequenceStringStubsTests(TestCase): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note to reviewers: I plan to write docs in a later PR, because don't want to make this PR already bigger than the monster it already is. But the API should look something like how these tests are written - maybe we can provide a convenience API like string_stub_treq([((expected request args), (expected response))])
instead of having to construct StubTreq(StringStubbingResource(SequenceStringStubs([...])))
?
…erted in a future PR to add this functionality back in.
Note to reviewer - I removed some code to make this PR smaller to review. For reference, 75b49b1 is the code that was removed, and is what I intend to submit for the next PR (should give some idea of what the API for stubbing responses should look like) |
Two things I wouldn’t know where else to mention:
|
Conflicts: requirements-dev.txt setup.py
|
||
def test_providing_resource_to_stub_treq(self): | ||
""" | ||
The resource provided to StubTreq is responds to every request no |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
stray "is" here
Couple of things I noticed while tinkering around in my REPL:
|
…meNotSupported) Thanks @radix!
@radix: thanks for finding that bug! Fixed it so it now bails out early if the response from the real agent already has a (failure) response |
I am a little surprised that making requests with This LGTM! |
Let's deal with the HTTPS support issue in a future version - that's a problem with treq itself, not this code :). |
Add an in-memory stub version of treq
Thanks to @glyph for the suggestion of using the request traversal agent from https://github.com/rackerlabs/mimic, which means that treq actually operates and produces a real response, so we don't have to make a verified fake response, and for help debugging HTTPS and request issues.
Part of addressing #27.
Was going to write the docs and tutorial next if this looks good.