def test_profile_diff(self):
        profile1 = mozprofile.Profile()
        profile2 = mozprofile.Profile(preferences=dict(foo='bar'))

        # diff a profile against itself; no difference
        self.assertEqual([], mozprofile.diff(profile1, profile1))

        # diff two profiles
        diff = dict(mozprofile.diff(profile1, profile2))
        self.assertEqual(diff.keys(), ['user.js'])
        lines = [line.strip() for line in diff['user.js'].splitlines()]
        self.assertTrue('+foo: bar' in lines)

        # diff a blank vs FirefoxProfile
        ff_profile = mozprofile.FirefoxProfile()
        diff = dict(mozprofile.diff(profile2, ff_profile))
        self.assertEqual(diff.keys(), ['user.js'])
        lines = [line.strip() for line in diff['user.js'].splitlines()]
        self.assertTrue('-foo: bar' in lines)
        ff_pref_lines = ['+%s: %s' % (key, value)
                         for key, value in mozprofile.FirefoxProfile.preferences.items()]
        self.assertTrue(set(ff_pref_lines).issubset(lines))
    def test_profile_diff(self):
        profile1 = mozprofile.Profile()
        profile2 = mozprofile.Profile(preferences=dict(foo='bar'))

        # diff a profile against itself; no difference
        self.assertEqual([], mozprofile.diff(profile1, profile1))

        # diff two profiles
        diff = dict(mozprofile.diff(profile1, profile2))
        self.assertEqual(diff.keys(), ['user.js'])
        lines = [line.strip() for line in diff['user.js'].splitlines()]
        self.assertTrue('+foo: bar' in lines)

        # diff a blank vs FirefoxProfile
        ff_profile = mozprofile.FirefoxProfile()
        diff = dict(mozprofile.diff(profile2, ff_profile))
        self.assertEqual(diff.keys(), ['user.js'])
        lines = [line.strip() for line in diff['user.js'].splitlines()]
        self.assertTrue('-foo: bar' in lines)
        ff_pref_lines = ['+%s: %s' % (key, value)
                         for key, value in mozprofile.FirefoxProfile.preferences.items()]
        self.assertTrue(set(ff_pref_lines).issubset(lines))
Exemple #3
0
def test_profile_diff():
    profile1 = mozprofile.Profile()
    profile2 = mozprofile.Profile(preferences=dict(foo='bar'))

    # diff a profile against itself; no difference
    assert mozprofile.diff(profile1, profile1) == []

    # diff two profiles
    diff = dict(mozprofile.diff(profile1, profile2))
    assert list(diff.keys()) == ['user.js']
    lines = [line.strip() for line in diff['user.js'].splitlines()]
    assert '+foo: bar' in lines

    # diff a blank vs FirefoxProfile
    ff_profile = mozprofile.FirefoxProfile()
    diff = dict(mozprofile.diff(profile2, ff_profile))
    assert list(diff.keys()) == ['user.js']
    lines = [line.strip() for line in diff['user.js'].splitlines()]
    assert '-foo: bar' in lines
    ff_pref_lines = ['+%s: %s' % (key, value)
                     for key, value in mozprofile.FirefoxProfile.preferences.items()]
    assert set(ff_pref_lines).issubset(lines)