コード例 #1
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testParsing(self):
        self.assertEquals(self.vf.name, "fw")
        self.assertEquals(self.vf.version, "1.2")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 2)
        self.assert_("DarwinX86" in flavors)
        self.assert_("Darwin" in flavors)

        flavor = self.vf.info["DarwinX86"]
        self.assertEquals(flavor['declarer'], 'rhl')
        self.assertEquals(flavor['modifier'], 'rhl')
        self.assertEquals(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEquals(flavor['modified'], 'Tue Oct  9 22:05:03 2007')
        self.assertEquals(flavor['declared'], 'Tue Oct  9 22:05:03 2007')
        self.assertEquals(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEquals(flavor['table_file'], 'fw.table')

        flavor = self.vf.info["Darwin"]
        self.assertEquals(flavor['declarer'], 'rhl')
        self.assertEquals(flavor['modifier'], 'rhl')
        self.assertEquals(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEquals(flavor['modified'], 'Tue Oct  9 22:05:03 2005')
        self.assertEquals(flavor['declared'], 'Tue Oct  9 22:05:03 2005')
        self.assertEquals(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEquals(flavor['table_file'], 'fw.table')

        self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"),
                              "afw",
                              "3.2",
                              verbosity=-1)
        self.assertEquals(self.vf.name, "afw")
        self.assertEquals(self.vf.version, "3.2")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 2)
コード例 #2
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testUPS_DBfile(self):
        vf = VersionFile(os.path.join(testEupsStack, "lapack-3.1.1.version"))
        prod = vf.makeProduct("Linux", "/opt")

        self.assertEqual(prod.dir, "/u/dss/products/Linux/lapack/3.1.1")
        self.assertEqual(prod.tablefile, "/opt/ups_db/lapack/Linux/3.1.1.table")

        prod = vf.makeProduct("Linux", dbpath="/opt/eups/UPS_DB")
        self.assertEqual(prod.tablefile, "/opt/eups/UPS_DB/lapack/Linux/3.1.1.table")
コード例 #3
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testUPS_DBfile(self):
        vf = VersionFile(os.path.join(testEupsStack, "lapack-3.1.1.version"))
        prod = vf.makeProduct("Linux", "/opt")

        self.assertEquals(prod.dir, "/u/dss/products/Linux/lapack/3.1.1")
        self.assertEquals(prod.tablefile,
                          "/opt/ups_db/lapack/Linux/3.1.1.table")

        prod = vf.makeProduct("Linux", dbpath="/opt/eups/UPS_DB")
        self.assertEquals(prod.tablefile,
                          "/opt/eups/UPS_DB/lapack/Linux/3.1.1.table")
コード例 #4
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testWrite(self):
        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table", "ups")

        self.assertEquals(len(self.vf.getFlavors()), 3)
        file = os.path.join(testEupsStack, "tst.version")
        self.vf.write(file=file)

        vf = VersionFile(file)
        self.assertEquals(vf.name, "fw")
        self.assertEquals(vf.version, "1.2")
        flavors = vf.getFlavors()
        self.assertEquals(len(flavors), 3)
        self.assert_("DarwinX86" in flavors)
        self.assert_("Darwin" in flavors)
        self.assert_("Linux:rhel" in flavors)
コード例 #5
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testParsing(self):
        self.assertEqual(self.vf.name, "fw")
        self.assertEqual(self.vf.version, "1.2")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 2)
        self.assertIn("DarwinX86", flavors)
        self.assertIn("Darwin", flavors)

        flavor = self.vf.info["DarwinX86"]
        self.assertEqual(flavor['declarer'], 'rhl')
        self.assertEqual(flavor['modifier'], 'rhl')
        self.assertEqual(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEqual(flavor['modified'], 'Tue Oct  9 22:05:03 2007')
        self.assertEqual(flavor['declared'], 'Tue Oct  9 22:05:03 2007')
        self.assertEqual(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEqual(flavor['table_file'], 'fw.table')

        flavor = self.vf.info["Darwin"]
        self.assertEqual(flavor['declarer'], 'rhl')
        self.assertEqual(flavor['modifier'], 'rhl')
        self.assertEqual(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEqual(flavor['modified'], 'Tue Oct  9 22:05:03 2005')
        self.assertEqual(flavor['declared'], 'Tue Oct  9 22:05:03 2005')
        self.assertEqual(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEqual(flavor['table_file'], 'fw.table')

        self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"),
                              "afw", "3.2", verbosity=-1)
        self.assertEqual(self.vf.name, "afw")
        self.assertEqual(self.vf.version, "3.2")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 2)
コード例 #6
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testWrite(self):
        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table", "ups")

        self.assertEqual(len(self.vf.getFlavors()), 3)
        file=os.path.join(testEupsStack, "tst.version")
        self.vf.write(file=file)

        vf = VersionFile(file)
        self.assertEqual(vf.name, "fw")
        self.assertEqual(vf.version, "1.2")
        flavors = vf.getFlavors()
        self.assertEqual(len(flavors), 3)
        self.assertIn("DarwinX86", flavors)
        self.assertIn("Darwin", flavors)
        self.assertIn("Linux:rhel", flavors)
コード例 #7
0
ファイル: testDb.py プロジェクト: airnandez/eups
class VersionFileTestCase(unittest.TestCase):
    def setUp(self):
        self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"))

    def testParsing(self):
        self.assertEquals(self.vf.name, "fw")
        self.assertEquals(self.vf.version, "1.2")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 2)
        self.assert_("DarwinX86" in flavors)
        self.assert_("Darwin" in flavors)

        flavor = self.vf.info["DarwinX86"]
        self.assertEquals(flavor['declarer'], 'rhl')
        self.assertEquals(flavor['modifier'], 'rhl')
        self.assertEquals(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEquals(flavor['modified'], 'Tue Oct  9 22:05:03 2007')
        self.assertEquals(flavor['declared'], 'Tue Oct  9 22:05:03 2007')
        self.assertEquals(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEquals(flavor['table_file'], 'fw.table')

        flavor = self.vf.info["Darwin"]
        self.assertEquals(flavor['declarer'], 'rhl')
        self.assertEquals(flavor['modifier'], 'rhl')
        self.assertEquals(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEquals(flavor['modified'], 'Tue Oct  9 22:05:03 2005')
        self.assertEquals(flavor['declared'], 'Tue Oct  9 22:05:03 2005')
        self.assertEquals(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEquals(flavor['table_file'], 'fw.table')

        self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"),
                              "afw",
                              "3.2",
                              verbosity=-1)
        self.assertEquals(self.vf.name, "afw")
        self.assertEquals(self.vf.version, "3.2")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 2)

    def testAddFlavor(self):
        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 3)
        self.assert_("Linux:rhel" in flavors)
        info = self.vf.info["Linux:rhel"]
        self.assertEquals(info["table_file"], "fw.table")
        self.assertEquals(info["ups_dir"], "ups")
        self.assertEquals(info["productDir"], "/opt/sw/Linux/fw/1.2")
        self.assert_(info.has_key("declarer"))
        self.assert_(info.has_key("declared"))
        self.assert_(not info.has_key("modifier"))
        declared = info["declared"]
        declarer = info["declarer"]

        self.vf.addFlavor("Linux:rhel", upsdir="ups")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 3)
        self.assert_("Linux:rhel" in flavors)
        info = self.vf.info["Linux:rhel"]
        self.assertEquals(info["table_file"], "fw.table")
        self.assertEquals(info["ups_dir"], "ups")
        self.assertEquals(info["productDir"], "/opt/sw/Linux/fw/1.2")
        self.assertEquals(info["declarer"], declarer)
        self.assertEquals(info["declared"], declared)
        self.assertEquals(info["modifier"], declarer)
        self.assert_(info.has_key("modified"))

        self.vf.removeFlavor("Linux:rhel")
        flavors = self.vf.getFlavors()
        self.assertEquals(len(flavors), 2)
        self.vf.removeFlavor(flavors)
        self.assertEquals(len(self.vf.getFlavors()), 0)
        self.assert_(self.vf.isEmpty())

    def testMakeProduct(self):
        prod = self.vf.makeProduct("Darwin")
        self.assertEquals(prod.name, "fw")
        self.assertEquals(prod.version, "1.2")
        self.assertEquals(prod.dir, "DarwinX86/fw/1.2")
        self.assertEquals(prod.flavor, "Darwin")
        self.assertEquals(prod.tablefile, "DarwinX86/fw/1.2/ups/fw.table")
        self.assertEquals(len(prod.tags), 0)
        self.assert_(prod.db is None)

        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table", "ups")
        prod = self.vf.makeProduct("Linux:rhel")
        self.assertEquals(prod.name, "fw")
        self.assertEquals(prod.version, "1.2")
        self.assertEquals(prod.dir, "/opt/sw/Linux/fw/1.2")
        self.assertEquals(prod.flavor, "Linux:rhel")
        self.assertEquals(prod.tablefile, "/opt/sw/Linux/fw/1.2/ups/fw.table")
        self.assertEquals(len(prod.tags), 0)
        self.assert_(prod.db is None)

        self.assertRaises(ProductNotFound, self.vf.makeProduct, "goober")

        prod = self.vf.makeProducts()
        self.assertEquals(len(prod), 3)
        for p in prod:
            self.assert_(isinstance(p, Product))

    def testWrite(self):
        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table", "ups")

        self.assertEquals(len(self.vf.getFlavors()), 3)
        file = os.path.join(testEupsStack, "tst.version")
        self.vf.write(file=file)

        vf = VersionFile(file)
        self.assertEquals(vf.name, "fw")
        self.assertEquals(vf.version, "1.2")
        flavors = vf.getFlavors()
        self.assertEquals(len(flavors), 3)
        self.assert_("DarwinX86" in flavors)
        self.assert_("Darwin" in flavors)
        self.assert_("Linux:rhel" in flavors)
コード例 #8
0
ファイル: checkVersionFile.py プロジェクト: mwittgen/eups
 def setUp(self):
     self.vf = VersionFile(self.file)
     self.flavors = self._getFlavors(self.file)
コード例 #9
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testPROD_DIRfile(self):
        vf = VersionFile(os.path.join(testEupsStack, "fw.version"))
        prod = vf.makeProduct("Darwin")

        self.assertEquals(prod.dir, "DarwinX86/fw/1.2")
        self.assertEquals(prod.tablefile, "DarwinX86/fw/1.2/ups/fw.table")
コード例 #10
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testUPS_DB(self):
        # test no substitution
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DB/Linux/fw/1.0", "fw.table")
        prod = vf.makeProduct("Linux")
        self.assert_(prod.db is None)
        self.assertEquals(prod.dir, "$UPS_DB/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "$UPS_DB/Linux/fw/1.0/fw.table")

        # test use in product dir
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEquals(prod.db, "/opt/ups_db")
        self.assertEquals(prod.dir, "/opt/ups_db/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/ups_db/Linux/fw/1.0/fw.table")

        prod = vf.makeProduct("Linux", "/opt", "/opt/eups_db")
        self.assertEquals(prod.dir, "/opt/eups_db/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/eups_db/Linux/fw/1.0/fw.table")

        # test integration of ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DB/Linux/fw/1.0", "fw.table", "ups")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEquals(prod.db, "/opt/ups_db")
        self.assertEquals(prod.dir, "/opt/ups_db/Linux/fw/1.0")
        self.assertEquals(prod.tablefile,
                          "/opt/ups_db/Linux/fw/1.0/ups/fw.table")

        # test use in table path
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "/opt/Linux/fw/1.0",
                     "$UPS_DB/Linux/fw/1.0/fw.table", "ups")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEquals(prod.db, "/opt/ups_db")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/ups_db/Linux/fw/1.0/fw.table")

        # test use in ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "Linux/fw/1.0", "fw.table",
                     "$UPS_DB/Linux/fw/1.0/UPS")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEquals(prod.db, "/opt/ups_db")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile,
                          "/opt/ups_db/Linux/fw/1.0/UPS/fw.table")

        # test in combination with FLAVOR
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table",
                     "$UPS_DB/$FLAVOR/ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.db, "/opt/ups_db")
        self.assertEquals(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/ups_db/LinuxARM/ups/fw.table")
コード例 #11
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testFLAVOR(self):

        # test use in product dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "/opt/$FLAVOR/fw/1.0", "fw.table")
        prod = vf.makeProduct("LinuxARM")
        self.assertEqual(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/LinuxARM/fw/1.0/fw.table")

        # test use in product dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table")
        prod = vf.makeProduct("LinuxARM")
        self.assertEqual(prod.dir, "LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "LinuxARM/fw/1.0/fw.table")

        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/LinuxARM/fw/1.0/fw.table")

        # test use in table path
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$FLAVOR/fw.table",
                     "/opt/eups/tables")
        prod = vf.makeProduct("LinuxARM")
        self.assertEqual(prod.dir, "Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/eups/tables/LinuxARM/fw.table")

        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "$FLAVOR/fw.table",
                     "/opt/eups/tables")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/eups/tables/LinuxARM/fw.table")

        # test use in ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table")
        vf.info["LinuxARM"]["ups_dir"] = "$FLAVOR"
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/LinuxARM/fw/1.0/LinuxARM/fw.table")

        # test in combination with PROD_DIR
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table", "$PROD_DIR/UPS")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/LinuxARM/fw/1.0/UPS/fw.table")
コード例 #12
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
 def setUp(self):
     self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"))
コード例 #13
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
class VersionFileTestCase(unittest.TestCase):

    def setUp(self):
        self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"))

    def testParsing(self):
        self.assertEqual(self.vf.name, "fw")
        self.assertEqual(self.vf.version, "1.2")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 2)
        self.assertIn("DarwinX86", flavors)
        self.assertIn("Darwin", flavors)

        flavor = self.vf.info["DarwinX86"]
        self.assertEqual(flavor['declarer'], 'rhl')
        self.assertEqual(flavor['modifier'], 'rhl')
        self.assertEqual(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEqual(flavor['modified'], 'Tue Oct  9 22:05:03 2007')
        self.assertEqual(flavor['declared'], 'Tue Oct  9 22:05:03 2007')
        self.assertEqual(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEqual(flavor['table_file'], 'fw.table')

        flavor = self.vf.info["Darwin"]
        self.assertEqual(flavor['declarer'], 'rhl')
        self.assertEqual(flavor['modifier'], 'rhl')
        self.assertEqual(flavor['productDir'], 'DarwinX86/fw/1.2')
        self.assertEqual(flavor['modified'], 'Tue Oct  9 22:05:03 2005')
        self.assertEqual(flavor['declared'], 'Tue Oct  9 22:05:03 2005')
        self.assertEqual(flavor['ups_dir'], '$PROD_DIR/ups')
        self.assertEqual(flavor['table_file'], 'fw.table')

        self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"),
                              "afw", "3.2", verbosity=-1)
        self.assertEqual(self.vf.name, "afw")
        self.assertEqual(self.vf.version, "3.2")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 2)

    def testAddFlavor(self):
        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 3)
        self.assertIn("Linux:rhel", flavors)
        info = self.vf.info["Linux:rhel"]
        self.assertEqual(info["table_file"], "fw.table")
        self.assertEqual(info["ups_dir"], "ups")
        self.assertEqual(info["productDir"], "/opt/sw/Linux/fw/1.2")
        self.assertIn("declarer", info)
        self.assertIn("declared", info)
        self.assertNotIn("modifier", info)
        declared = info["declared"]
        declarer = info["declarer"]

        self.vf.addFlavor("Linux:rhel", upsdir="ups")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 3)
        self.assertIn("Linux:rhel", flavors)
        info = self.vf.info["Linux:rhel"]
        self.assertEqual(info["table_file"], "fw.table")
        self.assertEqual(info["ups_dir"], "ups")
        self.assertEqual(info["productDir"], "/opt/sw/Linux/fw/1.2")
        self.assertEqual(info["declarer"], declarer)
        self.assertEqual(info["declared"], declared)
        self.assertEqual(info["modifier"], declarer)
        self.assertIn("modified", info)

        self.vf.removeFlavor("Linux:rhel")
        flavors = self.vf.getFlavors()
        self.assertEqual(len(flavors), 2)
        self.vf.removeFlavor(flavors)
        self.assertEqual(len(self.vf.getFlavors()), 0)
        self.assert_(self.vf.isEmpty())

    def testMakeProduct(self):
        prod = self.vf.makeProduct("Darwin")
        self.assertEqual(prod.name, "fw")
        self.assertEqual(prod.version, "1.2")
        self.assertEqual(prod.dir, "DarwinX86/fw/1.2")
        self.assertEqual(prod.flavor, "Darwin")
        self.assertEqual(prod.tablefile, "DarwinX86/fw/1.2/ups/fw.table")
        self.assertEqual(len(prod.tags), 0)
        self.assert_(prod.db is None)

        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table", "ups")
        prod = self.vf.makeProduct("Linux:rhel")
        self.assertEqual(prod.name, "fw")
        self.assertEqual(prod.version, "1.2")
        self.assertEqual(prod.dir, "/opt/sw/Linux/fw/1.2")
        self.assertEqual(prod.flavor, "Linux:rhel")
        self.assertEqual(prod.tablefile, "/opt/sw/Linux/fw/1.2/ups/fw.table")
        self.assertEqual(len(prod.tags), 0)
        self.assert_(prod.db is None)

        self.assertRaises(ProductNotFound, self.vf.makeProduct, "goober")

        prod = self.vf.makeProducts()
        self.assertEqual(len(prod), 3)
        for p in prod:
            self.assert_(isinstance(p, Product))

    def testWrite(self):
        self.vf.addFlavor("Linux:rhel", "/opt/sw/Linux/fw/1.2",
                          "/opt/sw/Linux/fw/1.2/ups/fw.table", "ups")

        self.assertEqual(len(self.vf.getFlavors()), 3)
        file=os.path.join(testEupsStack, "tst.version")
        self.vf.write(file=file)

        vf = VersionFile(file)
        self.assertEqual(vf.name, "fw")
        self.assertEqual(vf.version, "1.2")
        flavors = vf.getFlavors()
        self.assertEqual(len(flavors), 3)
        self.assertIn("DarwinX86", flavors)
        self.assertIn("Darwin", flavors)
        self.assertIn("Linux:rhel", flavors)
コード例 #14
0
 def setUp(self):
     self.vf = VersionFile(self.file)
     self.flavors = self._getFlavors(self.file)
コード例 #15
0
class CheckVersionFileTestCase(unittest.TestCase):
    flavre = re.compile(r"^\s*FLAVOR\s*=\s*")
    qualre = re.compile(r"^\s*QUALIFIERS\s*=\s*")
    def __init__(self, method=None, file=defaultFile, testExist=False,
                 prodroot=None):
        self.file = file
        self.testExist = testExist
        if not prodroot: prodroot = "/opt"
        self.prodroot = prodroot
        if method:
            unittest.TestCase.__init__(self, method)
        else:
            unittest.TestCase.__init__(self, 'testParsing')

    def setUp(self):
        self.vf = VersionFile(self.file)
        self.flavors = self._getFlavors(self.file)

    def tearDown(self):
        pass

    def _getFlavors(self, file):
        out = []
        fd = open(file)
        try:
            for line in fd:
                if self.flavre.match(line):
                    out.append(self.flavre.sub("", line).strip().strip('"').strip("'"))
                elif self.qualre.match(line) and len(out) > 0:
                    line = self.qualre.sub("", line).strip().strip('"').strip("'")
                    if len(line) > 0:
                        out[-1] += ":%s" % line
            return out

#            return map(lambda g: g.strip(),
#                       map(lambda f: self.flavre.sub("", f),
#                           filter(lambda l: self.flavre.match(l), fd)))

        finally:
            fd.close()

    def testParsing(self):
        for flavor in self.flavors:
            sys.stderr.write('+'); sys.stderr.flush()
            prod = self.vf.makeProduct(flavor, self.prodroot)
            self.assertPathOK(prod.dir, "prod.dir")
            self.assertPathOK(prod.db, "prod.db")
            self.assertPathOK(prod.tablefile, "prod.tablefile")

    def assertPathOK(self, path, what):
        self.assertResolvedMacros(path, what)
        self.assertAbs(path, what)
        if self.testExist:
            self.assertPathExists(path, what)

    def assertPathExists(self, path, what):
        self.assert_(os.path.exists(path),
                     "Path %s does not exist: %s" % (what, path))

    def assertResolvedMacros(self, path, what):
        self.assert_(path.find('$') < 0,
                     "Unresolved macro in %s: %s" % (what, path))
    def assertAbs(self, path, what):
        self.assert_(path == "none" or os.path.isabs(path),
                     "Relative path in %s: %s"  % (what, path))

    def shortDescription(self):
        return self.file
コード例 #16
0
ファイル: testDb.py プロジェクト: airnandez/eups
 def setUp(self):
     self.vf = VersionFile(os.path.join(testEupsStack, "fw.version"))
コード例 #17
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testFLAVOR(self):

        # test use in product dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "/opt/$FLAVOR/fw/1.0", "fw.table")
        prod = vf.makeProduct("LinuxARM")
        self.assertEquals(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/LinuxARM/fw/1.0/fw.table")

        # test use in product dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table")
        prod = vf.makeProduct("LinuxARM")
        self.assertEquals(prod.dir, "LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile, "LinuxARM/fw/1.0/fw.table")

        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/LinuxARM/fw/1.0/fw.table")

        # test use in table path
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$FLAVOR/fw.table",
                     "/opt/eups/tables")
        prod = vf.makeProduct("LinuxARM")
        self.assertEquals(prod.dir, "Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/eups/tables/LinuxARM/fw.table")

        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "$FLAVOR/fw.table",
                     "/opt/eups/tables")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/eups/tables/LinuxARM/fw.table")

        # test use in ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table")
        vf.info["LinuxARM"]["ups_dir"] = "$FLAVOR"
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile,
                          "/opt/LinuxARM/fw/1.0/LinuxARM/fw.table")

        # test in combination with PROD_DIR
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table", "$PROD_DIR/UPS")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/LinuxARM/fw/1.0/UPS/fw.table")
コード例 #18
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testPROD_DIR(self):
        # test in table
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$PROD_DIR/fw.table")
        prod = vf.makeProduct("LinuxARM")
        self.assertEqual(prod.dir, "Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "Linux/fw/1.0/fw.table")

        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/Linux/fw/1.0/fw.table")

        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$PROD_DIR/fw.table", "ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/Linux/fw/1.0/fw.table")

        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$PROD_DIR/fw.table",
                     "$FLAVOR/ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/Linux/fw/1.0/fw.table")

        # test in ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "fw.table", "$PROD_DIR/ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/Linux/fw/1.0/ups/fw.table")
コード例 #19
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testPROD_DIR(self):
        # test in table
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$PROD_DIR/fw.table")
        prod = vf.makeProduct("LinuxARM")
        self.assertEquals(prod.dir, "Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "Linux/fw/1.0/fw.table")

        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/Linux/fw/1.0/fw.table")

        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$PROD_DIR/fw.table", "ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/Linux/fw/1.0/fw.table")

        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "$PROD_DIR/fw.table",
                     "$FLAVOR/ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/Linux/fw/1.0/fw.table")

        # test in ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "Linux/fw/1.0", "fw.table", "$PROD_DIR/ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/Linux/fw/1.0/ups/fw.table")
コード例 #20
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testUPS_DB(self):
        # test no substitution
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DB/Linux/fw/1.0", "fw.table")
        prod = vf.makeProduct("Linux")
        self.assert_(prod.db is None)
        self.assertEqual(prod.dir, "$UPS_DB/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "$UPS_DB/Linux/fw/1.0/fw.table")

        # test use in product dir
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEqual(prod.db, "/opt/ups_db")
        self.assertEqual(prod.dir, "/opt/ups_db/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/ups_db/Linux/fw/1.0/fw.table")

        prod = vf.makeProduct("Linux", "/opt", "/opt/eups_db")
        self.assertEqual(prod.dir, "/opt/eups_db/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/eups_db/Linux/fw/1.0/fw.table")

        # test integration of ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DB/Linux/fw/1.0", "fw.table", "ups")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEqual(prod.db, "/opt/ups_db")
        self.assertEqual(prod.dir, "/opt/ups_db/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/ups_db/Linux/fw/1.0/ups/fw.table")

        # test use in table path
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "/opt/Linux/fw/1.0",
                     "$UPS_DB/Linux/fw/1.0/fw.table", "ups")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEqual(prod.db, "/opt/ups_db")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/ups_db/Linux/fw/1.0/fw.table")

        # test use in ups_dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "Linux/fw/1.0",
                     "fw.table", "$UPS_DB/Linux/fw/1.0/UPS")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEqual(prod.db, "/opt/ups_db")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/ups_db/Linux/fw/1.0/UPS/fw.table")

        # test in combination with FLAVOR
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("LinuxARM", "$FLAVOR/fw/1.0", "fw.table",
                     "$UPS_DB/$FLAVOR/ups")
        prod = vf.makeProduct("LinuxARM", "/opt")
        self.assertEqual(prod.db, "/opt/ups_db")
        self.assertEqual(prod.dir, "/opt/LinuxARM/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/ups_db/LinuxARM/ups/fw.table")
コード例 #21
0
ファイル: testDb.py プロジェクト: airnandez/eups
    def testUPS_DIR(self):
        # test use in table path
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "/opt/Linux/fw/1.0", "$UPS_DIR/fw.table", "UPS")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEquals(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/Linux/fw/1.0/UPS/fw.table")

        # test no substitution
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DIR/Linux/fw/1.0", "fw.table")
        prod = vf.makeProduct("Linux")
        self.assertEquals(prod.dir, "$UPS_DIR/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "$UPS_DIR/Linux/fw/1.0/fw.table")

        # test use in product dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DIR/Linux/fw/1.0", "fw.table",
                     "$PROD_ROOT/ups")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEquals(prod.dir, "/opt/ups/Linux/fw/1.0")
        self.assertEquals(prod.tablefile, "/opt/ups/fw.table")
コード例 #22
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testUPS_DIR(self):
        # test use in table path
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "/opt/Linux/fw/1.0",
                     "$UPS_DIR/fw.table", "UPS")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEqual(prod.dir, "/opt/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/Linux/fw/1.0/UPS/fw.table")

        # test no substitution
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DIR/Linux/fw/1.0", "fw.table")
        prod = vf.makeProduct("Linux")
        self.assertEqual(prod.dir, "$UPS_DIR/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "$UPS_DIR/Linux/fw/1.0/fw.table")

        # test use in product dir
        vf = VersionFile(None, readFile=False)
        vf.addFlavor("Linux", "$UPS_DIR/Linux/fw/1.0", "fw.table",
                     "$PROD_ROOT/ups")
        prod = vf.makeProduct("Linux", "/opt")
        self.assertEqual(prod.dir, "/opt/ups/Linux/fw/1.0")
        self.assertEqual(prod.tablefile, "/opt/ups/fw.table")
コード例 #23
0
ファイル: testDb.py プロジェクト: RobertLuptonTheGood/eups
    def testPROD_DIRfile(self):
        vf = VersionFile(os.path.join(testEupsStack, "fw.version"))
        prod = vf.makeProduct("Darwin")

        self.assertEqual(prod.dir, "DarwinX86/fw/1.2")
        self.assertEqual(prod.tablefile, "DarwinX86/fw/1.2/ups/fw.table")
コード例 #24
0
ファイル: checkVersionFile.py プロジェクト: mwittgen/eups
class CheckVersionFileTestCase(unittest.TestCase):
    flavre = re.compile(r"^\s*FLAVOR\s*=\s*")
    qualre = re.compile(r"^\s*QUALIFIERS\s*=\s*")

    def __init__(self,
                 method=None,
                 file=defaultFile,
                 testExist=False,
                 prodroot=None):
        self.file = file
        self.testExist = testExist
        if not prodroot: prodroot = "/opt"
        self.prodroot = prodroot
        if method:
            unittest.TestCase.__init__(self, method)
        else:
            unittest.TestCase.__init__(self, 'testParsing')

    def setUp(self):
        self.vf = VersionFile(self.file)
        self.flavors = self._getFlavors(self.file)

    def tearDown(self):
        pass

    def _getFlavors(self, file):
        out = []
        fd = open(file)
        try:
            for line in fd:
                if self.flavre.match(line):
                    out.append(
                        self.flavre.sub("",
                                        line).strip().strip('"').strip("'"))
                elif self.qualre.match(line) and len(out) > 0:
                    line = self.qualre.sub("",
                                           line).strip().strip('"').strip("'")
                    if len(line) > 0:
                        out[-1] += ":%s" % line
            return out


#            return map(lambda g: g.strip(),
#                       map(lambda f: self.flavre.sub("", f),
#                           filter(lambda l: self.flavre.match(l), fd)))

        finally:
            fd.close()

    def testParsing(self):
        for flavor in self.flavors:
            sys.stderr.write('+')
            sys.stderr.flush()
            prod = self.vf.makeProduct(flavor, self.prodroot)
            self.assertPathOK(prod.dir, "prod.dir")
            self.assertPathOK(prod.db, "prod.db")
            self.assertPathOK(prod.tablefile, "prod.tablefile")

    def assertPathOK(self, path, what):
        self.assertResolvedMacros(path, what)
        self.assertAbs(path, what)
        if self.testExist:
            self.assertPathExists(path, what)

    def assertPathExists(self, path, what):
        self.assert_(os.path.exists(path),
                     "Path %s does not exist: %s" % (what, path))

    def assertResolvedMacros(self, path, what):
        self.assert_(
            path.find('$') < 0, "Unresolved macro in %s: %s" % (what, path))

    def assertAbs(self, path, what):
        self.assert_(path == "none" or os.path.isabs(path),
                     "Relative path in %s: %s" % (what, path))

    def shortDescription(self):
        return self.file