<s> import unittest <EOL> from flexmock import flexmock <EOL> from tinys3 . request_factory import CopyRequest , S3Request , UpdateMetadataRequest , DeleteRequest , GetRequest <EOL> from tinys3 import Connection <EOL> class TestNonUploadRequests ( unittest . TestCase ) : <EOL> def setUp ( self ) : <EOL> """<STR_LIT>""" <EOL> self . conn = Connection ( "<STR_LIT>" , "<STR_LIT>" , tls = True ) <EOL> def test_url_generation ( self ) : <EOL> """<STR_LIT>""" <EOL> r = S3Request ( self . conn ) <EOL> url = r . bucket_url ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( url , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . conn . tls = False <EOL> r = S3Request ( self . conn ) <EOL> url = r . bucket_url ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( url , '<STR_LIT>' , '<STR_LIT>' ) <EOL> url = r . bucket_url ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( url , '<STR_LIT>' , '<STR_LIT>' ) <EOL> url = r . bucket_url ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( url , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def _mock_adapter ( self , request ) : <EOL> """<STR_LIT>""" <EOL> mock_obj = flexmock ( ) <EOL> flexmock ( request ) . should_receive ( '<STR_LIT>' ) . and_return ( mock_obj ) <EOL> return mock_obj <EOL> def test_delete_request ( self ) : <EOL> """<STR_LIT>""" <EOL> r = DeleteRequest ( self . conn , '<STR_LIT>' , '<STR_LIT>' ) <EOL> mock = self . _mock_adapter ( r ) <EOL> mock . should_receive ( '<STR_LIT>' ) . with_args ( '<STR_LIT>' , <EOL> auth = self . conn . auth ) . and_return ( self . _mock_response ( ) ) . once ( ) <EOL> r . run ( ) <EOL> def test_get_request ( self ) : <EOL> """<STR_LIT>""" <EOL> r = GetRequest ( self . conn , '<STR_LIT>' , '<STR_LIT>' ) <EOL> mock = self . _mock_adapter ( r ) <EOL> mock . should_receive ( '<STR_LIT>' ) . with_args ( '<STR_LIT>' , <EOL> auth = self . conn . auth ) . and_return ( self . _mock_response ( ) ) . once ( ) <EOL> r . run ( ) <EOL> def test_update_metadata ( self ) : <EOL> """<STR_LIT>""" <EOL> r = UpdateMetadataRequest ( self . conn , '<STR_LIT>' , '<STR_LIT>' , { '<STR_LIT>' : '<STR_LIT>' } , <EOL> True ) <EOL> mock = self . _mock_adapter ( r ) <EOL> expected_headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' <EOL> } <EOL> mock . should_receive ( '<STR_LIT>' ) . with_args ( <EOL> '<STR_LIT>' , <EOL> headers = expected_headers , <EOL> auth = self . conn . auth <EOL> ) . and_return ( self . _mock_response ( ) ) . once ( ) <EOL> r . run ( ) <EOL> def test_copy ( self ) : <EOL> """<STR_LIT>""" <EOL> r = CopyRequest ( self . conn , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , None , False ) <EOL> mock = self . _mock_adapter ( r ) <EOL> expected_headers = { <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> mock . should_receive ( '<STR_LIT>' ) . with_args ( <EOL> '<STR_LIT>' , <EOL> headers = expected_headers , <EOL> auth = self . conn . auth <EOL> ) . and_return ( self . _mock_response ( ) ) . once ( ) <EOL> r . run ( ) <EOL> def _mock_response ( self ) : <EOL> """<STR_LIT>""" <EOL> return flexmock ( raise_for_status = lambda : None ) </s>
