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

2017-04-04 Thread Matt Riedemann

On 4/4/2017 8:09 AM, 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-requ...@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-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


FWIW novaclient unit tests already use requests_mock:

https://github.com/openstack/python-novaclient/blob/7.1.0/novaclient/tests/unit/utils.py

However, the actual framework in there is confusing, at least to me.

--

Thanks,

Matt

__
OpenStack Development Mailing List (not for usage questions)
Unsubscribe: openstack-dev-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-04-04 Thread George Shuklin

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-requ...@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-requ...@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-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-04-04 Thread Monty Taylor

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-requ...@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-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


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

2017-04-04 Thread George Shuklin

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.


Does someone knew anything about httpretty and novaclient interaction? 
(I think keystoneauth1 and other openstack clients behaves the same way?).


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-requ...@lists.openstack.org?subject:unsubscribe
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev