<s> import sys <EOL> import unittest <EOL> from libcloud . utils . py3 import method_type <EOL> from libcloud . utils . py3 import httplib <EOL> from libcloud . compute . types import Provider <EOL> from libcloud . compute . providers import get_driver <EOL> from libcloud . compute . drivers . rackspace import RackspaceFirstGenNodeDriver <EOL> from libcloud . compute . drivers . rackspace import RackspaceNodeDriver <EOL> from libcloud . test . compute . test_openstack import OpenStack_1_0_Tests <EOL> from libcloud . test . compute . test_openstack import OpenStack_1_1_Tests , OpenStack_1_1_MockHttp <EOL> from libcloud . pricing import clear_pricing_data <EOL> from libcloud . test . secrets import RACKSPACE_NOVA_PARAMS <EOL> from libcloud . test . secrets import RACKSPACE_PARAMS <EOL> DEPRECATED_RACKSPACE_PROVIDERS = [ Provider . RACKSPACE_UK , <EOL> Provider . RACKSPACE_NOVA_BETA , <EOL> Provider . RACKSPACE_NOVA_DFW , <EOL> Provider . RACKSPACE_NOVA_LON , <EOL> Provider . RACKSPACE_NOVA_ORD ] <EOL> class RackspaceusFirstGenUsTests ( OpenStack_1_0_Tests ) : <EOL> should_list_locations = True <EOL> should_have_pricing = True <EOL> driver_klass = RackspaceFirstGenNodeDriver <EOL> driver_type = RackspaceFirstGenNodeDriver <EOL> driver_args = RACKSPACE_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> def test_error_is_thrown_on_accessing_old_constant ( self ) : <EOL> for provider in DEPRECATED_RACKSPACE_PROVIDERS : <EOL> try : <EOL> get_driver ( provider ) <EOL> except Exception : <EOL> e = sys . exc_info ( ) [ <NUM_LIT:1> ] <EOL> self . assertTrue ( str ( e ) . find ( '<STR_LIT>' ) != - <NUM_LIT:1> ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_list_sizes_pricing ( self ) : <EOL> sizes = self . driver . list_sizes ( ) <EOL> for size in sizes : <EOL> self . assertTrue ( size . price > <NUM_LIT:0> ) <EOL> class RackspaceusFirstGenUkTests ( OpenStack_1_0_Tests ) : <EOL> should_list_locations = True <EOL> should_have_pricing = True <EOL> driver_klass = RackspaceFirstGenNodeDriver <EOL> driver_type = RackspaceFirstGenNodeDriver <EOL> driver_args = RACKSPACE_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> def test_list_sizes_pricing ( self ) : <EOL> sizes = self . driver . list_sizes ( ) <EOL> for size in sizes : <EOL> self . assertTrue ( size . price > <NUM_LIT:0> ) <EOL> class RackspaceNovaMockHttp ( OpenStack_1_1_MockHttp ) : <EOL> def __init__ ( self , * args , ** kwargs ) : <EOL> super ( RackspaceNovaMockHttp , self ) . __init__ ( * args , ** kwargs ) <EOL> methods1 = OpenStack_1_1_MockHttp . __dict__ <EOL> names1 = [ m for m in methods1 if m . find ( '<STR_LIT>' ) == <NUM_LIT:0> ] <EOL> for name in names1 : <EOL> method = methods1 [ name ] <EOL> new_name = name . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> setattr ( self , new_name , method_type ( method , self , <EOL> RackspaceNovaMockHttp ) ) <EOL> def _v2_1337_os_networksv2 ( self , method , url , body , headers ) : <EOL> if method == '<STR_LIT:GET>' : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , self . json_content_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> elif method == '<STR_LIT:POST>' : <EOL> body = self . fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . ACCEPTED , body , self . json_content_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> raise NotImplementedError ( ) <EOL> def _v2_1337_os_networksv2_f13e5051_feea_416b_827a_1a0acc2dad14 ( self , <EOL> method , <EOL> url , body , <EOL> headers ) : <EOL> if method == '<STR_LIT>' : <EOL> body = '<STR_LIT>' <EOL> return ( httplib . ACCEPTED , body , self . json_content_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> raise NotImplementedError ( ) <EOL> class RackspaceNovaLonMockHttp ( RackspaceNovaMockHttp ) : <EOL> def _v2_0_tokens ( self , method , url , body , headers ) : <EOL> body = self . auth_fixtures . load ( '<STR_LIT>' ) <EOL> return ( httplib . OK , body , self . json_content_headers , <EOL> httplib . responses [ httplib . OK ] ) <EOL> class BaseRackspaceNovaTestCase ( object ) : <EOL> conn_classes = ( RackspaceNovaMockHttp , RackspaceNovaMockHttp ) <EOL> auth_url = '<STR_LIT>' <EOL> def create_driver ( self ) : <EOL> return self . driver_type ( * self . driver_args , ** self . driver_kwargs ) <EOL> def setUp ( self ) : <EOL> self . driver_klass . connectionCls . conn_classes = self . conn_classes <EOL> self . driver_klass . connectionCls . auth_url = self . auth_url <EOL> self . conn_classes [ <NUM_LIT:0> ] . type = None <EOL> self . conn_classes [ <NUM_LIT:1> ] . type = None <EOL> self . driver = self . create_driver ( ) <EOL> self . driver . connection . _populate_hosts_and_request_paths ( ) <EOL> clear_pricing_data ( ) <EOL> self . node = self . driver . list_nodes ( ) [ <NUM_LIT:1> ] <EOL> def test_service_catalog_contais_right_endpoint ( self ) : <EOL> self . assertEqual ( self . driver . connection . get_endpoint ( ) , <EOL> self . expected_endpoint ) <EOL> def test_list_sizes_pricing ( self ) : <EOL> sizes = self . driver . list_sizes ( ) <EOL> for size in sizes : <EOL> if size . ram > <NUM_LIT> : <EOL> self . assertTrue ( size . price > <NUM_LIT:0> ) <EOL> class RackspaceNovaDfwTests ( BaseRackspaceNovaTestCase , OpenStack_1_1_Tests ) : <EOL> driver_klass = RackspaceNodeDriver <EOL> driver_type = RackspaceNodeDriver <EOL> driver_args = RACKSPACE_NOVA_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> expected_endpoint = '<STR_LIT>' <EOL> class RackspaceNovaOrdTests ( BaseRackspaceNovaTestCase , OpenStack_1_1_Tests ) : <EOL> driver_klass = RackspaceNodeDriver <EOL> driver_type = RackspaceNodeDriver <EOL> driver_args = RACKSPACE_NOVA_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> expected_endpoint = '<STR_LIT>' <EOL> class RackspaceNovaIadTests ( BaseRackspaceNovaTestCase , OpenStack_1_1_Tests ) : <EOL> driver_klass = RackspaceNodeDriver <EOL> driver_type = RackspaceNodeDriver <EOL> driver_args = RACKSPACE_NOVA_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> expected_endpoint = '<STR_LIT>' <EOL> class RackspaceNovaLonTests ( BaseRackspaceNovaTestCase , OpenStack_1_1_Tests ) : <EOL> driver_klass = RackspaceNodeDriver <EOL> driver_type = RackspaceNodeDriver <EOL> driver_args = RACKSPACE_NOVA_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> conn_classes = ( RackspaceNovaLonMockHttp , RackspaceNovaLonMockHttp ) <EOL> auth_url = '<STR_LIT>' <EOL> expected_endpoint = '<STR_LIT>' <EOL> class RackspaceNovaSydTests ( BaseRackspaceNovaTestCase , OpenStack_1_1_Tests ) : <EOL> driver_klass = RackspaceNodeDriver <EOL> driver_type = RackspaceNodeDriver <EOL> driver_args = RACKSPACE_NOVA_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> expected_endpoint = '<STR_LIT>' <EOL> class RackspaceNovaHkgTests ( BaseRackspaceNovaTestCase , OpenStack_1_1_Tests ) : <EOL> driver_klass = RackspaceNodeDriver <EOL> driver_type = RackspaceNodeDriver <EOL> driver_args = RACKSPACE_NOVA_PARAMS <EOL> driver_kwargs = { '<STR_LIT>' : '<STR_LIT>' } <EOL> expected_endpoint = '<STR_LIT>' <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> sys . exit ( unittest . main ( ) ) </s>
