<s> import mock <EOL> from oslo_config import cfg <EOL> from solum . tests import base <EOL> from solum . tests import fakes <EOL> from solum . tests import utils <EOL> import solum . uploaders . swift as uploader <EOL> class SwiftUploadTest ( base . BaseTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( SwiftUploadTest , self ) . setUp ( ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_upload_on_assembly_delete ( self , mock_write_row , mock_trans_jlog , <EOL> mock_upload , mock_open ) : <EOL> ctxt = utils . dummy_context ( ) <EOL> orig_path = "<STR_LIT>" <EOL> assembly = fakes . FakeAssembly ( ) <EOL> build_id = "<STR_LIT>" <EOL> container = '<STR_LIT>' <EOL> cfg . CONF . worker . log_upload_swift_container = container <EOL> stage = "<STR_LIT>" <EOL> swiftupload = uploader . SwiftUpload ( ctxt , orig_path , <EOL> assembly , build_id , <EOL> stage ) <EOL> rs_before_delete = swiftupload . resource <EOL> name_before = swiftupload . resource . name <EOL> uuid_before = swiftupload . resource . uuid <EOL> del assembly <EOL> swiftupload . upload_log ( ) <EOL> self . assertEqual ( name_before , swiftupload . resource . name ) <EOL> self . assertEqual ( uuid_before , swiftupload . resource . uuid ) <EOL> swift_info = { '<STR_LIT>' : container } <EOL> filename = "<STR_LIT>" % ( rs_before_delete . name , <EOL> build_id , <EOL> stage , build_id ) <EOL> self . assertTrue ( mock_trans_jlog . called ) <EOL> tansf_path = orig_path + '<STR_LIT>' <EOL> mock_upload . assert_called_once_with ( container , filename , tansf_path ) <EOL> mock_write_row . assert_called_once_with ( filename , swift_info ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_upload ( self , mock_write_row , mock_trans_jlog , mock_swift , <EOL> mock_open ) : <EOL> ctxt = utils . dummy_context ( ) <EOL> orig_path = "<STR_LIT>" <EOL> assembly = fakes . FakeAssembly ( ) <EOL> build_id = "<STR_LIT>" <EOL> container = '<STR_LIT>' <EOL> cfg . CONF . worker . log_upload_swift_container = container <EOL> stage = "<STR_LIT>" <EOL> swiftupload = uploader . SwiftUpload ( ctxt , orig_path , <EOL> assembly , build_id , <EOL> stage ) <EOL> resource = swiftupload . resource <EOL> swiftupload . upload_log ( ) <EOL> swift_info = { '<STR_LIT>' : container } <EOL> filename = "<STR_LIT>" % ( resource . name , <EOL> build_id , <EOL> stage , build_id ) <EOL> self . assertTrue ( mock_trans_jlog . called ) <EOL> tansf_path = orig_path + '<STR_LIT>' <EOL> mock_swift . assert_called_once_with ( tansf_path , <EOL> container , <EOL> filename ) <EOL> mock_write_row . assert_called_once_with ( filename , swift_info ) </s>
