<s> from testrunner import testhelp <EOL> import itertools <EOL> import pwd <EOL> import grp <EOL> import re <EOL> import os <EOL> import tempfile <EOL> from conary_test import recipes <EOL> from conary_test import rephelp <EOL> from conary import conarycfg , errors <EOL> from conary . cmds import commit <EOL> from conary import trove <EOL> from conary import versions <EOL> from conary . build import use <EOL> from conary . deps import deps <EOL> class LocalCsTest ( rephelp . RepositoryHelper ) : <EOL> def setup ( self ) : <EOL> repos = self . openRepository ( ) <EOL> built = [ ] <EOL> info = { <EOL> '<STR_LIT:user>' : pwd . getpwuid ( os . getuid ( ) ) [ <NUM_LIT:0> ] , <EOL> '<STR_LIT>' : pwd . getpwuid ( os . getuid ( ) ) [ <NUM_LIT:2> ] , <EOL> '<STR_LIT>' : grp . getgrgid ( os . getgid ( ) ) [ <NUM_LIT:0> ] , <EOL> } <EOL> loader = rephelp . LoaderFromString ( recipes . testRecipe1 , "<STR_LIT>" , <EOL> cfg = self . cfg , <EOL> repos = repos , <EOL> component = '<STR_LIT>' ) <EOL> built += self . cookObject ( loader ) <EOL> self . build ( recipes . userInfoRecipe % info , "<STR_LIT>" ) <EOL> return ( built , info ) <EOL> def testBasic ( self ) : <EOL> built , info = self . setup ( ) <EOL> path = self . _testBasic1 ( built , info ) <EOL> self . _testBasic2 ( path , info ) <EOL> def testIncomplete ( self ) : <EOL> raise testhelp . SkipTestException ( '<STR_LIT>' ) <EOL> built , info = self . setup ( ) <EOL> OLD_TROVE_VERSION = trove . TROVE_VERSION <EOL> OLD_TROVE_VERSION_1_1 = trove . TROVE_VERSION_1_1 <EOL> d = { } <EOL> if use . Arch . x86 : <EOL> d = { '<STR_LIT>' : '<STR_LIT>' } <EOL> elif use . Arch . x86_64 : <EOL> d = { '<STR_LIT>' : '<STR_LIT>' } <EOL> else : <EOL> raise NotImplementedError , '<STR_LIT>' <EOL> try : <EOL> trove . TROVE_VERSION = <NUM_LIT:1> <EOL> trove . TROVE_VERSION_1_1 = <NUM_LIT:2> <EOL> self . logFilter . add ( ) <EOL> try : <EOL> path = self . _testBasic1 ( built , info ) <EOL> except errors . ConaryError , err : <EOL> assert ( str ( err ) == '''<STR_LIT>''' % d ) <EOL> else : <EOL> assert ( <NUM_LIT:0> ) <EOL> finally : <EOL> trove . TROVE_VERSION = OLD_TROVE_VERSION <EOL> trove . TROVE_VERSION_1_1 = OLD_TROVE_VERSION_1_1 <EOL> self . resetRoot ( ) <EOL> path = self . _testBasic1 ( built , info ) <EOL> try : <EOL> trove . TROVE_VERSION = <NUM_LIT:1> <EOL> trove . TROVE_VERSION_1_1 = <NUM_LIT:2> <EOL> self . resetRoot ( ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' % info ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> db = self . openDatabase ( ) <EOL> tups = db . findTroves ( None , [ ( '<STR_LIT>' % info , None , None ) , <EOL> ( '<STR_LIT>' , None , None ) ] ) <EOL> tups = list ( itertools . chain ( * tups . itervalues ( ) ) ) <EOL> assert ( [ x for x in db . getTroves ( tups ) if not x . troveInfo . incomplete ( ) ] == [ ] ) <EOL> try : <EOL> self . _testBasic2 ( path , info ) <EOL> except errors . ConaryError , err : <EOL> assert ( re . match ( r'<STR_LIT>' % d , str ( err ) ) ) <EOL> else : <EOL> assert ( <NUM_LIT:0> ) <EOL> finally : <EOL> trove . TROVE_VERSION = OLD_TROVE_VERSION <EOL> trove . TROVE_VERSION_1_1 = OLD_TROVE_VERSION_1_1 <EOL> os . remove ( path ) <EOL> def _testBasic1 ( self , built , info ) : <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' % info ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> ( fd , path ) = tempfile . mkstemp ( ) <EOL> os . close ( fd ) <EOL> self . writeFile ( self . rootDir + "<STR_LIT>" , '<STR_LIT>' ) <EOL> self . writeFile ( self . rootDir + "<STR_LIT>" , <EOL> '<STR_LIT>' ) <EOL> os . chmod ( self . rootDir + "<STR_LIT>" , <NUM_LIT:0> <NUM_LIT> ) <EOL> self . localChangeset ( self . rootDir , '<STR_LIT>' , path ) <EOL> self . resetRoot ( ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' % info ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , path ) <EOL> self . verifyFile ( self . rootDir + "<STR_LIT>" , <EOL> '<STR_LIT>' ) <EOL> self . verifyFile ( self . rootDir + "<STR_LIT>" , <EOL> '<STR_LIT>' ) <EOL> assert ( ( os . stat ( self . rootDir + "<STR_LIT>" ) . st_mode & <NUM_LIT:0> <NUM_LIT> ) <EOL> == <NUM_LIT:0> <NUM_LIT> ) <EOL> self . erasePkg ( self . rootDir , '<STR_LIT>' ) <EOL> return path <EOL> def _testBasic2 ( self , path , info ) : <EOL> commit . doCommit ( self . cfg , path , <EOL> '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' % info ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , <EOL> version = '<STR_LIT>' ) <EOL> self . verifyFile ( self . rootDir + "<STR_LIT>" , <EOL> '<STR_LIT>' ) <EOL> self . verifyFile ( self . rootDir + "<STR_LIT>" , <EOL> '<STR_LIT>' ) <EOL> assert ( ( os . stat ( self . rootDir + "<STR_LIT>" ) . st_mode & <NUM_LIT:0> <NUM_LIT> ) <EOL> == <NUM_LIT:0> <NUM_LIT> ) <EOL> self . erasePkg ( self . rootDir , '<STR_LIT>' ) <EOL> os . remove ( path ) <EOL> def testShadowed ( self ) : <EOL> self . repos = self . openRepository ( ) <EOL> self . addTestPkg ( <NUM_LIT:1> , <EOL> content = '''<STR_LIT>''' ) <EOL> self . mkbranch ( self . cfg . buildLabel , "<STR_LIT>" , "<STR_LIT>" , <EOL> shadow = True ) <EOL> self . cfg . buildLabel = versions . Label ( '<STR_LIT>' ) <EOL> self . cfg . installLabelPath = conarycfg . CfgLabelList ( [ self . cfg . buildLabel ] ) <EOL> self . addTestPkg ( <NUM_LIT:1> , content = '''<STR_LIT>''' ) <EOL> self . cookTestPkg ( <NUM_LIT:1> ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , depCheck = False ) <EOL> self . writeFile ( self . rootDir + "<STR_LIT>" , '<STR_LIT>' ) <EOL> ( fd , path ) = tempfile . mkstemp ( ) <EOL> os . close ( fd ) <EOL> self . localChangeset ( self . rootDir , '<STR_LIT>' , path ) <EOL> commit . doCommit ( self . cfg , path , <EOL> '<STR_LIT>' ) <EOL> assert ( self . repos . hasTrove ( '<STR_LIT>' , versions . VersionFromString ( <EOL> '<STR_LIT>' ) , <EOL> deps . Flavor ( ) ) ) <EOL> commit . doCommit ( self . cfg , path , <EOL> '<STR_LIT>' ) <EOL> assert ( self . repos . hasTrove ( '<STR_LIT>' , versions . VersionFromString ( <EOL> '<STR_LIT>' ) , <EOL> deps . Flavor ( ) ) ) <EOL> os . remove ( path ) </s>
