def _findMomDependencies( self, folder ): """recursively find leaf nodes within folder""" leafNodes = [] if os.path.isdir( folder ): elements = os.listdir( folder ) for element in elements: mApp().debugN( self, 4, 'checking if {0} is a MOM dependency'.format( element ) ) path = os.path.join( folder, element ) dependency = Dependency( path ) if dependency.verify(): # if self._directoryIsLeafNode( path ): leafNodes.append( dependency ) elif os.path.isdir( path ): leafNodes.extend( self._findMomDependencies( path ) ) return leafNodes
def testApplyPackageConfiguration( self ): packageFolder = os.path.join( self.TEST_MOM_ENVIRONMENTS, 'dep-a-1.1.0' ) packageFile = os.path.join( packageFolder, Dependency._ControlFileName ) self.assertTrue( os.path.exists( packageFile ) ) dep = Dependency() dep.setFolder( packageFolder ) self.assertTrue( dep._readControlFile( packageFile ) ) self.assertTrue( dep.isEnabled() ) self.assertEquals( dep.getObjectStatus(), 'test-dep-a-1.1.0' ) with EnvironmentSaver(): dep.apply() self.assertEquals( os.environ[ 'EXAMPLE_VARIABLE'], 'example_variable' ) self.assertTrue( os.environ['PATH'].startswith( 'example_path' ) )
def testApplyDisabledPackageConfiguration( self ): packageFolder = os.path.join( self.TEST_MOM_ENVIRONMENTS, 'dep-a-1.2.0' ) packageFile = os.path.join( packageFolder, Dependency._ControlFileName ) self.assertTrue( os.path.exists( packageFile ) ) dep = Dependency() dep.setFolder( packageFolder ) self.assertTrue( dep._readControlFile( packageFile ) ) self.assertTrue( not dep.isEnabled() ) self.assertEquals( dep.getObjectStatus(), 'test-disabled-dep-a-1.2.0' ) self.assertEquals( dep.getScore(), 120 )