<s> from requests import Response <EOL> from cinderclient import base <EOL> from cinderclient import exceptions <EOL> from cinderclient . openstack . common . apiclient import base as common_base <EOL> from cinderclient . v1 import volumes <EOL> from cinderclient . tests . unit import utils <EOL> from cinderclient . tests . unit . v1 import fakes <EOL> cs = fakes . FakeClient ( ) <EOL> REQUEST_ID = '<STR_LIT>' <EOL> def create_response_obj_with_header ( ) : <EOL> resp = Response ( ) <EOL> resp . headers [ '<STR_LIT>' ] = REQUEST_ID <EOL> return resp <EOL> class BaseTest ( utils . TestCase ) : <EOL> def test_resource_repr ( self ) : <EOL> r = base . Resource ( None , dict ( foo = "<STR_LIT:bar>" , baz = "<STR_LIT>" ) ) <EOL> self . assertEqual ( "<STR_LIT>" , repr ( r ) ) <EOL> self . assertNotIn ( "<STR_LIT>" , repr ( r ) ) <EOL> def test_getid ( self ) : <EOL> self . assertEqual ( <NUM_LIT:4> , base . getid ( <NUM_LIT:4> ) ) <EOL> class TmpObject ( object ) : <EOL> id = <NUM_LIT:4> <EOL> self . assertEqual ( <NUM_LIT:4> , base . getid ( TmpObject ) ) <EOL> def test_eq ( self ) : <EOL> r1 = base . Resource ( None , { '<STR_LIT:id>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> r2 = base . Resource ( None , { '<STR_LIT:id>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT:hello>' } ) <EOL> self . assertNotEqual ( r1 , r2 ) <EOL> r1 = base . Resource ( None , { '<STR_LIT:id>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT:hello>' } ) <EOL> r2 = base . Resource ( None , { '<STR_LIT:id>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT:hello>' } ) <EOL> self . assertEqual ( r1 , r2 ) <EOL> r1 = base . Resource ( None , { '<STR_LIT:id>' : <NUM_LIT:1> } ) <EOL> r2 = volumes . Volume ( None , { '<STR_LIT:id>' : <NUM_LIT:1> } ) <EOL> self . assertNotEqual ( r1 , r2 ) <EOL> r1 = base . Resource ( None , { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:12> } ) <EOL> r2 = base . Resource ( None , { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT:12> } ) <EOL> self . assertEqual ( r1 , r2 ) <EOL> def test_findall_invalid_attribute ( self ) : <EOL> cs . volumes . findall ( vegetable = '<STR_LIT>' ) <EOL> self . assertRaises ( exceptions . NotFound , <EOL> cs . volumes . find , <EOL> vegetable = '<STR_LIT>' ) <EOL> def test_to_dict ( self ) : <EOL> r1 = base . Resource ( None , { '<STR_LIT:id>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT>' } ) <EOL> self . assertEqual ( { '<STR_LIT:id>' : <NUM_LIT:1> , '<STR_LIT:name>' : '<STR_LIT>' } , r1 . to_dict ( ) ) <EOL> def test_resource_object_with_request_ids ( self ) : <EOL> resp_obj = create_response_obj_with_header ( ) <EOL> r = base . Resource ( None , { "<STR_LIT:name>" : "<STR_LIT:1>" } , resp = resp_obj ) <EOL> self . assertEqual ( [ REQUEST_ID ] , r . request_ids ) <EOL> class ListWithMetaTest ( utils . TestCase ) : <EOL> def test_list_with_meta ( self ) : <EOL> resp = create_response_obj_with_header ( ) <EOL> obj = common_base . ListWithMeta ( [ ] , resp ) <EOL> self . assertEqual ( [ ] , obj ) <EOL> self . assertTrue ( hasattr ( obj , '<STR_LIT>' ) ) <EOL> self . assertEqual ( [ REQUEST_ID ] , obj . request_ids ) <EOL> class DictWithMetaTest ( utils . TestCase ) : <EOL> def test_dict_with_meta ( self ) : <EOL> resp = create_response_obj_with_header ( ) <EOL> obj = common_base . DictWithMeta ( [ ] , resp ) <EOL> self . assertEqual ( { } , obj ) <EOL> self . assertTrue ( hasattr ( obj , '<STR_LIT>' ) ) <EOL> self . assertEqual ( [ REQUEST_ID ] , obj . request_ids ) <EOL> class TupleWithMetaTest ( utils . TestCase ) : <EOL> def test_tuple_with_meta ( self ) : <EOL> resp = create_response_obj_with_header ( ) <EOL> obj = common_base . TupleWithMeta ( ( ) , resp ) <EOL> self . assertEqual ( ( ) , obj ) <EOL> self . assertTrue ( hasattr ( obj , '<STR_LIT>' ) ) <EOL> self . assertEqual ( [ REQUEST_ID ] , obj . request_ids ) </s>
