def setUp(self): self.config = DummyConfig() self.config.target_platform = Platform.LINUX self.package = Package1(self.config, None, None) self.package_path = '/test/package.pkg' self.pkgref = PkgRef(self.package, PackageType.RUNTIME, self.package_path)
class PkgRefTest(unittest.TestCase, XMLMixin): def setUp(self): self.config = DummyConfig() self.config.target_platform = Platform.LINUX self.package = Package1(self.config, None, None) self.package_path = '/test/package.pkg' self.pkgref = PkgRef(self.package, PackageType.RUNTIME, self.package_path) def testAddRoot(self): self.pkgref._add_root() self.assertEqual(self.pkgref.root.tag, PkgRef.TAG_PKGREF) self.assertEqual(self.pkgref.root.attrib['spec'], PkgRef.SPEC_VERSION) self.assertEqual(self.pkgref.root.attrib['uuid'], self.package.uuid) self.assertEqual(len(self.pkgref.root.getchildren()), 0) def testAddScripts(self): self.pkgref._add_root() self.pkgref._add_scripts() scripts = self.find_one(self.pkgref.root, PkgRef.TAG_SCRIPTS) self.check_text(scripts, PkgRef.TAG_SCRIPTS_DIR, os.path.join(self.package_path, 'Contents', 'Resources')) def testAddExtra(self): self.pkgref._add_root() self.pkgref._add_extra() extra = self.find_one(self.pkgref.root, PkgRef.TAG_EXTRA) self.check_text(extra, PkgRef.TAG_PACKAGE_PATH, self.package_path) self.check_text(extra, PkgRef.TAG_TITLE, self.package.shortdesc) def testAddContents(self): self.pkgref._add_root() self.pkgref._add_contents() contents = self.find_one(self.pkgref.root, PkgRef.TAG_CONTENTS) self.check_text(contents, PkgRef.TAG_FILE_LIST, '%s-contents.xml' % self.package.name) def testAddConfig(self): self.pkgref._add_root() self.pkgref._add_config() config = self.find_one(self.pkgref.root, PkgRef.TAG_CONFIG) self.check_text(config, PkgRef.TAG_IDENTIFIER, self.package.identifier()) self.check_text(config, PkgRef.TAG_VERSION, self.package.version) self.check_text(config, PkgRef.TAG_DESCRIPTION, self.package.shortdesc) self.check_attrib(config, PkgRef.TAG_POST_INSTALL, 'type', 'none') self.check_attrib(config, PkgRef.TAG_INSTALL_TO, 'relative', 'true') self.check_attrib(config, PkgRef.TAG_INSTALL_TO, 'mod', 'true') self.check_text(config, PkgRef.TAG_INSTALL_TO, '.') self.find_one(config, PkgRef.TAG_REQ_AUTH) mods = ['installTo.isAbsoluteType', 'installTo.path', 'parent', 'installTo.isRelativeType', 'installTo', 'version', 'identifier'] docmods = [x.text for x in config.iterfind(PkgRef.TAG_MOD)] self.assertEqual(sorted(mods), sorted(docmods)) flags = self.find_one(config, PkgRef.TAG_FLAGS) self.find_one(flags, PkgRef.TAG_FOLLOW_SYMLINKS)
class PkgRefTest(unittest.TestCase, XMLMixin): def setUp(self): self.config = DummyConfig() self.config.target_platform = Platform.LINUX self.package = Package1(self.config, None, None) self.package_path = '/test/package.pkg' self.pkgref = PkgRef(self.package, PackageType.RUNTIME, self.package_path) def testAddRoot(self): self.pkgref._add_root() self.assertEquals(self.pkgref.root.tag, PkgRef.TAG_PKGREF) self.assertEquals(self.pkgref.root.attrib['spec'], PkgRef.SPEC_VERSION) self.assertEquals(self.pkgref.root.attrib['uuid'], self.package.uuid) self.assertEquals(len(self.pkgref.root.getchildren()), 0) def testAddScripts(self): self.pkgref._add_root() self.pkgref._add_scripts() scripts = self.find_one(self.pkgref.root, PkgRef.TAG_SCRIPTS) self.check_text( scripts, PkgRef.TAG_SCRIPTS_DIR, os.path.join(self.package_path, 'Contents', 'Resources')) def testAddExtra(self): self.pkgref._add_root() self.pkgref._add_extra() extra = self.find_one(self.pkgref.root, PkgRef.TAG_EXTRA) self.check_text(extra, PkgRef.TAG_PACKAGE_PATH, self.package_path) self.check_text(extra, PkgRef.TAG_TITLE, self.package.shortdesc) def testAddContents(self): self.pkgref._add_root() self.pkgref._add_contents() contents = self.find_one(self.pkgref.root, PkgRef.TAG_CONTENTS) self.check_text(contents, PkgRef.TAG_FILE_LIST, '%s-contents.xml' % self.package.name) def testAddConfig(self): self.pkgref._add_root() self.pkgref._add_config() config = self.find_one(self.pkgref.root, PkgRef.TAG_CONFIG) self.check_text(config, PkgRef.TAG_IDENTIFIER, self.package.identifier()) self.check_text(config, PkgRef.TAG_VERSION, self.package.version) self.check_text(config, PkgRef.TAG_DESCRIPTION, self.package.shortdesc) self.check_attrib(config, PkgRef.TAG_POST_INSTALL, 'type', 'none') self.check_attrib(config, PkgRef.TAG_INSTALL_TO, 'relative', 'true') self.check_attrib(config, PkgRef.TAG_INSTALL_TO, 'mod', 'true') self.check_text(config, PkgRef.TAG_INSTALL_TO, '.') self.find_one(config, PkgRef.TAG_REQ_AUTH) mods = [ 'installTo.isAbsoluteType', 'installTo.path', 'parent', 'installTo.isRelativeType', 'installTo', 'version', 'identifier' ] docmods = [x.text for x in config.iterfind(PkgRef.TAG_MOD)] self.assertEquals(sorted(mods), sorted(docmods)) flags = self.find_one(config, PkgRef.TAG_FLAGS) self.find_one(flags, PkgRef.TAG_FOLLOW_SYMLINKS)