<s> import os <EOL> from conary_test import rephelp <EOL> from conary_test import recipes <EOL> from conary import versions <EOL> from conary . repository . netrepos import versionops <EOL> from conary . deps import deps <EOL> from conary . local import database <EOL> class FlavorTest ( rephelp . RepositoryHelper ) : <EOL> def cmpQueryResult ( self , d , targ ) : <EOL> def _flavorCmp ( a , b ) : <EOL> a = str ( a ) <EOL> b = str ( b ) <EOL> if a < b : <EOL> return - <NUM_LIT:1> <EOL> elif a == b : <EOL> return <NUM_LIT:0> <EOL> else : <EOL> return <NUM_LIT:1> <EOL> for versionDict in d . itervalues ( ) : <EOL> for flavorList in versionDict . itervalues ( ) : <EOL> flavorList . sort ( _flavorCmp ) <EOL> for versionDict in targ . itervalues ( ) : <EOL> for flavorList in versionDict . itervalues ( ) : <EOL> flavorList . sort ( _flavorCmp ) <EOL> assert ( d == targ ) <EOL> def testFlavorQueries ( self ) : <EOL> def _build ( v , f ) : <EOL> self . addComponent ( '<STR_LIT>' , str ( v ) , flavor = f ) <EOL> self . addCollection ( '<STR_LIT>' , str ( v ) , [ '<STR_LIT>' ] , <EOL> defaultFlavor = f ) <EOL> v1 = versions . VersionFromString ( '<STR_LIT>' ) <EOL> v2 = versions . VersionFromString ( '<STR_LIT>' ) <EOL> defFlavor = deps . parseFlavor ( '<STR_LIT>' ) <EOL> noReadLine = deps . parseFlavor ( '<STR_LIT>' ) <EOL> for version , flavor in [ ( v1 , defFlavor ) , ( v1 , noReadLine ) ] : <EOL> _build ( version , flavor ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> buildBranch = versions . VersionFromString ( "<STR_LIT>" % <EOL> self . cfg . buildLabel . asString ( ) ) <EOL> repos = self . openRepository ( ) <EOL> d = repos . getTroveVersionList ( '<STR_LIT:localhost>' , { None : None } ) <EOL> full = { '<STR_LIT>' : { v1 : [ defFlavor , noReadLine ] } , <EOL> '<STR_LIT>' : { v1 : [ defFlavor , noReadLine ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveVersionList ( '<STR_LIT:localhost>' , { None : [ defFlavor ] } ) <EOL> full = { '<STR_LIT>' : { v1 : [ defFlavor ] } , <EOL> '<STR_LIT>' : { v1 : [ defFlavor ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveVersionList ( '<STR_LIT:localhost>' , { None : [ noReadLine ] } ) <EOL> full = { '<STR_LIT>' : { v1 : [ defFlavor , noReadLine ] } , <EOL> '<STR_LIT>' : { v1 : [ defFlavor , noReadLine ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveLeavesByBranch ( <EOL> { '<STR_LIT>' : { buildBranch : None } } , <EOL> bestFlavor = False ) <EOL> self . cmpQueryResult ( d , { '<STR_LIT>' : <EOL> { v1 : [ defFlavor , noReadLine ] } } ) <EOL> d = repos . getTroveLeavesByLabel ( <EOL> { None : { self . cfg . buildLabel : [ defFlavor ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v1 : [ defFlavor ] } , <EOL> '<STR_LIT>' : { v1 : [ defFlavor ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveLatestByLabel ( <EOL> { None : { self . cfg . buildLabel : [ defFlavor ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v1 : [ defFlavor ] } , <EOL> '<STR_LIT>' : { v1 : [ defFlavor ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveLeavesByLabel ( <EOL> { None : { self . cfg . buildLabel : [ noReadLine ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v1 : [ noReadLine ] } , <EOL> '<STR_LIT>' : { v1 : [ noReadLine ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveLatestByLabel ( <EOL> { None : { self . cfg . buildLabel : [ noReadLine ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v1 : [ noReadLine ] } , <EOL> '<STR_LIT>' : { v1 : [ noReadLine ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> _build ( v2 , defFlavor ) <EOL> d = repos . getTroveLeavesByLabel ( <EOL> { None : { self . cfg . buildLabel : [ defFlavor ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v2 : [ defFlavor ] } , <EOL> '<STR_LIT>' : { v2 : [ defFlavor ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveLeavesByLabel ( <EOL> { None : { self . cfg . buildLabel : [ noReadLine ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v2 : [ defFlavor ] } , <EOL> '<STR_LIT>' : { v2 : [ defFlavor ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> d = repos . getTroveLatestByLabel ( <EOL> { None : { self . cfg . buildLabel : [ noReadLine ] } } , <EOL> bestFlavor = True ) <EOL> full = { '<STR_LIT>' : { v2 : [ defFlavor ] } , <EOL> '<STR_LIT>' : { v2 : [ defFlavor ] } } <EOL> self . cmpQueryResult ( d , full ) <EOL> disallowReadLine = deps . parseFlavor ( <EOL> deps . formatFlavor ( noReadLine ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) ) <EOL> d = repos . getTroveLeavesByLabel ( <EOL> { None : { self . cfg . buildLabel : [ disallowReadLine ] } } , <EOL> bestFlavor = True ) <EOL> self . cmpQueryResult ( d , <EOL> { '<STR_LIT>' : { v1 : [ noReadLine ] } , <EOL> '<STR_LIT>' : { v1 : [ noReadLine ] } } ) <EOL> d = repos . getTroveLatestByLabel ( <EOL> { None : { self . cfg . buildLabel : [ disallowReadLine ] } } , <EOL> bestFlavor = True ) <EOL> self . cmpQueryResult ( d , <EOL> { '<STR_LIT>' : { v1 : [ noReadLine ] } , <EOL> '<STR_LIT>' : { v1 : [ noReadLine ] } } ) <EOL> def _updateFlavor ( self , flavorString ) : <EOL> flavor = deps . parseFlavor ( flavorString ) <EOL> self . cfg . flavor [ <NUM_LIT:0> ] . union ( flavor , <EOL> mergeType = deps . DEP_MERGE_TYPE_OVERRIDE ) <EOL> def _checkVersion ( self , vers , flavorCheck = None ) : <EOL> db = database . Database ( self . cfg . root , self . cfg . dbPath ) <EOL> l = db . getTroveVersionList ( '<STR_LIT>' ) <EOL> assert ( len ( l ) == <NUM_LIT:1> ) <EOL> assert ( l [ <NUM_LIT:0> ] == vers ) <EOL> if flavorCheck is not None : <EOL> flavors = db . getAllTroveFlavors ( { '<STR_LIT>' : l } ) <EOL> flavor = deps . parseFlavor ( flavorCheck ) <EOL> assert ( flavors [ '<STR_LIT>' ] [ vers ] == [ flavor ] ) <EOL> def testSimpleUpdates ( self ) : <EOL> self . resetRepository ( ) <EOL> self . resetRoot ( ) <EOL> trove = self . build ( recipes . manyFlavors , "<STR_LIT>" ) <EOL> v1 = trove . getVersion ( ) <EOL> defFlavor = trove . getFlavor ( ) <EOL> assert ( str ( defFlavor ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors , "<STR_LIT>" ) <EOL> v = trove . getVersion ( ) <EOL> noReadLine = trove . getFlavor ( ) <EOL> assert ( str ( noReadLine ) == '<STR_LIT>' ) <EOL> assert ( v1 == v ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . resetRoot ( ) <EOL> self . _updateFlavor ( '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> assert ( not os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . resetRoot ( ) <EOL> self . _updateFlavor ( '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , flavor = '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . resetRoot ( ) <EOL> self . _updateFlavor ( '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> assert ( not os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . _updateFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors , "<STR_LIT>" ) <EOL> v2 = trove . getVersion ( ) <EOL> assert ( defFlavor == trove . getFlavor ( ) ) <EOL> self . resetRoot ( ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 ) <EOL> assert ( os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . _checkVersion ( v2 ) <EOL> self . resetRoot ( ) <EOL> self . _updateFlavor ( '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 ) <EOL> assert ( not os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . _checkVersion ( v2 ) <EOL> self . resetRoot ( ) <EOL> self . _updateFlavor ( '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 ) <EOL> assert ( not os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> rc = self . logCheck ( self . updatePkg , ( self . rootDir , '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> self . _checkVersion ( v1 ) <EOL> assert ( not os . path . exists ( self . rootDir + '<STR_LIT>' ) ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> rc = self . logCheck ( self . updatePkg , ( self . rootDir , '<STR_LIT>' ) , <EOL> '<STR_LIT>' ) <EOL> def testMixedUpdates ( self ) : <EOL> def _oneSet ( versionStr ) : <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = versionStr ) <EOL> self . _checkVersion ( v2 , '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = versionStr ) <EOL> self . _checkVersion ( v2 , '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = versionStr ) <EOL> self . _checkVersion ( v2 , '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors , "<STR_LIT>" ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors2 , "<STR_LIT>" ) <EOL> v2 = trove . getVersion ( ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors2 , "<STR_LIT>" ) <EOL> assert ( trove . getVersion ( ) == v2 ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> _oneSet ( None ) <EOL> _oneSet ( '<STR_LIT>' ) <EOL> _oneSet ( v2 . asString ( ) ) <EOL> _oneSet ( '<STR_LIT>' ) <EOL> _oneSet ( '<STR_LIT>' ) <EOL> def testSimultaneousInstalls ( self ) : <EOL> def build ( ) : <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors , "<STR_LIT>" ) <EOL> v = trove . getVersion ( ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . manyFlavors , "<STR_LIT>" ) <EOL> assert ( trove . getVersion ( ) == v ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> return v <EOL> v1 = build ( ) <EOL> v2 = build ( ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 , <EOL> flavor = '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 , <EOL> flavor = '<STR_LIT>' , keepExisting = True ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , checkPathConflicts = False ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> self . _checkVersion ( v2 ) <EOL> self . erasePkg ( self . rootDir , '<STR_LIT>' , flavor = '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> assert ( not os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> self . resetRoot ( ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 , <EOL> flavor = '<STR_LIT>' ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v1 , <EOL> flavor = '<STR_LIT>' , keepExisting = True ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , version = v2 , <EOL> flavor = '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> assert ( os . path . exists ( self . rootDir + "<STR_LIT>" ) ) <EOL> self . _checkVersion ( v2 ) <EOL> def testDependencies ( self ) : <EOL> def _checkFlavor ( targ ) : <EOL> db = database . Database ( self . rootDir , self . cfg . dbPath ) <EOL> l = db . getTroveVersionList ( '<STR_LIT>' , withFlavors = True ) <EOL> assert ( str ( l [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) == targ ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . bashMissingRecipe , "<STR_LIT>" ) <EOL> v = trove . getVersion ( ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . bashMissingRecipe , "<STR_LIT>" ) <EOL> v = trove . getVersion ( ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . bashRecipe , "<STR_LIT>" ) <EOL> v = trove . getVersion ( ) <EOL> assert ( str ( trove . getFlavor ( ) ) == '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> trove = self . build ( recipes . bashRecipe , "<STR_LIT>" ) <EOL> assert ( trove . getVersion ( ) == v ) <EOL> self . build ( recipes . bashUserRecipe , '<STR_LIT>' ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . captureOutput ( self . updatePkg , self . rootDir , '<STR_LIT>' , <EOL> resolve = True ) <EOL> _checkFlavor ( '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . captureOutput ( self . updatePkg , self . rootDir , '<STR_LIT>' , <EOL> resolve = True ) <EOL> _checkFlavor ( '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . captureOutput ( self . updatePkg , self . rootDir , '<STR_LIT>' , <EOL> resolve = True ) <EOL> _checkFlavor ( '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . captureOutput ( self . updatePkg , self . rootDir , '<STR_LIT>' , <EOL> resolve = True ) <EOL> _checkFlavor ( '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . captureOutput ( self . updatePkg , self . rootDir , '<STR_LIT>' , <EOL> resolve = True ) <EOL> _checkFlavor ( '<STR_LIT>' ) <EOL> self . resetRoot ( ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . updatePkg ( self . rootDir , '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> self . captureOutput ( self . updatePkg , self . rootDir , '<STR_LIT>' , <EOL> resolve = True ) <EOL> _checkFlavor ( '<STR_LIT>' ) <EOL> def testLeavesFlavor ( self ) : <EOL> repos = self . openRepository ( ) <EOL> server = self . servers . getServer ( <NUM_LIT:0> ) <EOL> tlabel = '<STR_LIT>' <EOL> tlast = ( '<STR_LIT>' % ( tlabel , ) , '<STR_LIT>' ) <EOL> tlist = [ <EOL> ( '<STR_LIT>' % ( tlabel , ) , '<STR_LIT>' ) , <EOL> ( '<STR_LIT>' % ( tlabel , ) , '<STR_LIT>' ) , <EOL> tlast , <EOL> ] <EOL> self . cfg . flavor = [ deps . parseFlavor ( '<STR_LIT>' ) ] <EOL> db = server . reposDB . connect ( ) <EOL> def print_db ( db , tname = None ) : <EOL> cu = db . cursor ( ) <EOL> args = [ ] <EOL> query = """<STR_LIT>""" <EOL> if tname : <EOL> query = query + "<STR_LIT>" <EOL> args . append ( tname ) <EOL> cu . execute ( query , args ) <EOL> ret = cu . fetchall ( ) <EOL> print "<STR_LIT>" <EOL> for x in ret : <EOL> print x <EOL> def set_ts ( db , tname , tversion , ts ) : <EOL> cu = db . cursor ( ) <EOL> updq = """<STR_LIT>""" % ( str ( ts ) , ts , tname , tversion ) <EOL> cu . execute ( updq , [ ] ) <EOL> db . commit ( ) <EOL> def fix_latest ( db ) : <EOL> cu = db . cursor ( ) <EOL> cu . execute ( '<STR_LIT>' ) <EOL> latest = versionops . LatestTable ( db ) <EOL> latest . rebuild ( ) <EOL> db . commit ( ) <EOL> def xcombinations ( items , n ) : <EOL> if n == <NUM_LIT:0> : yield [ ] <EOL> else : <EOL> for i in xrange ( len ( items ) ) : <EOL> for cc in xcombinations ( items [ : i ] + items [ i + <NUM_LIT:1> : ] , n - <NUM_LIT:1> ) : <EOL> yield [ items [ i ] ] + cc <EOL> cnt = <NUM_LIT:0> <EOL> req = { } <EOL> for xlist in xcombinations ( range ( len ( tlist ) ) , len ( tlist ) ) : <EOL> cnt = cnt + <NUM_LIT:1> <EOL> tname = "<STR_LIT>" % ( cnt , ) <EOL> for t in xlist : <EOL> for iter in range ( <NUM_LIT:1> , cnt + <NUM_LIT:1> ) : <EOL> l = ( tname , tlist [ t ] [ <NUM_LIT:0> ] % ( iter , ) , tlist [ t ] [ <NUM_LIT:1> ] ) <EOL> self . addQuickTestComponent ( * l ) <EOL> set_ts ( db , tname , l [ <NUM_LIT:1> ] , t * <NUM_LIT:100> + iter + <NUM_LIT:1> ) <EOL> set_ts ( db , tname , tlast [ <NUM_LIT:0> ] % ( cnt , ) , <NUM_LIT:200> * len ( tlist ) + <NUM_LIT:1> ) <EOL> fix_latest ( db ) <EOL> d = repos . getTroveLeavesByLabel ( <EOL> { tname : { versions . Label ( tlabel ) : self . cfg . flavor } } , <EOL> bestFlavor = True ) <EOL> assert ( len ( d ) == <NUM_LIT:1> ) <EOL> assert ( d . has_key ( tname ) ) <EOL> ret = d [ tname ] <EOL> need = { versions . VersionFromString ( tlast [ <NUM_LIT:0> ] % ( cnt , ) ) : [ deps . parseFlavor ( tlast [ <NUM_LIT:1> ] ) ] } <EOL> if ret != need : <EOL> print <EOL> print "<STR_LIT>" , need <EOL> print "<STR_LIT>" , ret <EOL> print_db ( db , tname ) <EOL> assert ( ret == need ) <EOL> def testLatestByLabel ( self ) : <EOL> def _build ( * specList ) : <EOL> for ( v , f ) in specList : <EOL> self . addComponent ( '<STR_LIT>' , v , flavor = f ) <EOL> v1 = versions . ThawVersion ( '<STR_LIT>' ) <EOL> v2 = versions . ThawVersion ( '<STR_LIT>' ) <EOL> l = v1 . trailingLabel ( ) <EOL> defFlavor = deps . parseFlavor ( '<STR_LIT>' ) <EOL> noReadLine = deps . parseFlavor ( '<STR_LIT>' ) <EOL> reqNoReadLine = deps . parseFlavor ( '<STR_LIT>' ) <EOL> _build ( ( v1 , defFlavor ) , ( v2 , defFlavor ) ) <EOL> repos = self . openRepository ( ) <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : None } } ) <EOL> assert ( d [ '<STR_LIT>' ] . keys ( ) == [ v2 ] ) <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ defFlavor ] } } ) <EOL> assert ( d [ '<STR_LIT>' ] . keys ( ) == [ v2 ] ) <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ defFlavor ] } } , <EOL> bestFlavor = True ) <EOL> assert ( d [ '<STR_LIT>' ] . keys ( ) == [ v2 ] ) <EOL> _build ( ( v1 , noReadLine ) ) <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : None } } ) <EOL> assert ( d [ '<STR_LIT>' ] ) == { v1 : [ noReadLine ] , <EOL> v2 : [ defFlavor ] } <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ noReadLine ] } } , <EOL> bestFlavor = True ) <EOL> assert ( d [ '<STR_LIT>' ] ) == { v2 : [ defFlavor ] } <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ reqNoReadLine ] } } , <EOL> bestFlavor = True ) <EOL> assert ( d [ '<STR_LIT>' ] ) == { v1 : [ noReadLine ] } <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ noReadLine ] } } ) <EOL> assert ( d [ '<STR_LIT>' ] ) == { v2 : [ defFlavor ] , v1 : [ noReadLine ] } <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ defFlavor , <EOL> noReadLine ] } } ) <EOL> assert ( d [ '<STR_LIT>' ] ) == { v2 : [ defFlavor ] , v1 : [ noReadLine ] } <EOL> d = repos . getTroveLatestByLabel ( { '<STR_LIT>' : { l : [ defFlavor , <EOL> reqNoReadLine ] } } , <EOL> bestFlavor = True ) <EOL> assert ( d [ '<STR_LIT>' ] ) == { v2 : [ defFlavor ] , v1 : [ noReadLine ] } </s>
