bug 1388313, add first phase of tests for ContentComparer.compare draft
authorAxel Hecht <axel@pike.org>
Thu, 17 Aug 2017 14:39:27 +0200
changeset 308 02a53a7e637730ff4aa5fd55bdc610c3de573b6c
parent 307 0834aba59219411d32fe369b10f2508c50835ec7
push id91
push useraxel@mozilla.com
push dateThu, 17 Aug 2017 12:49:00 +0000
bugs1388313
bug 1388313, add first phase of tests for ContentComparer.compare MozReview-Commit-ID: J8gcSTaD3X
compare_locales/tests/test_compare.py
--- 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}}})