<s> """<STR_LIT>""" <EOL> import logging <EOL> import mox <EOL> import stubout <EOL> from google . apputils import app <EOL> from google . apputils import basetest <EOL> from simian . mac . client import client <EOL> class ClientModuleTest ( mox . MoxTestBase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> mox . MoxTestBase . setUp ( self ) <EOL> self . stubs = stubout . StubOutForTesting ( ) <EOL> def tearDown ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> self . stubs . UnsetAll ( ) <EOL> class BaseSimianClientTest ( mox . MoxTestBase ) : <EOL> def setUp ( self ) : <EOL> mox . MoxTestBase . setUp ( self ) <EOL> self . stubs = stubout . StubOutForTesting ( ) <EOL> self . client = client . BaseSimianClient ( ) <EOL> def tearDown ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> self . stubs . UnsetAll ( ) <EOL> def testGetSystemRootCACertChain ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( <EOL> client . client . SimianClient , '<STR_LIT>' , True ) <EOL> argv = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> stdout = '<STR_LIT>' <EOL> stderr = '<STR_LIT>' <EOL> rc = <NUM_LIT:0> <EOL> mock_p = self . mox . CreateMockAnything ( ) <EOL> client . client . SimianClient . GetSystemRootCACertChain ( <EOL> self . client ) . AndReturn ( '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> argv , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndReturn ( mock_p ) <EOL> mock_p . communicate ( ) . AndReturn ( ( stdout , stderr ) ) <EOL> mock_p . wait ( ) . AndReturn ( rc ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( stdout , self . client . GetSystemRootCACertChain ( ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetSystemRootCACertChainWhenError ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( <EOL> client . client . SimianClient , '<STR_LIT>' , True ) <EOL> argv = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> stdout = '<STR_LIT>' <EOL> stderr = '<STR_LIT>' <EOL> rc = <NUM_LIT:1> <EOL> mock_p = self . mox . CreateMockAnything ( ) <EOL> client . client . SimianClient . GetSystemRootCACertChain ( <EOL> self . client ) . AndReturn ( '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> argv , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndReturn ( mock_p ) <EOL> mock_p . communicate ( ) . AndReturn ( ( stdout , stderr ) ) <EOL> mock_p . wait ( ) . AndReturn ( rc ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( '<STR_LIT>' , self . client . GetSystemRootCACertChain ( ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetSystemRootCACertChainWhenOSError ( self ) : <EOL> """<STR_LIT>""" <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( <EOL> client . client . SimianClient , '<STR_LIT>' , True ) <EOL> argv = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' <EOL> ] <EOL> client . client . SimianClient . GetSystemRootCACertChain ( <EOL> self . client ) . AndReturn ( '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> argv , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndRaise ( OSError ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( '<STR_LIT>' , self . client . GetSystemRootCACertChain ( ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testGetSystemProfile ( self ) : <EOL> """<STR_LIT>""" <EOL> profile = '<STR_LIT>' <EOL> mock_profile = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( client . hw , '<STR_LIT>' ) <EOL> client . hw . SystemProfile ( <EOL> include_only = [ '<STR_LIT>' , '<STR_LIT>' ] ) . AndReturn ( mock_profile ) <EOL> mock_profile . GetProfile ( ) . AndReturn ( profile ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( profile , self . client . _GetSystemProfile ( ) ) <EOL> self . mox . VerifyAll ( ) <EOL> class SimianClient ( mox . MoxTestBase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> mox . MoxTestBase . setUp ( self ) <EOL> self . stubs = stubout . StubOutForTesting ( ) <EOL> self . client = client . SimianClient ( ) <EOL> def tearDown ( self ) : <EOL> self . mox . UnsetStubs ( ) <EOL> self . stubs . UnsetAll ( ) <EOL> def testIsDiskImageReadOnly ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> stdout = '<STR_LIT>' <EOL> stderr = '<STR_LIT>' <EOL> rc = <NUM_LIT:0> <EOL> mock_p = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , filename ] , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndReturn ( mock_p ) <EOL> mock_p . communicate ( ) . AndReturn ( ( stdout , stderr ) ) <EOL> mock_p . wait ( ) . AndReturn ( rc ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertTrue ( self . client . _IsDiskImageReadOnly ( filename ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsDiskImageReadOnlyWhenReadWrite ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> stdout = '<STR_LIT>' <EOL> stderr = '<STR_LIT>' <EOL> rc = <NUM_LIT:0> <EOL> mock_p = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , filename ] , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndReturn ( mock_p ) <EOL> mock_p . communicate ( ) . AndReturn ( ( stdout , stderr ) ) <EOL> mock_p . wait ( ) . AndReturn ( rc ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertFalse ( self . client . _IsDiskImageReadOnly ( filename ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsDiskImageReadOnlyWhenExecError ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> mock_p = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , filename ] , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndReturn ( mock_p ) <EOL> mock_p . communicate ( ) . AndRaise ( OSError ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertRaises ( <EOL> client . client . SimianClientError , <EOL> self . client . _IsDiskImageReadOnly , filename ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsDiskImageReadOnlyWhenNonZero ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> stdout = '<STR_LIT>' <EOL> stderr = '<STR_LIT>' <EOL> rc = <NUM_LIT:9> <EOL> mock_p = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( client . subprocess , '<STR_LIT>' ) <EOL> client . subprocess . Popen ( <EOL> [ '<STR_LIT>' , '<STR_LIT>' , filename ] , <EOL> stdout = client . subprocess . PIPE , <EOL> stderr = client . subprocess . PIPE ) . AndReturn ( mock_p ) <EOL> mock_p . communicate ( ) . AndReturn ( ( stdout , stderr ) ) <EOL> mock_p . wait ( ) . AndReturn ( rc ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertRaises ( <EOL> client . client . SimianClientError , <EOL> self . client . _IsDiskImageReadOnly , filename ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsPackageUploadNecessaryWhenNew ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . GetPackageInfo ( filename ) . AndRaise ( <EOL> client . client . SimianServerError ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertTrue ( <EOL> self . client . _IsPackageUploadNecessary ( filename , pkginfo ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsPackageUploadNecessaryWhenPlistParseError ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> pkginfo = '<STR_LIT>' <EOL> cur_pkginfo = '<STR_LIT>' <EOL> mock_mpip = self . mox . CreateMockAnything ( ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . stubs . Set ( client . plist , '<STR_LIT>' , mock_mpip ) <EOL> self . client . GetPackageInfo ( filename ) . AndReturn ( cur_pkginfo ) <EOL> mock_mpip ( cur_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndRaise ( client . plist . PlistError ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertTrue ( <EOL> self . client . _IsPackageUploadNecessary ( filename , pkginfo ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsPackageUploadNecessaryWhenHashMissing ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> upload_pkginfo = self . mox . CreateMockAnything ( ) <EOL> upload_pkginfo_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> cur_pkginfo = '<STR_LIT>' <EOL> pkginfo_plist = self . mox . CreateMockAnything ( ) <EOL> mock_mpip = self . mox . CreateMockAnything ( ) <EOL> pkginfo_dict = { '<STR_LIT:foo>' : '<STR_LIT:bar>' } <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . stubs . Set ( client , '<STR_LIT>' , self . mox . CreateMock ( client . plist ) ) <EOL> self . client . GetPackageInfo ( filename ) . AndReturn ( cur_pkginfo ) <EOL> client . plist . MunkiPackageInfoPlist ( cur_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndReturn ( None ) <EOL> mock_mpip . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> client . plist . MunkiPackageInfoPlist ( upload_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndReturn ( None ) <EOL> mock_mpip . GetContents ( ) . AndReturn ( upload_pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertTrue ( <EOL> self . client . _IsPackageUploadNecessary ( filename , upload_pkginfo ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsPackageUploadNecessaryWhenHashDifferent ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> orig_sha256_hash = '<STR_LIT>' <EOL> upload_pkginfo = self . mox . CreateMockAnything ( ) <EOL> upload_pkginfo_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : '<STR_LIT>' % orig_sha256_hash , <EOL> } <EOL> cur_pkginfo = '<STR_LIT>' <EOL> pkginfo_plist = self . mox . CreateMockAnything ( ) <EOL> mock_mpip = self . mox . CreateMockAnything ( ) <EOL> pkginfo_dict = { '<STR_LIT>' : orig_sha256_hash } <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . stubs . Set ( client , '<STR_LIT>' , self . mox . CreateMock ( client . plist ) ) <EOL> self . client . GetPackageInfo ( filename ) . AndReturn ( cur_pkginfo ) <EOL> client . plist . MunkiPackageInfoPlist ( cur_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndReturn ( None ) <EOL> mock_mpip . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> client . plist . MunkiPackageInfoPlist ( upload_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndReturn ( None ) <EOL> mock_mpip . GetContents ( ) . AndReturn ( upload_pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertTrue ( <EOL> self . client . _IsPackageUploadNecessary ( filename , upload_pkginfo ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testIsPackageUploadNecessaryWhenHashSame ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> orig_sha256_hash = '<STR_LIT>' <EOL> upload_pkginfo = self . mox . CreateMockAnything ( ) <EOL> upload_pkginfo_dict = { <EOL> '<STR_LIT>' : <NUM_LIT:1> , <EOL> '<STR_LIT>' : orig_sha256_hash , <EOL> } <EOL> cur_pkginfo = '<STR_LIT>' <EOL> pkginfo_plist = self . mox . CreateMockAnything ( ) <EOL> mock_mpip = self . mox . CreateMockAnything ( ) <EOL> pkginfo_dict = { '<STR_LIT>' : orig_sha256_hash } <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . stubs . Set ( client , '<STR_LIT>' , self . mox . CreateMock ( client . plist ) ) <EOL> self . client . GetPackageInfo ( filename ) . AndReturn ( cur_pkginfo ) <EOL> client . plist . MunkiPackageInfoPlist ( cur_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndReturn ( None ) <EOL> mock_mpip . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> client . plist . MunkiPackageInfoPlist ( upload_pkginfo ) . AndReturn ( mock_mpip ) <EOL> mock_mpip . Parse ( ) . AndReturn ( None ) <EOL> mock_mpip . GetContents ( ) . AndReturn ( upload_pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertFalse ( <EOL> self . client . _IsPackageUploadNecessary ( filename , upload_pkginfo ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testUploadMunkiPackageWhenNotReadOnlyDiskImage ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> catalogs = '<STR_LIT>' <EOL> manifests = '<STR_LIT>' <EOL> install_types = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> pkginfo_hooks = None <EOL> pkginfo_dict = { <EOL> '<STR_LIT>' : '<STR_LIT:size>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . _IsDiskImageReadOnly ( filename ) . AndReturn ( False ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertRaises ( <EOL> client . client . SimianClientError , <EOL> self . client . UploadMunkiPackage , <EOL> filename , description , display_name , catalogs , manifests , <EOL> install_types , pkginfo_hooks = pkginfo_hooks ) <EOL> self . mox . VerifyAll ( ) <EOL> def testUploadMunkiPackageWhenInstaller ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> pkginfo_name = '<STR_LIT>' <EOL> catalogs = '<STR_LIT>' <EOL> manifests = '<STR_LIT>' <EOL> install_types = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> pkginfo_hooks = None <EOL> pkginfo_dict = { <EOL> '<STR_LIT>' : '<STR_LIT:size>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . _IsDiskImageReadOnly ( filename ) . AndReturn ( True ) <EOL> self . client . _LoadPackageInfo ( <EOL> filename , description , display_name , catalogs ) . AndReturn ( pkginfo ) <EOL> pkginfo . __setitem__ ( '<STR_LIT>' , True ) . AndReturn ( None ) <EOL> pkginfo . __setitem__ ( '<STR_LIT>' , True ) . AndReturn ( None ) <EOL> pkginfo . __setitem__ ( '<STR_LIT:name>' , pkginfo_name ) . AndReturn ( None ) <EOL> pkginfo . Validate ( ) . AndReturn ( None ) <EOL> pkginfo . GetXml ( ) . AndReturn ( '<STR_LIT>' ) <EOL> self . client . UploadPackage ( <EOL> filename , description , display_name , catalogs , manifests , install_types , <EOL> '<STR_LIT>' ) . AndReturn ( ( response , filename , catalogs , manifests ) ) <EOL> pkginfo . GetPackageName ( ) . AndReturn ( '<STR_LIT>' ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <EOL> ( response , filename , '<STR_LIT>' , catalogs , manifests , '<STR_LIT:size>' , '<STR_LIT>' ) , <EOL> self . client . UploadMunkiPackage ( <EOL> filename , description , display_name , catalogs , manifests , <EOL> install_types , pkginfo_hooks = pkginfo_hooks , unattended_install = True , <EOL> pkginfo_name = pkginfo_name ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testUploadMunkiPackageWhenUninstaller ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> catalogs = '<STR_LIT>' <EOL> manifests = '<STR_LIT>' <EOL> install_types = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> pkginfo_hooks = None <EOL> pkginfo_dict = { <EOL> '<STR_LIT>' : '<STR_LIT:size>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . _IsDiskImageReadOnly ( filename ) . AndReturn ( True ) <EOL> self . client . _LoadPackageInfo ( <EOL> filename , description , display_name , catalogs ) . AndReturn ( pkginfo ) <EOL> pkginfo . __setitem__ ( '<STR_LIT>' , True ) . AndReturn ( None ) <EOL> pkginfo . __setitem__ ( '<STR_LIT>' , True ) . AndReturn ( None ) <EOL> pkginfo . Validate ( ) . AndReturn ( None ) <EOL> pkginfo . GetXml ( ) . AndReturn ( '<STR_LIT>' ) <EOL> self . client . UploadPackage ( <EOL> filename , description , display_name , catalogs , manifests , install_types , <EOL> '<STR_LIT>' ) . AndReturn ( ( response , filename , catalogs , manifests ) ) <EOL> pkginfo . GetPackageName ( ) . AndReturn ( '<STR_LIT>' ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <EOL> ( response , filename , '<STR_LIT>' , catalogs , manifests , '<STR_LIT:size>' , '<STR_LIT>' ) , <EOL> self . client . UploadMunkiPackage ( <EOL> filename , description , display_name , catalogs , manifests , <EOL> install_types , pkginfo_hooks = pkginfo_hooks , <EOL> unattended_uninstall = True ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testUploadMunkiPackageWhenHookTrue ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> catalogs = '<STR_LIT>' <EOL> manifests = '<STR_LIT>' <EOL> install_types = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> pkginfo_hooks = [ self . mox . CreateMockAnything ( ) ] <EOL> pkginfo_dict = { <EOL> '<STR_LIT>' : '<STR_LIT:size>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . _IsDiskImageReadOnly ( filename ) . AndReturn ( True ) <EOL> self . client . _LoadPackageInfo ( <EOL> filename , description , display_name , catalogs ) . AndReturn ( pkginfo ) <EOL> pkginfo_hooks [ <NUM_LIT:0> ] ( pkginfo ) . AndReturn ( True ) <EOL> pkginfo . Validate ( ) . AndReturn ( None ) <EOL> pkginfo . GetXml ( ) . AndReturn ( '<STR_LIT>' ) <EOL> self . client . UploadPackage ( <EOL> filename , description , display_name , catalogs , manifests , install_types , <EOL> '<STR_LIT>' ) . AndReturn ( ( response , filename , catalogs , manifests ) ) <EOL> pkginfo . GetPackageName ( ) . AndReturn ( '<STR_LIT>' ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <EOL> ( response , filename , '<STR_LIT>' , catalogs , manifests , '<STR_LIT:size>' , '<STR_LIT>' ) , <EOL> self . client . UploadMunkiPackage ( <EOL> filename , description , display_name , catalogs , manifests , <EOL> install_types , pkginfo_hooks = pkginfo_hooks ) ) <EOL> self . mox . VerifyAll ( ) <EOL> def testUploadMunkiPackageWhenHookFalse ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> catalogs = '<STR_LIT>' <EOL> manifests = '<STR_LIT>' <EOL> install_types = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> pkginfo_hooks = [ self . mox . CreateMockAnything ( ) ] <EOL> pkginfo_dict = { <EOL> '<STR_LIT>' : '<STR_LIT:size>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . _IsDiskImageReadOnly ( filename ) . AndReturn ( True ) <EOL> self . client . _LoadPackageInfo ( <EOL> filename , description , display_name , catalogs ) . AndReturn ( pkginfo ) <EOL> pkginfo_hooks [ <NUM_LIT:0> ] ( pkginfo ) . AndReturn ( False ) <EOL> pkginfo . Validate ( ) . AndReturn ( None ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertRaises ( <EOL> client . client . SimianClientError , <EOL> self . client . UploadMunkiPackage , <EOL> filename , description , display_name , catalogs , manifests , install_types , <EOL> pkginfo_hooks = pkginfo_hooks ) <EOL> self . mox . VerifyAll ( ) <EOL> def testUploadMunkiPackageWhenHookObject ( self ) : <EOL> """<STR_LIT>""" <EOL> filename = '<STR_LIT>' <EOL> description = '<STR_LIT>' <EOL> display_name = '<STR_LIT>' <EOL> catalogs = '<STR_LIT>' <EOL> manifests = '<STR_LIT>' <EOL> install_types = '<STR_LIT>' <EOL> pkginfo = self . mox . CreateMockAnything ( ) <EOL> pkginfo_hooks = [ self . mox . CreateMockAnything ( ) ] <EOL> pkginfo_dict = { <EOL> '<STR_LIT>' : '<STR_LIT:size>' , <EOL> '<STR_LIT>' : '<STR_LIT>' , <EOL> } <EOL> response = '<STR_LIT>' <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . mox . StubOutWithMock ( self . client , '<STR_LIT>' ) <EOL> self . client . _IsDiskImageReadOnly ( filename ) . AndReturn ( True ) <EOL> self . client . _LoadPackageInfo ( <EOL> filename , description , display_name , catalogs ) . AndReturn ( pkginfo ) <EOL> pkginfo_hooks [ <NUM_LIT:0> ] ( pkginfo ) . AndReturn ( pkginfo ) <EOL> pkginfo . Validate ( ) . AndReturn ( True ) <EOL> pkginfo . __getitem__ ( '<STR_LIT:description>' ) . AndReturn ( description ) <EOL> pkginfo . __getitem__ ( '<STR_LIT>' ) . AndReturn ( display_name ) <EOL> pkginfo . __getitem__ ( '<STR_LIT>' ) . AndReturn ( catalogs ) <EOL> pkginfo . GetXml ( ) . AndReturn ( '<STR_LIT>' ) <EOL> self . client . UploadPackage ( <EOL> filename , description , display_name , catalogs , manifests , install_types , <EOL> '<STR_LIT>' ) . AndReturn ( ( response , filename , catalogs , manifests ) ) <EOL> pkginfo . GetPackageName ( ) . AndReturn ( '<STR_LIT>' ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> pkginfo . GetContents ( ) . AndReturn ( pkginfo_dict ) <EOL> self . mox . ReplayAll ( ) <EOL> self . assertEqual ( <EOL> ( response , filename , '<STR_LIT>' , catalogs , manifests , '<STR_LIT:size>' , '<STR_LIT>' ) , <EOL> self . client . UploadMunkiPackage ( <EOL> filename , description , display_name , catalogs , manifests , <EOL> install_types , pkginfo_hooks = pkginfo_hooks ) ) <EOL> self . mox . VerifyAll ( ) <EOL> logging . basicConfig ( filename = '<STR_LIT>' ) <EOL> def main ( unused_argv ) : <EOL> basetest . main ( ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> app . run ( ) </s>
