<s> """<STR_LIT>""" <EOL> import mock <EOL> from requests_mock . contrib import fixture <EOL> from keystoneauth1 import session <EOL> from openstackclient . api import object_store_v1 as object_store <EOL> from openstackclient . tests import utils <EOL> FAKE_ACCOUNT = '<STR_LIT>' <EOL> FAKE_AUTH = '<STR_LIT>' <EOL> FAKE_URL = '<STR_LIT>' + FAKE_ACCOUNT <EOL> FAKE_CONTAINER = '<STR_LIT>' <EOL> FAKE_OBJECT = '<STR_LIT>' <EOL> LIST_CONTAINER_RESP = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> ] <EOL> LIST_OBJECT_RESP = [ <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:text>' } , <EOL> { '<STR_LIT:name>' : '<STR_LIT>' , '<STR_LIT>' : <NUM_LIT> , '<STR_LIT>' : '<STR_LIT:text>' } , <EOL> ] <EOL> class TestObjectAPIv1 ( utils . TestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestObjectAPIv1 , self ) . setUp ( ) <EOL> sess = session . Session ( ) <EOL> self . api = object_store . APIv1 ( session = sess , endpoint = FAKE_URL ) <EOL> self . requests_mock = self . useFixture ( fixture . Fixture ( ) ) <EOL> class TestContainer ( TestObjectAPIv1 ) : <EOL> def setUp ( self ) : <EOL> super ( TestContainer , self ) . setUp ( ) <EOL> def test_container_create ( self ) : <EOL> headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> headers = headers , <EOL> status_code = <NUM_LIT> , <EOL> ) <EOL> ret = self . api . container_create ( container = '<STR_LIT>' ) <EOL> data = { <EOL> '<STR_LIT>' : FAKE_ACCOUNT , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . assertEqual ( data , ret ) <EOL> def test_container_delete ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> status_code = <NUM_LIT> , <EOL> ) <EOL> ret = self . api . container_delete ( container = '<STR_LIT>' ) <EOL> self . assertIsNone ( ret ) <EOL> def test_container_list_no_options ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL , <EOL> json = LIST_CONTAINER_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . container_list ( ) <EOL> self . assertEqual ( LIST_CONTAINER_RESP , ret ) <EOL> def test_container_list_prefix ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> json = LIST_CONTAINER_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . container_list ( <EOL> prefix = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( LIST_CONTAINER_RESP , ret ) <EOL> def test_container_list_marker_limit_end ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> json = LIST_CONTAINER_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . container_list ( <EOL> marker = '<STR_LIT>' , <EOL> limit = <NUM_LIT:2> , <EOL> end_marker = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( LIST_CONTAINER_RESP , ret ) <EOL> def test_container_show ( self ) : <EOL> headers = { <EOL> '<STR_LIT>' : FAKE_ACCOUNT , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> resp = { <EOL> '<STR_LIT>' : FAKE_ACCOUNT , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT:1>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : FAKE_ACCOUNT } , <EOL> } <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> headers = headers , <EOL> status_code = <NUM_LIT> , <EOL> ) <EOL> ret = self . api . container_show ( container = '<STR_LIT>' ) <EOL> self . assertEqual ( resp , ret ) <EOL> class TestObject ( TestObjectAPIv1 ) : <EOL> def setUp ( self ) : <EOL> super ( TestObject , self ) . setUp ( ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def base_object_create ( self , file_contents , mock_open ) : <EOL> mock_open . read . return_value = file_contents <EOL> headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> headers = headers , <EOL> status_code = <NUM_LIT> , <EOL> ) <EOL> ret = self . api . object_create ( <EOL> container = '<STR_LIT>' , <EOL> object = '<STR_LIT>' , <EOL> ) <EOL> data = { <EOL> '<STR_LIT>' : FAKE_ACCOUNT , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:object>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> self . assertEqual ( data , ret ) <EOL> def test_object_create ( self ) : <EOL> self . base_object_create ( '<STR_LIT>' ) <EOL> self . base_object_create ( bytes ( [ <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ] ) ) <EOL> def test_object_delete ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> status_code = <NUM_LIT> , <EOL> ) <EOL> ret = self . api . object_delete ( <EOL> container = '<STR_LIT>' , <EOL> object = '<STR_LIT>' , <EOL> ) <EOL> self . assertIsNone ( ret ) <EOL> def test_object_list_no_options ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> json = LIST_OBJECT_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . object_list ( container = '<STR_LIT>' ) <EOL> self . assertEqual ( LIST_OBJECT_RESP , ret ) <EOL> def test_object_list_delimiter ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> json = LIST_OBJECT_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . object_list ( <EOL> container = '<STR_LIT>' , <EOL> delimiter = '<STR_LIT:|>' , <EOL> ) <EOL> self . assertEqual ( LIST_OBJECT_RESP , ret ) <EOL> def test_object_list_prefix ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> json = LIST_OBJECT_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . object_list ( <EOL> container = '<STR_LIT>' , <EOL> prefix = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( LIST_OBJECT_RESP , ret ) <EOL> def test_object_list_marker_limit_end ( self ) : <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT:GET>' , <EOL> FAKE_URL + '<STR_LIT>' , <EOL> json = LIST_CONTAINER_RESP , <EOL> status_code = <NUM_LIT:200> , <EOL> ) <EOL> ret = self . api . object_list ( <EOL> container = '<STR_LIT>' , <EOL> marker = '<STR_LIT>' , <EOL> limit = <NUM_LIT:2> , <EOL> end_marker = '<STR_LIT>' , <EOL> ) <EOL> self . assertEqual ( LIST_CONTAINER_RESP , ret ) <EOL> def test_object_show ( self ) : <EOL> headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : FAKE_ACCOUNT , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> resp = { <EOL> '<STR_LIT>' : FAKE_ACCOUNT , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT:object>' : FAKE_OBJECT , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : { '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' } , <EOL> } <EOL> self . requests_mock . register_uri ( <EOL> '<STR_LIT>' , <EOL> FAKE_URL + '<STR_LIT>' + FAKE_OBJECT , <EOL> headers = headers , <EOL> status_code = <NUM_LIT> , <EOL> ) <EOL> ret = self . api . object_show ( <EOL> container = '<STR_LIT>' , <EOL> object = FAKE_OBJECT , <EOL> ) <EOL> self . assertEqual ( resp , ret ) </s>
