<s> import os <EOL> import re <EOL> import shutil <EOL> import types <EOL> from conary_test import rephelp <EOL> from conary_test import resources <EOL> from conary . repository import changeset <EOL> class CookTestWithMSICapsules ( rephelp . RepositoryHelper ) : <EOL> def testCookWithMSICapsule ( self ) : <EOL> recipestr = """<STR_LIT>""" <EOL> pkgName = '<STR_LIT:foo>' <EOL> version = '<STR_LIT>' <EOL> msiName = '<STR_LIT>' <EOL> addCapsuleArgs = '<STR_LIT>' % msiName <EOL> recipestr = recipestr % ( pkgName , version , addCapsuleArgs ) <EOL> self . cfg . windowsBuildService = '<STR_LIT>' <EOL> class fakeWinHelper : <EOL> name = '<STR_LIT:foo>' <EOL> productName = '<STR_LIT>' <EOL> version = '<STR_LIT>' <EOL> platform = '<STR_LIT>' <EOL> productCode = '<STR_LIT>' <EOL> upgradeCode = '<STR_LIT>' <EOL> msiArgs = None <EOL> components = [ ] <EOL> def __init__ ( self , * args ) : <EOL> pass <EOL> def extractMSIInfo ( self , * args , ** kwargs ) : <EOL> pass <EOL> from conary . build import source <EOL> self . mock ( source , '<STR_LIT>' , fakeWinHelper ) <EOL> pkgNames , built , cs = self . _cookPkgs ( recipestr , msiName , pkgName ) <EOL> ti = [ tcs . getTroveInfo ( ) for tcs in cs . iterNewTroveList ( ) <EOL> if tcs . name ( ) == '<STR_LIT>' ] [ <NUM_LIT:0> ] <EOL> self . assertEqual ( ti . capsule . msi . name ( ) , <EOL> fakeWinHelper . productName ) <EOL> self . assertEqual ( ti . capsule . msi . version ( ) , <EOL> fakeWinHelper . version ) <EOL> self . assertEqual ( ti . capsule . msi . platform ( ) , <EOL> fakeWinHelper . platform ) <EOL> self . assertEqual ( ti . capsule . msi . productCode ( ) , <EOL> fakeWinHelper . productCode ) <EOL> self . assertEqual ( ti . capsule . msi . upgradeCode ( ) , <EOL> fakeWinHelper . upgradeCode ) <EOL> self . assertEqual ( ti . capsule . msi . msiArgs ( ) , <EOL> '<STR_LIT>' ) <EOL> self . assertEquals ( pkgNames , [ pkgName , pkgName + '<STR_LIT>' ] ) <EOL> def _cookAndInstall ( self , recipestr , filename , pkgname , <EOL> builtpkgnames = None , output = '<STR_LIT>' ) : <EOL> if builtpkgnames is None : <EOL> builtpkgnames = [ pkgname ] <EOL> r = self . _cookPkgs ( recipestr , filename , pkgname , builtpkgnames ) <EOL> self . _installPkgs ( builtpkgnames , output = '<STR_LIT>' ) <EOL> return r <EOL> def _cookPkgs ( self , recipestr , filename , pkgname , builtpkgnames = None , macros = { } , updatePackage = False ) : <EOL> repos = self . openRepository ( ) <EOL> recipename = pkgname + '<STR_LIT>' <EOL> ccsname = pkgname + '<STR_LIT>' <EOL> if builtpkgnames is None : <EOL> builtpkgnames = [ pkgname ] <EOL> origDir = os . getcwd ( ) <EOL> try : <EOL> os . chdir ( self . workDir ) <EOL> if updatePackage : <EOL> self . checkout ( pkgname ) <EOL> else : <EOL> self . newpkg ( pkgname ) <EOL> os . chdir ( pkgname ) <EOL> self . writeFile ( recipename , recipestr ) <EOL> if not updatePackage : <EOL> self . addfile ( recipename ) <EOL> if isinstance ( filename , types . StringType ) : <EOL> filenames = [ filename ] <EOL> else : <EOL> filenames = filename <EOL> for filename in filenames : <EOL> shutil . copyfile ( <EOL> resources . get_archive ( ) + '<STR_LIT:/>' + filename , <EOL> filename ) <EOL> self . addfile ( filename ) <EOL> self . commit ( ) <EOL> built , out = self . cookItem ( repos , self . cfg , pkgname , macros = macros ) <EOL> self . changeset ( repos , builtpkgnames , ccsname ) <EOL> cs = changeset . ChangeSetFromFile ( ccsname ) <EOL> finally : <EOL> os . chdir ( origDir ) <EOL> return ( sorted ( [ x . getName ( ) for x in cs . iterNewTroveList ( ) ] ) , built , cs ) <EOL> def _installPkgs ( self , builtpkgnames , output = '<STR_LIT>' ) : <EOL> rc , str = self . captureOutput ( self . updatePkg , self . rootDir , <EOL> builtpkgnames , depCheck = False ) <EOL> assert re . match ( output , str ) , '<STR_LIT>' % ( output , str ) </s>
