bug 1388313, add first phase of tests for ContentComparer.compare
MozReview-Commit-ID: J8gcSTaD3X
--- a/compare_locales/tests/test_compare.py
+++ b/compare_locales/tests/test_compare.py
@@ -258,8 +258,38 @@ class TestAddRemove(unittest.TestCase):
def test_replace_end(self):
self._test(['z', 'a', 'b'], ['z', 'a', 'p'], [
('equal', 'z'),
('equal', 'a'),
('add', 'p'),
('delete', 'b'),
])
+
+
+class MockFile(paths.File):
+ def __init__(self, locale, fullpath, byte_content):
+ super(MockFile, self).__init__(fullpath, fullpath, locale=locale)
+ self.byte_content = byte_content
+
+ def getContents(self):
+ return self.byte_content
+
+
+class TestComparer(unittest.TestCase):
+ def setUp(self):
+ self.obs = compare.Observer()
+ self.cc = compare.ContentComparer([self.obs])
+
+ def test_simple(self):
+ ref = MockFile('en-US', 'en-US/file.properties', b'''\
+one = English
+''')
+ l10n = MockFile('de', 'de/file.properties', b'''\
+one = Deutsch
+''')
+ self.cc.compare(ref, l10n, None)
+ self.assertDictEqual(self.obs.toJSON(), {
+ 'details': {},
+ 'summary': {
+ 'de': {
+ 'changed': 1,
+ 'changed_w': 1}}})