Пример #1
0
    def testExport(self):
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1")
        self.fam.addVersion("3.2", "/opt/LInux/magnum/3.2")
        self.fam.assignTag("stable", "3.1")
        self.fam.assignTag("beta", "3.2")
        self.fam.assignTag("current", "3.1")

        prods = self.fam.export(flavor="Linux")
        self.assertEquals(len(prods.keys()), 2)
        p = prods["3.1"]
        self.assertEquals(p.name, "magnum")
        self.assertEquals(p.flavor, "Linux")
        self.assert_(p.db is None)
        self.assertEquals(len(p.tags), 2)
        self.assert_("current" in p.tags)
        p.name = "helpful"

        fam = ProductFamily("helpful")
        fam.import_(prods)
        self.assertEquals(len(fam.getVersions()), 1)
        self.assert_(fam.hasVersion("3.1"))
Пример #2
0
 def setUp(self):
     self.fam = ProductFamily("magnum")
Пример #3
0
class ProductFamilyTestCase(unittest.TestCase):

    def setUp(self):
        self.fam = ProductFamily("magnum")

    def testNotFound(self):
        self.assertRaises(ProductNotFound, self.fam.getProduct, "4.0")

    def testAddVersion(self):
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1")
        self.assertEquals(len(self.fam.getVersions()), 1)
        self.assert_(not self.fam.hasVersion("1.0"))
        self.assert_(self.fam.hasVersion("3.1"))
        self.fam.addVersion("3.2", "/opt/LInux/magnum/3.2")
        self.assertEquals(len(self.fam.getVersions()), 2)
        self.assert_(self.fam.hasVersion("3.1"))
        self.assert_(not self.fam.removeVersion("1.0"))
        self.assert_(self.fam.removeVersion("3.1"))
        self.assert_(not self.fam.hasVersion("3.1"))
        self.assert_(self.fam.removeVersion("3.2"))

    def testGetProduct(self):
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1")
        p = self.fam.getProduct("3.1")
        self.assertEqual(p.name, "magnum")
        self.assertEqual(p.version, "3.1")
        self.assertEqual(p.dir, "/opt/LInux/magnum/3.1")

    def testAssignTag(self):
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1")
        self.fam.addVersion("3.2", "/opt/LInux/magnum/3.2")
        self.assertEquals(len(self.fam.getTags()), 0)
        tag = "stable"
        self.assert_(not self.fam.isTagAssigned(tag))
        self.fam.assignTag(tag, "3.1")
        self.assertEquals(len(self.fam.getTags()), 1)
        self.assert_(self.fam.isTagAssigned(tag))
        self.fam.assignTag("beta", "3.2")
        self.fam.assignTag("current", "3.1")
        self.assertEquals(len(self.fam.getTags()), 3)
        self.assert_(self.fam.isTagAssigned("beta"))
        self.assert_(self.fam.isTagAssigned("current"))
        p = self.fam.getProduct("3.1")
        self.assertEquals(len(p.tags), 2)
        self.assert_(tag in p.tags)
        self.assert_("current" in p.tags)
        p = self.fam.getTaggedProduct("beta")
        self.assertEquals(p.version, "3.2")
        self.assertEquals(len(p.tags), 1)
        self.assert_("beta" in p.tags)
        p = self.fam.getTaggedProduct(tag)
        self.assertEquals(p.version, "3.1")
        self.assertEquals(len(p.tags), 2)
        self.assert_(tag in p.tags)
        self.assert_("current" in p.tags)

        self.assert_(not self.fam.unassignTag("gurn"))
        self.assert_(self.fam.unassignTag("beta"))
        self.assert_(not self.fam.isTagAssigned("beta"))
        self.assert_(self.fam.isTagAssigned("current"))

    def testExport(self):
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1")
        self.fam.addVersion("3.2", "/opt/LInux/magnum/3.2")
        self.fam.assignTag("stable", "3.1")
        self.fam.assignTag("beta", "3.2")
        self.fam.assignTag("current", "3.1")

        prods = self.fam.export(flavor="Linux")
        self.assertEquals(len(prods.keys()), 2)
        p = prods["3.1"]
        self.assertEquals(p.name, "magnum")
        self.assertEquals(p.flavor, "Linux")
        self.assert_(p.db is None)
        self.assertEquals(len(p.tags), 2)
        self.assert_("current" in p.tags)
        p.name = "helpful"

        fam = ProductFamily("helpful")
        fam.import_(prods)
        self.assertEquals(len(fam.getVersions()), 1)
        self.assert_(fam.hasVersion("3.1"))

    def testLoadTable(self):
        tablefile = os.path.join(testEupsStack,"mwi.table")
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1", tablefile)
        prod = self.fam.getProduct("3.1")
        self.assert_(prod.tablefile is not None)
        self.assert_(os.path.exists(prod.tablefile))
        self.assert_(prod._table is None)
        self.fam.loadTableFor("3.1")
        prod = self.fam.getProduct("3.1")
        self.assert_(prod._table is not None)

    def testLoadTables(self):
        tablefile = os.path.join(testEupsStack,"mwi.table")
        self.fam.addVersion("3.1", "/opt/LInux/magnum/3.1", tablefile)
        prod = self.fam.getProduct("3.1")
        self.assert_(prod.tablefile is not None)
        self.assert_(os.path.exists(prod.tablefile))
        self.assert_(prod._table is None)
        self.fam.loadTableFor("3.1")

        self.fam.loadTables()
        prod = self.fam.getProduct("3.1")
        self.assert_(prod._table is not None)