示例#1
0
    def test_import_export(self):
        c1 = mngr.SubComponent(componentid='cid01', name='namec01')
        p1 = mngr.Package(packageid='pid01',
                          name='namep01',
                          depends=mngr.Dependencies(),
                          components=[c1])

        c2 = mngr.SubComponent(componentid='cid02', name='namec02')
        c3 = mngr.SubComponent(componentid='cid03', name='namec03')
        c4 = mngr.SubComponent(componentid='cid04',
                               name='namec04',
                               subcomponents=[c2, c3])
        c5 = mngr.SubComponent(componentid='cid05', name='namec05')
        c6 = mngr.SubComponent(componentid='cid06',
                               name='namec06',
                               subcomponents=[c5])

        p2 = mngr.Package(packageid="pid02",
                          name="namep02",
                          depends=mngr.Dependencies(),
                          components=[c4, c6])

        pkgdict = {p1.id: p1, p2.id: p2}
        mngr.Package.save_to_json({p1.id: p1, p2.id: p2}, 'test.json')
        pkgdictexp = mngr.Package.load_from_json('test.json')
        self.assertEqual(
            {pkg.id: pkg.to_dict()
             for pkg in pkgdict.values()},
            {pkg.id: pkg.to_dict()
             for pkg in pkgdictexp.values()})
示例#2
0
    def setUp(self):
        self.c1 = mngr.SubComponent(componentid="cid01", name='namec01')
        self.c2 = mngr.SubComponent(componentid="cid02", name='namec02')

        self.p1 = mngr.Package(packageid='pid01',
                               name='namep01',
                               depends=mngr.Dependencies(),
                               components=[self.c1])
        self.p2 = mngr.Package(packageid='pid02',
                               name='namep02',
                               depends=mngr.Dependencies(),
                               components=[self.c2])

        self.c3 = mngr.SubComponent(componentid='cid03', name='namec03')
        self.c4 = mngr.SubComponent(componentid='cid04',
                                    name='namec04',
                                    subcomponents=[self.c3])
        self.c5 = mngr.SubComponent(componentid='cid05',
                                    name='namec05',
                                    subcomponents=[self.c4])

        self.p3 = mngr.Package(packageid='pid03',
                               name='namep03',
                               depends=mngr.Dependencies(),
                               components=[self.c5])
示例#3
0
 def testUnion(self):
     d1 = mngr.Dependencies(requirements=['p01.c01'],
                            conflicts=['p02.c02'],
                            before=[],
                            after=['p01.c01'])
     d2 = mngr.Dependencies(requirements=['p02.c01'],
                            conflicts=['p02.c02'],
                            before=['p02.c01'],
                            after=[])
     d3 = d1.union(d2)
     self.assertEqual(
         (d3.requirements, d3.conflicts, d3.before, d3.after),
         ({'p01.c01', 'p02.c01'}, {'p02.c02'}, {'p02.c01'}, {'p01.c01'}))
示例#4
0
 def test_non_unique_id(self):
     m = mngr.Manager()
     m.add_pkg(self.p1)
     c = mngr.SubComponent(componentid="cid", name="namec")
     p = mngr.Package(packageid='pid01',
                      name='namep',
                      depends=mngr.Dependencies(),
                      components=[c])
     with self.assertRaises(mngr.NonUniqueIDException):
         m.add_pkg(p)