def setUp(self): self.config = DummyConfig() self.store = create_store(self.config) self.package = self.store.get_package('gstreamer-runtime') self.outdir = '/test' self.index = Index(self.package, self.store, self.outdir, [], PackageType.RUNTIME, False)
class IndexTest(unittest.TestCase, XMLMixin): def setUp(self): self.config = DummyConfig() self.store = create_store(self.config) self.package = self.store.get_package('gstreamer-runtime') self.outdir = '/test' self.index = Index(self.package, self.store, self.outdir, [], PackageType.RUNTIME, False) def testAddRoot(self): self.index._add_root() self.assertEqual(self.index.root.tag, Index.DOCUMENT_TAG) self.assertEqual(self.index.root.attrib['spec'], Index.SPEC_VERSION) self.assertEqual(len(self.index.root.getchildren()), 0) def testAddProperties(self): self.index._add_root() self.index._add_properties() children = self.index.root.getchildren() self.assertEqual(len(children), 1) properties = children[0] self.assertEqual(len(properties.getchildren()), 6) self.check_text(properties, Index.TAG_ORGANIZATION, self.package.org) self.check_text(properties, Index.TAG_TITLE, self.package.title) self.check_text(properties, Index.TAG_BUILD, os.path.join(self.outdir, '%s.pkg' % self.package.name)) self.check_attrib(properties, Index.TAG_USER_SEES, 'ui', Index.PROP_USER_SEES) self.check_attrib(properties, Index.TAG_MIN_TARGET, 'os', Index.PROP_MIN_TARGET) self.check_attrib(properties, Index.TAG_DOMAIN, 'system', Index.PROP_DOMAIN) def testAddDistribution(self): self.index._add_root() self.index._add_distribution() children = self.index.root.getchildren() self.assertEqual(len(children), 1) dist =children[0] self.find_one(dist, Index.TAG_SCRIPTS) self.check_attrib(dist, Index.TAG_VERSION, Index.ATTR_MIN_SPEC, Index.MIN_SPEC) def testAddDescription(self): self.index._add_root() self.index._add_description() self.check_text(self.index.root, Index.TAG_DESCRIPTION, self.package.shortdesc) def testAddFlags(self): self.index._add_root() self.index._add_flags() self.find_one(self.index.root, Index.TAG_FLAGS) def testAddContents(self): self.index._add_root() self.index._add_contents() children = self.index.root.getchildren() # 1 choice + 4 item self.assertEqual(len(children), 5) contents = self.find_one(self.index.root, Index.TAG_CONTENTS) packages =[] for choice in contents.iterfind(Index.TAG_CHOICE): if choice.attrib['id'] == 'gstreamer-test1': # Should have 2 package ref because it has a dependency in # gstreamer-test2 pkrefs = ['gstreamer-test1', 'gstreamer-test2'] elif choice.attrib['id'] == 'gstreamer-test3': pkrefs = ['gstreamer-test3'] elif choice.attrib['id'] == 'gstreamer-test-bindings': pkrefs = ['gstreamer-test-bindings'] else: self.fail("Incorrect choice %s" % choice) elpkrefs = [x.attrib['id'] for x in \ choice.iterfind(Index.TAG_PKGREF)] self.assertEqual(sorted(["default.%s.%s" % (self.config.target_arch, x) for x in pkrefs]), sorted(elpkrefs)) packages.extend(pkrefs) items = [x.text[:-4] for x in self.index.root.iterfind(Index.TAG_ITEM) if x.attrib['type']=='pkgref'] self.assertEqual(sorted(packages), sorted(items))
class IndexTest(unittest.TestCase, XMLMixin): def setUp(self): self.config = DummyConfig() self.store = create_store(self.config) self.package = self.store.get_package('gstreamer-runtime') self.outdir = '/test' self.index = Index(self.package, self.store, self.outdir, [], PackageType.RUNTIME, False) def testAddRoot(self): self.index._add_root() self.assertEquals(self.index.root.tag, Index.DOCUMENT_TAG) self.assertEquals(self.index.root.attrib['spec'], Index.SPEC_VERSION) self.assertEquals(len(self.index.root.getchildren()), 0) def testAddProperties(self): self.index._add_root() self.index._add_properties() children = self.index.root.getchildren() self.assertEquals(len(children), 1) properties = children[0] self.assertEquals(len(properties.getchildren()), 6) self.check_text(properties, Index.TAG_ORGANIZATION, self.package.org) self.check_text(properties, Index.TAG_TITLE, self.package.title) self.check_text( properties, Index.TAG_BUILD, os.path.join(self.outdir, '%s.pkg' % self.package.name)) self.check_attrib(properties, Index.TAG_USER_SEES, 'ui', Index.PROP_USER_SEES) self.check_attrib(properties, Index.TAG_MIN_TARGET, 'os', Index.PROP_MIN_TARGET) self.check_attrib(properties, Index.TAG_DOMAIN, 'system', Index.PROP_DOMAIN) def testAddDistribution(self): self.index._add_root() self.index._add_distribution() children = self.index.root.getchildren() self.assertEquals(len(children), 1) dist = children[0] self.find_one(dist, Index.TAG_SCRIPTS) self.check_attrib(dist, Index.TAG_VERSION, Index.ATTR_MIN_SPEC, Index.MIN_SPEC) def testAddDescription(self): self.index._add_root() self.index._add_description() self.check_text(self.index.root, Index.TAG_DESCRIPTION, self.package.shortdesc) def testAddFlags(self): self.index._add_root() self.index._add_flags() self.find_one(self.index.root, Index.TAG_FLAGS) def testAddContents(self): self.index._add_root() self.index._add_contents() children = self.index.root.getchildren() # 1 choice + 4 item self.assertEquals(len(children), 5) contents = self.find_one(self.index.root, Index.TAG_CONTENTS) packages = [] for choice in contents.iterfind(Index.TAG_CHOICE): if choice.attrib['id'] == 'gstreamer-test1': # Should have 2 package ref because it has a dependency in # gstreamer-test2 pkrefs = ['gstreamer-test1', 'gstreamer-test2'] elif choice.attrib['id'] == 'gstreamer-test3': pkrefs = ['gstreamer-test3'] elif choice.attrib['id'] == 'gstreamer-test-bindings': pkrefs = ['gstreamer-test-bindings'] else: self.fail("Incorrect choice %s" % choice) elpkrefs = [x.attrib['id'] for x in \ choice.iterfind(Index.TAG_PKGREF)] self.assertEquals( sorted([ "default.%s.%s" % (self.config.target_arch, x) for x in pkrefs ]), sorted(elpkrefs)) packages.extend(pkrefs) items = [ x.text[:-4] for x in self.index.root.iterfind(Index.TAG_ITEM) if x.attrib['type'] == 'pkgref' ] self.assertEquals(sorted(packages), sorted(items))