<s> import mock <EOL> from solum . common import exception as exc <EOL> from solum . common import solum_swiftclient as swiftclient <EOL> from solum . tests import base <EOL> from solum . tests import utils <EOL> class SwiftClientTest ( base . BaseTestCase ) : <EOL> """<STR_LIT>""" <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_swift_client_upload ( self , mock_file_size , mock_swift_client , <EOL> mock_open ) : <EOL> ctxt = utils . dummy_context ( ) <EOL> container = '<STR_LIT>' <EOL> filename = '<STR_LIT>' <EOL> mock_client = mock_swift_client . return_value <EOL> fsize = <NUM_LIT:5> <EOL> mock_file_size . return_value = fsize <EOL> swift = swiftclient . SwiftClient ( ctxt ) <EOL> swift . upload ( '<STR_LIT>' , container , filename ) <EOL> mock_client . put_container . assert_called_once_with ( container ) <EOL> mock_client . put_object . assert_called_once_with ( container , <EOL> filename , <EOL> mock . ANY , <EOL> content_length = fsize ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_swift_client_upload_exception ( self , mock_file_size , <EOL> mock_swift_client , mock_open ) : <EOL> ctxt = utils . dummy_context ( ) <EOL> mock_file_size . return_value = <NUM_LIT:0> <EOL> swift = swiftclient . SwiftClient ( ctxt ) <EOL> self . assertRaises ( exc . InvalidObjectSizeError , <EOL> swift . upload , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) </s>
