testing/mozbase/mozprofile/tests/bug758250.py

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/mozbase/mozprofile/tests/bug758250.py	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     1.4 +#!/usr/bin/env python
     1.5 +
     1.6 +import mozprofile
     1.7 +import os
     1.8 +import shutil
     1.9 +import tempfile
    1.10 +import unittest
    1.11 +
    1.12 +
    1.13 +here = os.path.dirname(os.path.abspath(__file__))
    1.14 +
    1.15 +
    1.16 +class Bug758250(unittest.TestCase):
    1.17 +    """
    1.18 +    use of --profile in mozrunner just blows away addon sources:
    1.19 +    https://bugzilla.mozilla.org/show_bug.cgi?id=758250
    1.20 +    """
    1.21 +
    1.22 +    def setUp(self):
    1.23 +        self.tmpdir = tempfile.mkdtemp()
    1.24 +        self.addon = os.path.join(here, 'addons', 'empty')
    1.25 +
    1.26 +    def tearDown(self):
    1.27 +        # remove vestiges
    1.28 +        shutil.rmtree(self.tmpdir)
    1.29 +
    1.30 +    def test_profile_addon_cleanup(self):
    1.31 +
    1.32 +        # sanity check: the empty addon should be here
    1.33 +        self.assertTrue(os.path.exists(self.addon))
    1.34 +        self.assertTrue(os.path.isdir(self.addon))
    1.35 +        self.assertTrue(os.path.exists(os.path.join(self.addon, 'install.rdf')))
    1.36 +
    1.37 +        # because we are testing data loss, let's make sure we make a copy
    1.38 +        shutil.rmtree(self.tmpdir)
    1.39 +        shutil.copytree(self.addon, self.tmpdir)
    1.40 +        self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'install.rdf')))
    1.41 +
    1.42 +        # make a starter profile
    1.43 +        profile = mozprofile.FirefoxProfile()
    1.44 +        path = profile.profile
    1.45 +
    1.46 +        # make a new profile based on the old
    1.47 +        newprofile = mozprofile.FirefoxProfile(profile=path, addons=[self.tmpdir])
    1.48 +        newprofile.cleanup()
    1.49 +
    1.50 +        # the source addon *should* still exist
    1.51 +        self.assertTrue(os.path.exists(self.tmpdir))
    1.52 +        self.assertTrue(os.path.exists(os.path.join(self.tmpdir, 'install.rdf')))
    1.53 +
    1.54 +
    1.55 +if __name__ == '__main__':
    1.56 +    unittest.main()

mercurial