<s> import os <EOL> from conary . deps import deps <EOL> from conary . local import database <EOL> from conary_test import rephelp <EOL> from conary . repository import changeset <EOL> from conary . repository import errors <EOL> from conary . repository . trovesource import ( <EOL> ChangesetFilesTroveSource , <EOL> ChangeSetJobSource , <EOL> SimpleTroveSource , <EOL> stack , <EOL> TroveListTroveSource , <EOL> TroveSourceStack , <EOL> ) <EOL> from conary . versions import Label <EOL> from conary . versions import VersionFromString as VFS , ThawVersion <EOL> class SimplestFindTroveSource ( SimpleTroveSource ) : <EOL> def addTroves ( self , * troveTups ) : <EOL> for troveTup in troveTups : <EOL> self . addTrove ( troveTup [ <NUM_LIT:0> ] , troveTup [ <NUM_LIT:1> ] , troveTup [ <NUM_LIT:2> ] ) <EOL> def reset ( self ) : <EOL> self . _trovesByName = { } <EOL> def troveDictMatches ( troveDict , troveTups ) : <EOL> troveTups = set ( troveTups ) <EOL> troveCount = len ( troveTups ) <EOL> d = troveDict . copy ( ) <EOL> foundCount = <NUM_LIT:0> <EOL> for n , versionDict in troveDict . iteritems ( ) : <EOL> for v , flavors in versionDict . iteritems ( ) : <EOL> for f in flavors : <EOL> if ( n , v , f ) not in troveTups : <EOL> return False <EOL> foundCount += <NUM_LIT:1> <EOL> return foundCount == troveCount <EOL> class TroveSourceTest ( rephelp . RepositoryHelper ) : <EOL> def testVersionMatching ( self ) : <EOL> v1 = ThawVersion ( '<STR_LIT>' ) <EOL> v2 = ThawVersion ( '<STR_LIT>' ) <EOL> v1b = ThawVersion ( '<STR_LIT>' ) <EOL> v2b = ThawVersion ( '<STR_LIT>' ) <EOL> nodeps = deps . parseFlavor ( '<STR_LIT>' ) <EOL> s = SimplestFindTroveSource ( ) <EOL> n = '<STR_LIT:test>' <EOL> n2 = '<STR_LIT>' <EOL> t_v1 = ( n , v1 , nodeps ) <EOL> t_v2 = ( n , v2 , nodeps ) <EOL> t_v1b = ( n , v1b , nodeps ) <EOL> t_v2b = ( n , v2b , nodeps ) <EOL> t2_v1 = ( n2 , v1 , nodeps ) <EOL> t2_v2 = ( n2 , v2 , nodeps ) <EOL> t2_v1b = ( n2 , v1b , nodeps ) <EOL> t2_v2b = ( n2 , v2b , nodeps ) <EOL> lbl_a = v1 . branch ( ) . label ( ) <EOL> lbl_b = v1b . branch ( ) . label ( ) <EOL> s . addTroves ( t_v1 , t_v2 , t_v1b , t_v2b , t2_v1 , t2_v2 , t2_v1b , t2_v2b ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : None } , n2 : { lbl_b : None } } ) <EOL> assert ( troveDictMatches ( d , [ t_v2 , t2_v2b ] ) ) <EOL> d = s . getTroveVersionsByLabel ( { n : { lbl_a : None } , n2 : { lbl_b : None } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1 , t_v2 , t2_v2b , t2_v1b ] ) ) <EOL> d = s . getTroveVersionsByLabel ( { n : { lbl_a : None , lbl_b : None } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1 , t_v2 , t_v1b , t_v2b ] ) ) <EOL> d = s . getTroveLeavesByBranch ( { n : { v1 . branch ( ) : None } , <EOL> n2 : { v2b . branch ( ) : None } } ) <EOL> assert ( troveDictMatches ( d , [ t_v2 , t2_v2b ] ) ) <EOL> d = s . getTroveVersionsByBranch ( { n : { v1 . branch ( ) : None } , <EOL> n2 : { v2b . branch ( ) : None } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1 , t_v2 , t2_v1b , t2_v2b ] ) ) <EOL> d = s . getTroveVersionFlavors ( { n : { v1 : None , v2b : None } , <EOL> n2 : { v2 : None , v1b : None } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1 , t_v2b , t2_v2 , t2_v1b ] ) ) <EOL> def testFlavorMatchingAsRepository ( self ) : <EOL> v1 = ThawVersion ( '<STR_LIT>' ) <EOL> v2 = ThawVersion ( '<STR_LIT>' ) <EOL> nodeps = deps . parseFlavor ( '<STR_LIT>' ) <EOL> rl_nossl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> rl_ssl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> norl_ssl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> norl_nossl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> p_rl_nossl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> p_rl_ssl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> p_norl_ssl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> p_norl_nossl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> ssl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> rl = deps . parseFlavor ( '<STR_LIT>' ) <EOL> s = SimplestFindTroveSource ( ) <EOL> s . searchAsRepository ( ) <EOL> n = '<STR_LIT>' <EOL> n2 = '<STR_LIT>' <EOL> t_v1_rl_nossl = ( n , v1 , rl_nossl ) <EOL> t_v1_norl_ssl = ( n , v1 , norl_ssl ) <EOL> t_v2_norl_nossl = ( n , v2 , norl_nossl ) <EOL> t_v2_rl_ssl = ( n , v2 , rl_ssl ) <EOL> lbl_a = v1 . branch ( ) . label ( ) <EOL> s . addTroves ( t_v1_rl_nossl , t_v1_norl_ssl , t_v2_norl_nossl , t_v2_rl_ssl ) <EOL> for trv in t_v1_rl_nossl , t_v1_norl_ssl , t_v2_norl_nossl , t_v2_rl_ssl : <EOL> self . addComponent ( * trv ) <EOL> repos = self . openRepository ( ) <EOL> assert ( s . hasTroves ( [ t_v1_rl_nossl ] ) [ <NUM_LIT:0> ] ) <EOL> for src in s , repos : <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ rl_nossl ] } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1_rl_nossl ] ) ) <EOL> d = src . getTroveLeavesByLabel ( { n : { lbl_a : [ p_rl_nossl ] } } , <EOL> bestFlavor = False ) <EOL> assert ( troveDictMatches ( d , [ t_v2_rl_ssl , t_v1_rl_nossl ] ) ) <EOL> d = src . getTroveLeavesByLabel ( { n : { lbl_a : [ rl_nossl , rl_ssl ] } } , <EOL> bestFlavor = True ) <EOL> assert ( troveDictMatches ( d , [ t_v1_rl_nossl , t_v2_rl_ssl ] ) ) <EOL> d = src . getTroveLeavesByLabel ( { n : { lbl_a : [ nodeps ] } } , <EOL> bestFlavor = True ) <EOL> assert ( troveDictMatches ( d , [ t_v2_norl_nossl ] ) ) <EOL> d = src . getTroveLeavesByLabel ( { n : { lbl_a : [ ssl ] } } , <EOL> bestFlavor = True ) <EOL> assert ( troveDictMatches ( d , [ t_v1_norl_ssl ] ) ) <EOL> d = src . getTroveLeavesByLabel ( { n : { lbl_a : [ p_norl_ssl ] } } , <EOL> bestFlavor = True ) <EOL> assert ( troveDictMatches ( d , [ t_v2_rl_ssl ] ) ) <EOL> s . searchAsDatabase ( ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ p_rl_nossl ] } } , <EOL> bestFlavor = False ) <EOL> assert ( troveDictMatches ( d , [ t_v1_rl_nossl ] ) ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ rl_nossl , rl_ssl ] } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1_rl_nossl , t_v2_rl_ssl ] ) ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ nodeps ] } } ) <EOL> assert ( troveDictMatches ( d , [ t_v2_norl_nossl ] ) or <EOL> troveDictMatches ( d , [ t_v2_rl_ssl ] ) ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ ssl ] } } ) <EOL> assert ( troveDictMatches ( d , [ t_v2_rl_ssl ] ) ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ rl ] } } ) <EOL> assert ( troveDictMatches ( d , [ t_v2_rl_ssl ] ) ) <EOL> d = s . getTroveLeavesByLabel ( { n : { lbl_a : [ p_norl_ssl ] } } ) <EOL> assert ( troveDictMatches ( d , [ t_v1_norl_ssl ] ) ) <EOL> def setUpGroupOddities ( self ) : <EOL> def _commitRecipe ( name , recipe , new = True ) : <EOL> oldDir = os . getcwd ( ) <EOL> os . chdir ( self . workDir ) <EOL> if new : <EOL> self . newpkg ( name ) <EOL> else : <EOL> self . checkout ( name ) <EOL> os . chdir ( name ) <EOL> self . writeFile ( '<STR_LIT>' % name , recipe ) <EOL> if new : <EOL> self . addfile ( '<STR_LIT>' % name ) <EOL> self . commit ( ) <EOL> os . chdir ( oldDir ) <EOL> groupTrove = """<STR_LIT>""" <EOL> groupTrove2 = """<STR_LIT>""" <EOL> self . addTestPkg ( <NUM_LIT:1> ) <EOL> self . cookTestPkg ( <NUM_LIT:1> ) <EOL> self . addTestPkg ( <NUM_LIT:1> , content = "<STR_LIT>" ) <EOL> self . addTestPkg ( <NUM_LIT:2> , flags = '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> self . cookTestPkg ( <NUM_LIT:2> ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> self . cookTestPkg ( <NUM_LIT:2> ) <EOL> self . addTestPkg ( <NUM_LIT:3> , flags = '<STR_LIT>' ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> self . cookTestPkg ( <NUM_LIT:3> ) <EOL> self . overrideBuildFlavor ( '<STR_LIT>' ) <EOL> self . cfg . buildLabel = Label ( '<STR_LIT>' ) <EOL> self . addTestPkg ( <NUM_LIT:4> , content = '<STR_LIT>' ) <EOL> self . cookTestPkg ( <NUM_LIT:4> ) <EOL> self . cfg . buildLabel = Label ( '<STR_LIT>' ) <EOL> self . addTestPkg ( <NUM_LIT:5> ) <EOL> self . cookTestPkg ( <NUM_LIT:5> ) <EOL> _commitRecipe ( '<STR_LIT>' , groupTrove2 ) <EOL> self . cookFromRepository ( '<STR_LIT>' ) <EOL> self . cfg . buildLabel = Label ( '<STR_LIT>' ) <EOL> _commitRecipe ( '<STR_LIT>' , groupTrove ) <EOL> self . cookFromRepository ( '<STR_LIT>' ) <EOL> groupTrove += '''<STR_LIT>''' <EOL> self . addTestPkg ( <NUM_LIT:6> ) <EOL> _commitRecipe ( '<STR_LIT>' , groupTrove , new = False ) <EOL> def testFindTroves ( self ) : <EOL> self . repos = self . openRepository ( ) <EOL> self . setUpGroupOddities ( ) <EOL> ts = TroveListTroveSource ( self . repos , [ ( '<STR_LIT>' , <EOL> VFS ( '<STR_LIT>' ) , <EOL> deps . parseFlavor ( '<STR_LIT>' ) ) ] ) <EOL> assert ( len ( ts . trovesByName ( '<STR_LIT>' ) ) == <NUM_LIT:1> ) <EOL> assert ( len ( ts . trovesByName ( '<STR_LIT>' ) ) == <NUM_LIT:1> ) <EOL> assert ( len ( ts . findTrove ( None , ( '<STR_LIT>' , None , None ) ) ) == <NUM_LIT:1> ) <EOL> ts . searchAsDatabase ( ) <EOL> assert ( len ( ts . findTrove ( None , ( '<STR_LIT>' , <EOL> '<STR_LIT>' , None ) ) ) == <NUM_LIT:1> ) <EOL> def testFindTrovesNotAcrossLabels ( self ) : <EOL> v = ThawVersion ( '<STR_LIT>' ) <EOL> v2 = ThawVersion ( '<STR_LIT>' ) <EOL> ts = SimpleTroveSource ( [ ( '<STR_LIT>' , v , <EOL> deps . parseFlavor ( '<STR_LIT>' ) ) , <EOL> ( '<STR_LIT>' , v2 , <EOL> deps . parseFlavor ( '<STR_LIT>' ) ) ] ) <EOL> queries = [ ( '<STR_LIT>' , None , None ) , <EOL> ( '<STR_LIT>' , '<STR_LIT:1.0>' , None ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , None ) , <EOL> ( '<STR_LIT>' , '<STR_LIT>' , None ) ] <EOL> for q in queries : <EOL> results = ts . findTroves ( None , [ q ] , <EOL> deps . parseFlavor ( '<STR_LIT>' ) , acrossLabels = False ) <EOL> assert ( len ( results [ q ] ) == <NUM_LIT:2> ) <EOL> class ChangesetFilesTest ( rephelp . RepositoryHelper ) : <EOL> def testSimple ( self ) : <EOL> r1 = self . addComponent ( '<STR_LIT>' , '<STR_LIT>' , fileContents = [ ] , requires = '<STR_LIT>' ) <EOL> r2 = self . addComponent ( '<STR_LIT>' , '<STR_LIT>' , fileContents = [ ] , requires = '<STR_LIT>' ) <EOL> d1 = self . addComponent ( '<STR_LIT>' , '<STR_LIT>' , filePrimer = <NUM_LIT:1> ) <EOL> l1 = self . addComponent ( '<STR_LIT>' , '<STR_LIT>' , filePrimer = <NUM_LIT:2> , <EOL> provides = '<STR_LIT>' ) <EOL> db = database . Database ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> db . addTrove ( r1 ) <EOL> repos = self . openRepository ( ) <EOL> relCs = repos . createChangeSet ( [ <EOL> ( '<STR_LIT>' , ( r1 . getVersion ( ) , r1 . getFlavor ( ) ) , <EOL> ( r2 . getVersion ( ) , r2 . getFlavor ( ) ) , <EOL> False ) ] ) <EOL> absCs = repos . createChangeSet ( [ <EOL> ( '<STR_LIT>' , ( None , None ) , <EOL> ( d1 . getVersion ( ) , d1 . getFlavor ( ) ) , <EOL> False ) , <EOL> ( '<STR_LIT>' , ( None , None ) , <EOL> ( l1 . getVersion ( ) , l1 . getFlavor ( ) ) , <EOL> False ) ] ) <EOL> trvSrc = ChangesetFilesTroveSource ( db , storeDeps = True ) <EOL> trvSrc . addChangeSet ( relCs ) <EOL> trvSrc . addChangeSet ( absCs ) <EOL> for trv in ( r2 , d1 , l1 ) : <EOL> [ otherTrv ] = trvSrc . getTroves ( [ ( trv . getName ( ) , trv . getVersion ( ) , <EOL> trv . getFlavor ( ) ) ] , <EOL> withFiles = False ) <EOL> assert ( trv == otherTrv ) <EOL> suggMap = trvSrc . resolveDependencies ( None , [ r2 . getRequires ( ) , <EOL> r1 . getRequires ( ) ] ) <EOL> assert ( suggMap [ r1 . getRequires ( ) ] == [ [ ( d1 . getName ( ) , d1 . getVersion ( ) , <EOL> d1 . getFlavor ( ) ) ] ] ) <EOL> suggs = suggMap [ r2 . getRequires ( ) ] <EOL> assert ( [ ( d1 . getName ( ) , d1 . getVersion ( ) , d1 . getFlavor ( ) ) ] in suggs ) <EOL> assert ( [ ( l1 . getName ( ) , l1 . getVersion ( ) , l1 . getFlavor ( ) ) ] in suggs ) <EOL> def testUselessRelChangeset ( self ) : <EOL> r1 = self . addCollection ( '<STR_LIT:foo>' , '<STR_LIT:1>' , [ '<STR_LIT>' ] , createComps = True ) <EOL> r2 = self . addCollection ( '<STR_LIT:foo>' , '<STR_LIT:2>' , [ '<STR_LIT>' ] , createComps = True ) <EOL> db = database . Database ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> db . addTrove ( r1 ) <EOL> chg = ( '<STR_LIT:foo>' , ( r1 . getVersion ( ) , r1 . getFlavor ( ) ) , <EOL> ( r2 . getVersion ( ) , r2 . getFlavor ( ) ) , False ) <EOL> repos = self . openRepository ( ) <EOL> relCs = repos . createChangeSet ( [ chg ] , recurse = True ) <EOL> trvSrc = ChangesetFilesTroveSource ( db , storeDeps = True ) <EOL> trvSrc . addChangeSet ( relCs ) <EOL> fooRun = ( '<STR_LIT>' , r2 . getVersion ( ) , r2 . getFlavor ( ) ) <EOL> assert ( trvSrc . hasTroves ( [ fooRun ] ) == [ False ] ) <EOL> assert ( trvSrc . hasTroves ( [ r2 . getNameVersionFlavor ( ) ] ) == [ True ] ) <EOL> def testCreateNewChangesetNotInSource ( self ) : <EOL> r1 = self . addCollection ( '<STR_LIT:foo>' , '<STR_LIT:1>' , [ '<STR_LIT>' ] , createComps = True ) <EOL> self . addComponent ( '<STR_LIT>' , '<STR_LIT:2>' , filePrimer = <NUM_LIT:2> ) <EOL> r2 = self . addCollection ( '<STR_LIT:foo>' , '<STR_LIT:2>' , [ '<STR_LIT>' ] ) <EOL> absChg = [ ( '<STR_LIT:foo>' , ( None , None ) , ( r1 . getVersion ( ) , r1 . getFlavor ( ) ) , True ) , <EOL> ( '<STR_LIT:foo>' , ( None , None ) , ( r2 . getVersion ( ) , r2 . getFlavor ( ) ) , True ) ] <EOL> repos = self . openRepository ( ) <EOL> absCs = repos . createChangeSet ( absChg , recurse = True ) <EOL> trvSrc = ChangesetFilesTroveSource ( None ) <EOL> trvSrc . addChangeSet ( absCs ) <EOL> relChg = ( '<STR_LIT:foo>' , ( r1 . getVersion ( ) , r1 . getFlavor ( ) ) , <EOL> ( r2 . getVersion ( ) , r2 . getFlavor ( ) ) , False ) <EOL> newCs , remainder = trvSrc . createChangeSet ( [ relChg ] , recurse = False , <EOL> withFiles = False , withFileContents = False ) <EOL> assert ( not remainder ) <EOL> trvCs = newCs . iterNewTroveList ( ) . next ( ) <EOL> assert ( trvCs . getNewVersion ( ) == r2 . getVersion ( ) ) <EOL> assert ( trvCs . getOldVersion ( ) == r1 . getVersion ( ) ) <EOL> badChg = ( '<STR_LIT:foo>' , ( r1 . getVersion ( ) , r1 . getFlavor ( ) ) , <EOL> ( r2 . getVersion ( ) , deps . parseFlavor ( '<STR_LIT:foo>' ) ) , False ) <EOL> newCs , remainder = trvSrc . createChangeSet ( [ badChg ] , recurse = False , <EOL> withFiles = False , withFileContents = False ) <EOL> assert ( remainder ) <EOL> assert ( newCs . isEmpty ( ) ) <EOL> badChg = ( '<STR_LIT:foo>' , ( r1 . getVersion ( ) , deps . parseFlavor ( '<STR_LIT:foo>' ) ) , <EOL> ( r2 . getVersion ( ) , r2 . getFlavor ( ) ) , False ) <EOL> newCs , remainder = trvSrc . createChangeSet ( [ badChg ] , recurse = False , <EOL> withFiles = False , withFileContents = False ) <EOL> assert ( remainder ) <EOL> assert ( newCs . isEmpty ( ) ) <EOL> relCs = repos . createChangeSet ( [ relChg ] , recurse = True ) <EOL> db = self . openDatabase ( ) <EOL> trvSrc = ChangesetFilesTroveSource ( db ) <EOL> trvSrc . addChangeSet ( relCs ) <EOL> newCs , remainder = trvSrc . createChangeSet ( absChg , recurse = False , <EOL> withFiles = False , withFileContents = False ) <EOL> assert ( len ( remainder ) == <NUM_LIT:2> ) <EOL> assert ( newCs . isEmpty ( ) ) <EOL> self . updatePkg ( [ '<STR_LIT>' % r1 . getVersion ( ) ] ) <EOL> trvSrc = ChangesetFilesTroveSource ( db ) <EOL> trvSrc . addChangeSet ( relCs ) <EOL> newCs , remainder = trvSrc . createChangeSet ( absChg , recurse = False , <EOL> withFiles = False , withFileContents = False ) <EOL> assert ( not remainder ) <EOL> assert ( len ( list ( newCs . iterNewTroveList ( ) ) ) == <NUM_LIT:2> ) <EOL> def testTroveSourceStack ( self ) : <EOL> s1 = SimplestFindTroveSource ( ) <EOL> s2 = SimplestFindTroveSource ( ) <EOL> s3 = SimplestFindTroveSource ( ) <EOL> nodeps = deps . parseFlavor ( '<STR_LIT>' ) <EOL> count = <NUM_LIT:3> <EOL> names = [ ] <EOL> versions = [ ] <EOL> for v in range ( count ) : <EOL> sv = str ( v + <NUM_LIT:1> ) <EOL> versions . append ( ThawVersion ( '<STR_LIT>' % sv ) ) <EOL> names . append ( "<STR_LIT>" % sv ) <EOL> t = [ ] <EOL> for i in range ( count ) : <EOL> l = [ ] <EOL> t . append ( l ) <EOL> name = names [ i ] <EOL> for j in range ( count ) : <EOL> l . append ( ( name , versions [ j ] , nodeps ) ) <EOL> s1 . addTroves ( t [ <NUM_LIT:0> ] [ <NUM_LIT:1> ] ) <EOL> s2 . addTroves ( t [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , t [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] ) <EOL> s3 . addTroves ( t [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , t [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , t [ <NUM_LIT:2> ] [ <NUM_LIT:2> ] ) <EOL> try : <EOL> ts1 = stack ( s1 ) <EOL> except Exception , e : <EOL> self . fail ( "<STR_LIT>" % e ) <EOL> self . assertEqual ( ts1 , s1 ) <EOL> ret = ts1 . hasTroves ( [ t [ <NUM_LIT:0> ] [ <NUM_LIT:0> ] , t [ <NUM_LIT:1> ] [ <NUM_LIT:1> ] , t [ <NUM_LIT:2> ] [ <NUM_LIT:2> ] ] ) <EOL> self . assertEqual ( ret , [ True , False , False ] ) <EOL> ts2 = stack ( ts1 ) <EOL> ret = ts1 . hasTroves ( [ t [ <NUM_LIT:0> ] [ <NUM_LIT:2> ] , t [ <NUM_LIT:1> ] [ <NUM_LIT:0> ] , t [ <NUM_LIT:2> ] [ <NUM_LIT:1> ] ] ) <EOL> self . assertEqual ( ret , [ True , False , False ] ) <EOL> ts3 = stack ( s1 , s3 ) <EOL> ts4 = stack ( s2 , ts3 ) <EOL> ts5 = TroveSourceStack ( s2 , ts3 ) <EOL> for s in [ s1 , s2 , s3 ] : <EOL> self . assertTrue ( ts4 . hasSource ( s ) ) <EOL> self . assertTrue ( ts5 . hasSource ( s ) ) <EOL> for ( rs , es ) in zip ( ts4 . iterSources ( ) , [ s2 , s1 , s3 ] ) : <EOL> self . assertEqual ( rs , es ) <EOL> for ( rs , es ) in zip ( ts5 . iterSources ( ) , [ s2 , s1 , s3 ] ) : <EOL> self . assertEqual ( rs , es ) <EOL> ts6 = stack ( s1 , s1 ) <EOL> self . assertNotEqual ( ts6 , s1 ) <EOL> self . assertTrue ( isinstance ( ts6 , TroveSourceStack ) ) <EOL> ts7 = stack ( ts6 , ts6 ) <EOL> self . assertEqual ( ts7 , ts6 ) <EOL> ts8 = stack ( ts3 , ts4 ) <EOL> for s in ts8 . iterSources ( ) : <EOL> self . assertFalse ( isinstance ( s , TroveSourceStack ) ) <EOL> def testUnreachableSource ( self ) : <EOL> """<STR_LIT>""" <EOL> repos_alive = self . openRepository ( <NUM_LIT:0> ) <EOL> repos_dead = self . openRepository ( <NUM_LIT:1> ) <EOL> trv = self . addComponent ( '<STR_LIT>' , '<STR_LIT>' , <EOL> repos = repos_dead ) <EOL> grp = self . addCollection ( '<STR_LIT>' , [ trv ] , repos = repos_alive ) <EOL> self . stopRepository ( <NUM_LIT:1> ) <EOL> n , v , f = grp . getNameVersionFlavor ( ) <EOL> s = stack ( repos_alive , repos_dead ) <EOL> self . assertRaises ( errors . OpenError , s . createChangeSet , <EOL> [ ( n , ( None , None ) , ( v , f ) , True ) ] , <EOL> recurse = True , withFiles = False ) <EOL> class ChangeSetJobSourceTest ( rephelp . RepositoryHelper ) : <EOL> def testBugFindTroves ( self ) : <EOL> db = database . Database ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> csjs = ChangeSetJobSource ( None , db ) <EOL> self . assertEqual ( csjs . findTroves ( '<STR_LIT:a>' , [ ] ) , { } ) <EOL> def testBugMergeDepSuggestions ( self ) : <EOL> db = database . Database ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> csjs = ChangeSetJobSource ( None , db ) <EOL> allSuggs = { '<STR_LIT:a>' : [ [ ] ] } <EOL> newSuggs = { '<STR_LIT:a>' : [ [ <NUM_LIT:2> ] ] } <EOL> csjs . mergeDepSuggestions ( allSuggs , newSuggs ) <EOL> self . assertEqual ( allSuggs , newSuggs ) <EOL> def testTwoChangeSetsWithSameTroveAndDiffConfig ( self ) : <EOL> trv = self . addComponent ( '<STR_LIT>' , [ ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> trv2 = self . addComponent ( '<STR_LIT>' , [ ( '<STR_LIT>' , '<STR_LIT>' ) ] ) <EOL> repos = self . openRepository ( ) <EOL> csPath = self . workDir + '<STR_LIT>' <EOL> csPath2 = self . workDir + '<STR_LIT>' <EOL> self . changeset ( repos , '<STR_LIT>' , csPath ) <EOL> self . changeset ( repos , '<STR_LIT>' , csPath2 ) <EOL> cs1 = changeset . ChangeSetFromFile ( csPath ) <EOL> cs2 = changeset . ChangeSetFromFile ( csPath2 ) <EOL> self . updatePkg ( '<STR_LIT>' ) <EOL> db = self . openDatabase ( ) <EOL> source = ChangesetFilesTroveSource ( db ) <EOL> source . addChangeSets ( [ cs1 , cs2 ] , True ) <EOL> n , v , f = trv . getNameVersionFlavor ( ) <EOL> v2 , f2 = trv2 . getNameVersionFlavor ( ) [ <NUM_LIT:1> : ] <EOL> newCs , remainder = source . createChangeSet ( [ ( n , ( v , f ) , ( v2 , f2 ) , False ) ] , <EOL> withFiles = True , withFileContents = True , <EOL> useDatabase = True ) <EOL> assert ( not remainder ) </s>
