addon-sdk/source/python-lib/cuddlefish/tests/test_rdf.py

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     1 # This Source Code Form is subject to the terms of the Mozilla Public
     2 # License, v. 2.0. If a copy of the MPL was not distributed with this
     3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
     5 import unittest
     6 import xml.dom.minidom
     7 import os.path
     9 from cuddlefish import rdf, packaging
    11 parent = os.path.dirname
    12 test_dir = parent(os.path.abspath(__file__))
    13 template_dir = os.path.join(parent(test_dir), "../../app-extension")
    15 class RDFTests(unittest.TestCase):
    16     def testBug567660(self):
    17         obj = rdf.RDF()
    18         data = u'\u2026'.encode('utf-8')
    19         x = '<?xml version="1.0" encoding="utf-8"?><blah>%s</blah>' % data
    20         obj.dom = xml.dom.minidom.parseString(x)
    21         self.assertEqual(obj.dom.documentElement.firstChild.nodeValue,
    22                          u'\u2026')
    23         self.assertEqual(str(obj).replace("\n",""), x.replace("\n",""))
    25     def failUnlessIn(self, substring, s, msg=""):
    26         if substring not in s:
    27             self.fail("(%s) substring '%s' not in string '%s'"
    28                       % (msg, substring, s))
    30     def testUnpack(self):
    31         basedir = os.path.join(test_dir, "bug-715340-files")
    32         for n in ["pkg-1-pack", "pkg-2-unpack", "pkg-3-pack"]:
    33             cfg = packaging.get_config_in_dir(os.path.join(basedir, n))
    34             m = rdf.gen_manifest(template_dir, cfg, jid="JID")
    35             if n.endswith("-pack"):
    36                 # these ones should remain packed
    37                 self.failUnlessEqual(m.get("em:unpack"), "false")
    38                 self.failUnlessIn("<em:unpack>false</em:unpack>", str(m), n)
    39             else:
    40                 # and these should be unpacked
    41                 self.failUnlessEqual(m.get("em:unpack"), "true")
    42                 self.failUnlessIn("<em:unpack>true</em:unpack>", str(m), n)
    44     def testTitle(self):
    45         basedir = os.path.join(test_dir, 'bug-906359-files')
    46         for n in ['title', 'fullName', 'none']:
    47             cfg = packaging.get_config_in_dir(os.path.join(basedir, n))
    48             m = rdf.gen_manifest(template_dir, cfg, jid='JID')
    49             self.failUnlessEqual(m.get('em:name'), 'a long ' + n)
    50             self.failUnlessIn('<em:name>a long ' + n + '</em:name>', str(m), n)
    53 if __name__ == '__main__':
    54     unittest.main()

mercurial