[openstack-dev] [novaclient] novaclient and httpretty - unable to record

George Shuklin george.shuklin at gmail.com
Tue Apr 4 15:34:41 UTC 2017


Thank you very much for advise!

On 04/04/2017 04:09 PM, Monty Taylor wrote:
> On 04/04/2017 04:43 AM, George Shuklin wrote:
>> Sorry for asking in dev maillist, but it really looks like dev issue.
>>
>> I'm writing  application which relies on novaclient, glanceclient, etc.
>>
>> It's almost done, but I thought about adding end to end tests by
>> recording and actual requests and replies to openstack. I used httpretty
>> library for this. Unfortunately, it ignores all requests and unable to
>> record them.
>
> You might have better luck with either requests_mock or betamax. There 
> is a betamax test fixture in the keystoneauth1 that you can use if you 
> want to go the betamax route:
>
> http://git.openstack.org/cgit/openstack/keystoneauth/tree/keystoneauth1/tests/unit/test_betamax_fixture.py 
>
>
> If you'd rather go requests_mock (which is what I've been using to 
> great pleasure) you can look in the shade test suite for some examples 
> - although it's a big test suite so things get complex:
>
> http://git.openstack.org/cgit/openstack-infra/shade/tree/shade/tests/unit/base.py#n398 
>
>
> http://git.openstack.org/cgit/openstack-infra/shade/tree/shade/tests/unit/test_security_groups.py#n380 
>
>
>> Does someone knew anything about httpretty and novaclient interaction?
>> (I think keystoneauth1 and other openstack clients behaves the same 
>> way?).
>
> I unfortunately don't know about httpretty and keystoneauth. I don't 
> know of any specific reason it shouldn't work, but as I use the other 
> things I have never explored it.
>
>> Code example:
>>
>> import httpretty
>> from keystoneauth1 import identity
>> from keystoneauth1 import session
>> import novaclient.client
>> auth_data = {'tenant_name':'any', 'username': 'any', 'password': 'any',
>> 'auth_url': 'https://google.com/does-not-matter/'}
>> with httpretty.HTTPretty.record('test.json'):
>>     auth = identity.v2.Password(**auth_data)
>>     s = session.Session(auth=auth)
>>     cl = novaclient.client.Client('2', session=s)
>>     z = cl.flavors.find(name='SSD.30')
>>
>>
>> Thanks!
>>
>>
>> __________________________________________________________________________ 
>>
>> OpenStack Development Mailing List (not for usage questions)
>> Unsubscribe: 
>> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
>> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>
>
> __________________________________________________________________________ 
>
> OpenStack Development Mailing List (not for usage questions)
> Unsubscribe: 
> OpenStack-dev-request at lists.openstack.org?subject:unsubscribe
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev





More information about the OpenStack-dev mailing list