#NEWLINE# def testPostWithFailureBecausePkginfoNotModifiable( self ) : #NEWLINE# #INDENT# 'Test uploading where pkginfo is not modifiable.' #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . handlers , 'IsBlobstore' ) #NEWLINE# uploadpkg . handlers . IsBlobstore ( ) . AndReturn ( True ) #NEWLINE# self . MockDoMunkiAuth ( require_level = uploadpkg . gaeserver . LEVEL_UPLOADPKG ) #NEWLINE# self . MockSelf ( 'get_uploads' ) #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . gae_util , 'GetBlobAndDel' ) #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . plist_lib , 'MunkiPackageInfoPlist' ) #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . blobstore , 'BlobInfo' ) #NEWLINE# mock_plist = self . mox . CreateMockAnything ( ) #NEWLINE# blob = self . mox . CreateMockAnything ( ) #NEWLINE# blob2 = self . mox . CreateMockAnything ( ) #NEWLINE# upload_files = [ blob ] #NEWLINE# pkginfo_files = [ blob2 ] #NEWLINE# name = 'fooname' #NEWLINE# filename = 'filename.dmg' #NEWLINE# pkginfo_str = '<plist></plist>' #NEWLINE# install_types = [ 'managed_installs' , 'managed_updates' ] #NEWLINE# catalogs = [ 'unstable' ] #NEWLINE# pkginfo_dict = { #NEWLINE# #INDENT# 'installer_item_location' : filename , #NEWLINE# 'installer_item_hash' : 'hash' , #NEWLINE# #UNINDENT# } #NEWLINE# blobstore_key = 'fookey' #NEWLINE# blob2 . key ( ) . AndReturn ( 'pkginfoblobkey' ) #NEWLINE# self . request . get ( 'user' ) . AndReturn ( 'foouser' ) #NEWLINE# self . request . get ( 'name' ) . AndReturn ( filename ) #NEWLINE# self . request . get ( 'install_types' ) . AndReturn ( ',' . join ( catalogs ) ) #NEWLINE# self . request . get ( 'catalogs' , None ) . AndReturn ( ',' . join ( catalogs ) ) #NEWLINE# self . request . get ( 'manifests' , None ) . AndReturn ( None ) #NEWLINE# self . c . get_uploads ( 'file' ) . AndReturn ( upload_files ) #NEWLINE# self . c . get_uploads ( 'pkginfo' ) . AndReturn ( pkginfo_files ) #NEWLINE# uploadpkg . gae_util . GetBlobAndDel ( 'pkginfoblobkey' ) . AndReturn ( pkginfo_str ) #NEWLINE# uploadpkg . plist_lib . MunkiPackageInfoPlist ( pkginfo_str ) . AndReturn ( mock_plist ) #NEWLINE# mock_plist . Parse ( ) . AndReturn ( None ) #NEWLINE# blob . key ( ) . AndReturn ( blobstore_key ) #NEWLINE# mock_plist . __getitem__ ( 'installer_item_location' ) . AndReturn ( filename ) #NEWLINE# mock_plist . __getitem__ ( 'installer_item_hash' ) . AndReturn ( 'hash' ) #NEWLINE# uploadpkg . blobstore . BlobInfo . get ( blobstore_key ) . AndReturn ( True ) #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . gae_util , 'ObtainLock' ) #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . gae_util , 'ReleaseLock' ) #NEWLINE# uploadpkg . gae_util . ObtainLock ( ( 'pkgsinfo_%s' % filename ) , timeout = 5.0 ) . AndReturn ( True ) #NEWLINE# pkg = self . MockModelStatic ( 'PackageInfo' , 'get_or_insert' , filename ) #NEWLINE# pkg . IsSafeToModify ( ) . AndReturn ( False ) #NEWLINE# uploadpkg . gae_util . ReleaseLock ( ( 'pkgsinfo_%s' % filename ) ) . AndReturn ( None ) #NEWLINE# self . mox . StubOutWithMock ( uploadpkg . gae_util , 'SafeBlobDel' ) #NEWLINE# uploadpkg . gae_util . SafeBlobDel ( blobstore_key ) . AndReturn ( None ) #NEWLINE# self . MockRedirect ( '/uploadpkg?mode=error&msg=Package%20is%20not%20modifiable' ) #NEWLINE# self . mox . ReplayAll ( ) #NEWLINE# self . c . post ( ) #NEWLINE# self . mox . VerifyAll ( )