testing/mozbase/mozprofile/tests/bug785146.py

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/usr/bin/env python
michael@0 2
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
michael@0 5 # You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 import mozfile
michael@0 8 import os
michael@0 9 import shutil
michael@0 10 import sqlite3
michael@0 11 import tempfile
michael@0 12 import unittest
michael@0 13 from mozprofile.permissions import Permissions
michael@0 14
michael@0 15 class PermissionsTest(unittest.TestCase):
michael@0 16
michael@0 17 locations = """http://mochi.test:8888 primary,privileged
michael@0 18 http://127.0.0.1:80 noxul
michael@0 19 http://127.0.0.1:8888 privileged
michael@0 20 """
michael@0 21
michael@0 22 def setUp(self):
michael@0 23 self.profile_dir = tempfile.mkdtemp()
michael@0 24 self.locations_file = mozfile.NamedTemporaryFile()
michael@0 25 self.locations_file.write(self.locations)
michael@0 26 self.locations_file.flush()
michael@0 27
michael@0 28 def tearDown(self):
michael@0 29 if self.profile_dir:
michael@0 30 shutil.rmtree(self.profile_dir)
michael@0 31 if self.locations_file:
michael@0 32 self.locations_file.close()
michael@0 33
michael@0 34 def test_schema_version(self):
michael@0 35 perms = Permissions(self.profile_dir, self.locations_file.name)
michael@0 36 perms_db_filename = os.path.join(self.profile_dir, 'permissions.sqlite')
michael@0 37 perms.write_db(self.locations_file)
michael@0 38
michael@0 39 stmt = 'PRAGMA user_version;'
michael@0 40
michael@0 41 con = sqlite3.connect(perms_db_filename)
michael@0 42 cur = con.cursor()
michael@0 43 cur.execute(stmt)
michael@0 44 entries = cur.fetchall()
michael@0 45
michael@0 46 schema_version = entries[0][0]
michael@0 47 self.assertEqual(schema_version, 2)
michael@0 48
michael@0 49 if __name__ == '__main__':
michael@0 50 unittest.main()

mercurial