#NEWLINE# def test_archive_retrieve_with_job( self ) : #NEWLINE# #INDENT# self . init_app ( [ 'archive' , 'retrieve' , 'vault_name' , 'archive_name' ] ) #NEWLINE# self . cache . get_archive_id . return_value = sentinel . archive_id #NEWLINE# mock_job = Mock ( archive_id = sentinel . archive_id , completed = True , completion_date = '1970-01-01T00:00:00Z' , archive_size = 1 ) #NEWLINE# mock_vault = Mock ( ) #NEWLINE# mock_vault . list_jobs . return_value = [ mock_job ] #NEWLINE# self . connection . get_vault . return_value = mock_vault #NEWLINE# mock_open = mock . mock_open ( ) #NEWLINE# with patch ( '__builtin__.open' , mock_open ) : #NEWLINE# #INDENT# self . app . main ( ) #NEWLINE# #UNINDENT# self . cache . get_archive_id . assert_called_once_with ( 'vault_name' , 'archive_name' ) #NEWLINE# mock_job . get_output . assert_called_once_with ( ) #NEWLINE# mock_job . get_output . return_value . read . assert_called_once_with ( ) #NEWLINE# mock_open . assert_called_once_with ( 'archive_name' , 'wb' ) #NEWLINE# mock_open . return_value . write . assert_called_once_with ( mock_open . get_output . return_value . read . return_value )