diff -r 000000000000 -r 6474c204b198 addon-sdk/source/python-lib/cuddlefish/tests/test_rdf.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/addon-sdk/source/python-lib/cuddlefish/tests/test_rdf.py Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,54 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. + +import unittest +import xml.dom.minidom +import os.path + +from cuddlefish import rdf, packaging + +parent = os.path.dirname +test_dir = parent(os.path.abspath(__file__)) +template_dir = os.path.join(parent(test_dir), "../../app-extension") + +class RDFTests(unittest.TestCase): + def testBug567660(self): + obj = rdf.RDF() + data = u'\u2026'.encode('utf-8') + x = '%s' % data + obj.dom = xml.dom.minidom.parseString(x) + self.assertEqual(obj.dom.documentElement.firstChild.nodeValue, + u'\u2026') + self.assertEqual(str(obj).replace("\n",""), x.replace("\n","")) + + def failUnlessIn(self, substring, s, msg=""): + if substring not in s: + self.fail("(%s) substring '%s' not in string '%s'" + % (msg, substring, s)) + + def testUnpack(self): + basedir = os.path.join(test_dir, "bug-715340-files") + for n in ["pkg-1-pack", "pkg-2-unpack", "pkg-3-pack"]: + cfg = packaging.get_config_in_dir(os.path.join(basedir, n)) + m = rdf.gen_manifest(template_dir, cfg, jid="JID") + if n.endswith("-pack"): + # these ones should remain packed + self.failUnlessEqual(m.get("em:unpack"), "false") + self.failUnlessIn("false", str(m), n) + else: + # and these should be unpacked + self.failUnlessEqual(m.get("em:unpack"), "true") + self.failUnlessIn("true", str(m), n) + + def testTitle(self): + basedir = os.path.join(test_dir, 'bug-906359-files') + for n in ['title', 'fullName', 'none']: + cfg = packaging.get_config_in_dir(os.path.join(basedir, n)) + m = rdf.gen_manifest(template_dir, cfg, jid='JID') + self.failUnlessEqual(m.get('em:name'), 'a long ' + n) + self.failUnlessIn('a long ' + n + '', str(m), n) + + +if __name__ == '__main__': + unittest.main()