testing/mozbase/mozprofile/tests/test_clone_cleanup.py

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:b19d0c7f3c18
1 #!/usr/bin/env python
2
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this file,
5 # You can obtain one at http://mozilla.org/MPL/2.0/.
6
7
8 import os
9 import tempfile
10 import unittest
11
12 from mozprofile.profile import Profile
13
14
15 class CloneCleanupTest(unittest.TestCase):
16 """
17 test cleanup logic for the clone functionality
18 see https://bugzilla.mozilla.org/show_bug.cgi?id=642843
19 """
20
21 def setUp(self):
22 # make a profile with one preference
23 path = tempfile.mktemp()
24 self.profile = Profile(path,
25 preferences={'foo': 'bar'},
26 restore=False)
27 user_js = os.path.join(self.profile.profile, 'user.js')
28 self.assertTrue(os.path.exists(user_js))
29
30 def test_restore_true(self):
31 # make a clone of this profile with restore=True
32 clone = Profile.clone(self.profile.profile, restore=True)
33
34 clone.cleanup()
35
36 # clone should be deleted
37 self.assertFalse(os.path.exists(clone.profile))
38
39 def test_restore_false(self):
40 # make a clone of this profile with restore=False
41 clone = Profile.clone(self.profile.profile, restore=False)
42
43 clone.cleanup()
44
45 # clone should still be around on the filesystem
46 self.assertTrue(os.path.exists(clone.profile))
47
48
49 if __name__ == '__main__':
50 unittest.main()
51

mercurial