<s> from conary_test import rephelp <EOL> from testrunner import testhelp <EOL> from conary_test import resources <EOL> import os <EOL> from conary . build import build <EOL> from conary . build import source <EOL> class WindowsActionTest ( rephelp . RepositoryHelper ) : <EOL> def setUp ( self ) : <EOL> rephelp . RepositoryHelper . setUp ( self ) <EOL> self . archivePath = resources . get_archive ( ) <EOL> self . cfg . macros [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> def tearDown ( self ) : <EOL> self . cfg . macros . pop ( '<STR_LIT>' ) <EOL> rephelp . RepositoryHelper . tearDown ( self ) <EOL> test_recipe1 = """<STR_LIT>""" <EOL> test_recipe2 = """<STR_LIT>""" <EOL> test_recipe3 = """<STR_LIT>""" <EOL> def testPolicy ( self ) : <EOL> def newDo ( a , macros ) : <EOL> msiPath = os . path . join ( self . archivePath , '<STR_LIT>' ) <EOL> a . recipe . _addCapsule ( msiPath , '<STR_LIT>' , a . package % macros ) <EOL> a . recipe . winHelper = source . WindowsHelper ( ) <EOL> a . recipe . winHelper . productName = '<STR_LIT>' <EOL> a . recipe . winHelper . platform = '<STR_LIT>' <EOL> a . recipe . winHelper . version = '<STR_LIT>' <EOL> a . recipe . winHelper . productCode = '<STR_LIT>' <EOL> a . recipe . winHelper . upgradeCode = '<STR_LIT>' <EOL> self . mock ( build . BuildMSI , '<STR_LIT>' , newDo ) <EOL> built , d = self . buildRecipe ( self . test_recipe1 , '<STR_LIT>' , <EOL> logBuild = True ) <EOL> msis = [ x for x in built if x [ <NUM_LIT:0> ] . endswith ( '<STR_LIT>' ) ] <EOL> self . assertEqual ( len ( msis ) , <NUM_LIT:1> ) <EOL> msi = msis [ <NUM_LIT:0> ] <EOL> repos = self . openRepository ( ) <EOL> spec = repos . findTrove ( self . cfg . buildLabel , msi ) <EOL> self . assertEqual ( len ( spec ) , <NUM_LIT:1> ) <EOL> trv = repos . getTrove ( * spec [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . name ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . platform ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . version ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . productCode ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . upgradeCode ( ) , '<STR_LIT>' ) <EOL> def testGetUpgradeCode ( self ) : <EOL> def mockBuildMSI ( version , upCode = None ) : <EOL> def do ( a , macros ) : <EOL> a . package = a . package % macros <EOL> msiPath = os . path . join ( self . archivePath , '<STR_LIT>' ) <EOL> a . recipe . _addCapsule ( msiPath , '<STR_LIT>' , a . package % macros ) <EOL> a . recipe . winHelper = source . WindowsHelper ( ) <EOL> a . recipe . winHelper . productName = '<STR_LIT>' <EOL> a . recipe . winHelper . platform = '<STR_LIT>' <EOL> a . recipe . winHelper . version = version <EOL> a . recipe . winHelper . productCode = '<STR_LIT>' <EOL> upgradeCode = a . _getUpgradeCode ( ) <EOL> if not upgradeCode : <EOL> upgradeCode = '<STR_LIT:None>' <EOL> if upCode : <EOL> upgradeCode = upCode <EOL> a . recipe . winHelper . upgradeCode = upgradeCode <EOL> self . mock ( build . BuildMSI , '<STR_LIT>' , do ) <EOL> repos = self . openRepository ( ) <EOL> origDir = os . getcwd ( ) <EOL> self . resetWork ( ) <EOL> os . chdir ( self . workDir ) <EOL> self . newpkg ( '<STR_LIT>' ) <EOL> os . chdir ( '<STR_LIT>' ) <EOL> self . writeFile ( '<STR_LIT>' , self . test_recipe1 ) <EOL> self . addfile ( '<STR_LIT>' ) <EOL> self . commit ( ) <EOL> os . chdir ( origDir ) <EOL> self . resetWork ( ) <EOL> os . chdir ( self . workDir ) <EOL> mockBuildMSI ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> built = self . cookItem ( repos , self . cfg , '<STR_LIT>' ) <EOL> self . checkout ( '<STR_LIT>' ) <EOL> os . chdir ( '<STR_LIT>' ) <EOL> self . writeFile ( '<STR_LIT>' , <EOL> self . test_recipe1 . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . commit ( ) <EOL> self . resetWork ( ) <EOL> os . chdir ( origDir ) <EOL> mockBuildMSI ( '<STR_LIT>' ) <EOL> built = self . cookItem ( repos , self . cfg , '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> msis = [ x for x in built if x [ <NUM_LIT:0> ] . endswith ( '<STR_LIT>' ) ] <EOL> self . assertEqual ( len ( msis ) , <NUM_LIT:1> ) <EOL> msi = msis [ <NUM_LIT:0> ] <EOL> repos = self . openRepository ( ) <EOL> spec = repos . findTrove ( self . cfg . buildLabel , msi ) <EOL> self . assertEqual ( len ( spec ) , <NUM_LIT:1> ) <EOL> trv = repos . getTrove ( * spec [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . name ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . platform ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . version ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . productCode ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . upgradeCode ( ) , '<STR_LIT>' ) <EOL> def testPersistingComponentInformation ( self ) : <EOL> def mockBuildMSI ( version , components = None ) : <EOL> def do ( a , macros ) : <EOL> a . package = a . package % macros <EOL> msiPath = os . path . join ( self . archivePath , '<STR_LIT>' ) <EOL> a . recipe . _addCapsule ( msiPath , '<STR_LIT>' , a . package % macros ) <EOL> a . recipe . winHelper = source . WindowsHelper ( ) <EOL> a . recipe . winHelper . productName = '<STR_LIT>' <EOL> a . recipe . winHelper . platform = '<STR_LIT>' <EOL> a . recipe . winHelper . version = version <EOL> a . recipe . winHelper . productCode = '<STR_LIT:foo>' <EOL> a . recipe . winHelper . upgradeCode = '<STR_LIT:bar>' <EOL> if components : <EOL> a . recipe . winHelper . components = components <EOL> for comp in a . _getComponentInfo ( ) : <EOL> if comp not in a . recipe . winHelper . components : <EOL> a . recipe . winHelper . components . append ( comp ) <EOL> self . mock ( build . BuildMSI , '<STR_LIT>' , do ) <EOL> repos = self . openRepository ( ) <EOL> origDir = os . getcwd ( ) <EOL> self . resetWork ( ) <EOL> os . chdir ( self . workDir ) <EOL> self . newpkg ( '<STR_LIT>' ) <EOL> os . chdir ( '<STR_LIT>' ) <EOL> self . writeFile ( '<STR_LIT>' , self . test_recipe1 ) <EOL> self . addfile ( '<STR_LIT>' ) <EOL> self . commit ( ) <EOL> os . chdir ( origDir ) <EOL> self . resetWork ( ) <EOL> os . chdir ( self . workDir ) <EOL> mockBuildMSI ( '<STR_LIT>' , <EOL> components = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> built = self . cookItem ( repos , self . cfg , '<STR_LIT>' ) <EOL> spec = repos . findTrove ( self . cfg . buildLabel , <EOL> ( '<STR_LIT>' , None , None ) ) [ <NUM_LIT:0> ] <EOL> trv = repos . getTrove ( * spec ) <EOL> components = [ ( x . uuid ( ) , x . path ( ) ) <EOL> for _ , x in trv . troveInfo . capsule . msi . components . iterAll ( ) ] <EOL> self . assertTrue ( ( '<STR_LIT>' , '<STR_LIT>' ) in components ) <EOL> self . assertTrue ( ( '<STR_LIT>' , '<STR_LIT>' ) in components ) <EOL> self . checkout ( '<STR_LIT>' ) <EOL> os . chdir ( '<STR_LIT>' ) <EOL> self . writeFile ( '<STR_LIT>' , <EOL> self . test_recipe1 . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> self . commit ( ) <EOL> self . resetWork ( ) <EOL> os . chdir ( origDir ) <EOL> mockBuildMSI ( '<STR_LIT>' , components = [ ( '<STR_LIT>' , '<STR_LIT>' ) , ] ) <EOL> built = self . cookItem ( repos , self . cfg , '<STR_LIT>' ) <EOL> spec = repos . findTrove ( self . cfg . buildLabel , <EOL> ( '<STR_LIT>' , None , None ) ) [ <NUM_LIT:0> ] <EOL> trv = repos . getTrove ( * spec ) <EOL> components = [ ( x . uuid ( ) , x . path ( ) ) <EOL> for _ , x in trv . troveInfo . capsule . msi . components . iterAll ( ) ] <EOL> self . assertTrue ( ( '<STR_LIT>' , '<STR_LIT>' ) in components ) <EOL> self . assertTrue ( ( '<STR_LIT>' , '<STR_LIT>' ) in components ) <EOL> self . assertTrue ( ( '<STR_LIT>' , '<STR_LIT>' ) in components ) <EOL> def testMsiArgs ( self ) : <EOL> def mockBuildMSI ( version , msiArgs = None ) : <EOL> def do ( a , macros ) : <EOL> a . package = a . package % macros <EOL> msiPath = os . path . join ( self . archivePath , '<STR_LIT>' ) <EOL> a . recipe . _addCapsule ( msiPath , '<STR_LIT>' , a . package % macros ) <EOL> a . recipe . winHelper = source . WindowsHelper ( ) <EOL> a . recipe . winHelper . productName = '<STR_LIT>' <EOL> a . recipe . winHelper . platform = '<STR_LIT>' <EOL> a . recipe . winHelper . version = version <EOL> a . recipe . winHelper . productCode = '<STR_LIT:foo>' <EOL> a . recipe . winHelper . upgradeCode = '<STR_LIT:bar>' <EOL> a . recipe . winHelper . msiArgs = msiArgs <EOL> self . mock ( build . BuildMSI , '<STR_LIT>' , do ) <EOL> repos = self . openRepository ( ) <EOL> origDir = os . getcwd ( ) <EOL> self . resetWork ( ) <EOL> os . chdir ( self . workDir ) <EOL> self . newpkg ( '<STR_LIT>' ) <EOL> os . chdir ( '<STR_LIT>' ) <EOL> self . writeFile ( '<STR_LIT>' , self . test_recipe3 ) <EOL> self . addfile ( '<STR_LIT>' ) <EOL> self . commit ( ) <EOL> os . chdir ( origDir ) <EOL> self . resetWork ( ) <EOL> os . chdir ( self . workDir ) <EOL> mockBuildMSI ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> built , _ = self . cookItem ( repos , self . cfg , '<STR_LIT>' ) <EOL> msis = [ x for x in built if x [ <NUM_LIT:0> ] . endswith ( '<STR_LIT>' ) ] <EOL> self . assertEqual ( len ( msis ) , <NUM_LIT:1> ) <EOL> msi = msis [ <NUM_LIT:0> ] <EOL> repos = self . openRepository ( ) <EOL> spec = repos . findTrove ( self . cfg . buildLabel , msi ) <EOL> self . assertEqual ( len ( spec ) , <NUM_LIT:1> ) <EOL> trv = repos . getTrove ( * spec [ <NUM_LIT:0> ] ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . name ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . platform ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . version ( ) , '<STR_LIT>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . productCode ( ) , '<STR_LIT:foo>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . upgradeCode ( ) , '<STR_LIT:bar>' ) <EOL> self . assertEqual ( trv . troveInfo . capsule . msi . msiArgs ( ) , '<STR_LIT>' ) <EOL> def testBasics ( self ) : <EOL> raise testhelp . SkipTestException ( '<STR_LIT>' ) <EOL> built , d = self . buildRecipe ( self . test_recipe1 , '<STR_LIT>' , logBuild = True ) <EOL> def testWebApp ( self ) : <EOL> raise testhelp . SkipTestException ( '<STR_LIT>' ) <EOL> built , d = self . buildRecipe ( self . test_recipe2 , '<STR_LIT>' , logBuild = True ) </s>
