Exemplo n.º 1
0
    def test_reset_should_keep_user_added_prefs(self):
        """Check that when we call reset the items we expect are updated"""
        profile = Profile()
        prefs_file = os.path.join(profile.profile, 'user.js')

        # we shouldn't have any initial preferences
        initial_prefs = Preferences.read_prefs(prefs_file)
        self.assertFalse(initial_prefs)
        initial_prefs = file(prefs_file).read().strip()
        self.assertFalse(initial_prefs)

        # add some preferences
        prefs1 = [("mr.t.quotes", "i aint getting on no plane!")]
        profile.set_persistent_preferences(prefs1)
        self.assertEqual(prefs1, Preferences.read_prefs(prefs_file))
        lines = file(prefs_file).read().strip().splitlines()
        self.assertTrue(
            any(line.startswith('#MozRunner Prefs Start') for line in lines))
        self.assertTrue(
            any(line.startswith('#MozRunner Prefs End') for line in lines))

        profile.reset()
        self.assertEqual(
            prefs1,
            Preferences.read_prefs(os.path.join(profile.profile, 'user.js')),
            "I pity the fool who left my pref")
Exemplo n.º 2
0
def test_reset_should_keep_user_added_prefs():
    """Check that when we call reset the items we expect are updated"""
    profile = Profile()
    prefs_file = os.path.join(profile.profile, 'user.js')

    # we shouldn't have any initial preferences
    initial_prefs = Preferences.read_prefs(prefs_file)
    assert not initial_prefs
    initial_prefs = open(prefs_file).read().strip()
    assert not initial_prefs

    # add some preferences
    prefs1 = [("mr.t.quotes", "i aint getting on no plane!")]
    profile.set_persistent_preferences(prefs1)
    assert prefs1 == Preferences.read_prefs(prefs_file)
    lines = open(prefs_file).read().strip().splitlines()
    assert any(line.startswith('#MozRunner Prefs Start') for line in lines)
    assert any(line.startswith('#MozRunner Prefs End') for line in lines)

    profile.reset()
    assert prefs1 == Preferences.read_prefs(os.path.join(profile.profile, 'user.js'))
Exemplo n.º 3
0
    def test_reset_should_keep_user_added_prefs(self):
        """Check that when we call reset the items we expect are updated"""
        profile = Profile()
        prefs_file = os.path.join(profile.profile, 'user.js')

        # we shouldn't have any initial preferences
        initial_prefs = Preferences.read_prefs(prefs_file)
        self.assertFalse(initial_prefs)
        initial_prefs = file(prefs_file).read().strip()
        self.assertFalse(initial_prefs)

        # add some preferences
        prefs1 = [("mr.t.quotes", "i aint getting on no plane!")]
        profile.set_persistent_preferences(prefs1)
        self.assertEqual(prefs1, Preferences.read_prefs(prefs_file))
        lines = file(prefs_file).read().strip().splitlines()
        self.assertTrue(any(line.startswith('#MozRunner Prefs Start') for line in lines))
        self.assertTrue(any(line.startswith('#MozRunner Prefs End') for line in lines))

        profile.reset()
        self.assertEqual(prefs1,
                         Preferences.read_prefs(os.path.join(profile.profile, 'user.js')),
                         "I pity the fool who left my pref")