In [ ]:
import sys
sys.path.append('/opt/rhc')
import rhc.micro as micro
import rhc.async as async
import logging
logging.basicConfig(level=logging.DEBUG)
In [ ]:
p=micro.load_connection([
'CONNECTION placeholder http://jsonplaceholder.typicode.com',
'RESOURCE document /posts/{id}',
])
async.wait(micro.connection.placeholder.document(1))
In [ ]:
class MyMock(object):
def document(self, method, path, headers, body):
print('method', method)
print('path', path)
print('headers', headers)
print('body', body)
return 'foo'
micro.connection.placeholder.mock = MyMock()
In [ ]:
async.wait(micro.connection.placeholder.document(1))
The mock is not called until the arguments provided to the partial are evaluated and prepared for the HTTP connection; this ensures that the mock data matches the actual connection data.
The mock is called with:
Notes:
Here is an example of content created from unused kwargs:
In [ ]:
async.wait(micro.connection.placeholder.document(1, test='value'))
In [ ]: