Example #1
0
    def test_merge_source_catalog_parse_python_special_comments(self):
        js_catalog = Catalog("en")
        python_catalog = Catalog("en")
        python_catalog.add(
            "id1",
            locations=[("file1", "1")],
            auto_comments=["default-message: Text1", "some comment"],
        )
        old_source_catalog = Catalog("en")

        new_js_catalog, new_python_catalog, fuzzy = _merge_source_catalog(
            js_catalog, python_catalog, old_source_catalog
        )

        expected_python_catalog = Catalog("en")
        expected_python_catalog.add(
            "id1",
            string="Text1",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )
        expected_js_catalog = Catalog("en")
        expected_js_catalog.add(
            "id1",
            string="Text1",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )
        assert_catalogs_deeply_equal(new_js_catalog, expected_js_catalog)
        assert_catalogs_deeply_equal(new_python_catalog, expected_python_catalog)
        self.assertEqual(fuzzy, frozenset())
Example #2
0
    def test_merge_source_catalog_fuzzy_in_js(self):
        js_catalog = Catalog("en")
        js_catalog.add(
            "id1",
            string="Text1",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )
        python_catalog = Catalog("en")
        old_source_catalog = Catalog("en")
        old_source_catalog.add(
            "id1",
            string="Text0",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )

        new_js_catalog, new_python_catalog, fuzzy = _merge_source_catalog(
            js_catalog, python_catalog, old_source_catalog
        )

        expected_python_catalog = Catalog("en")
        expected_js_catalog = Catalog("en")
        expected_js_catalog.add(
            "id1",
            string="Text1",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )
        assert_catalogs_deeply_equal(new_js_catalog, expected_js_catalog)
        assert_catalogs_deeply_equal(new_python_catalog, expected_python_catalog)
        self.assertEqual(fuzzy, frozenset(["id1"]))
Example #3
0
    def test_merge_source_catalog_update_existing_old(self):
        js_catalog = Catalog("en")
        js_catalog.add(
            "id0",
            string="Text0",
            locations=[("file0", "2")],
            auto_comments=["some js comment"],
        )
        python_catalog = Catalog("en")
        python_catalog.add(
            "id1",
            locations=[("file1", "1")],
            auto_comments=["default-message: Text1", "some comment"],
        )
        old_source_catalog = Catalog("en")
        old_source_catalog.add(
            "id0",
            string="Text0",
            locations=[("file0", "3")],
            auto_comments=["some js comment"],
        )
        old_source_catalog.add(
            "id1",
            string="Text1",
            locations=[("file0", "2")],
            auto_comments=["some old comment"],
        )

        new_js_catalog, new_python_catalog, fuzzy = _merge_source_catalog(
            js_catalog, python_catalog, old_source_catalog
        )

        expected_python_catalog = Catalog("en")
        expected_python_catalog.add(
            "id1",
            string="Text1",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )
        expected_js_catalog = Catalog("en")
        expected_js_catalog.add(
            "id0",
            string="Text0",
            locations=[("file0", "2")],
            auto_comments=["some js comment"],
        )
        expected_js_catalog.add(
            "id1",
            string="Text1",
            locations=[("file1", "1")],
            auto_comments=["some comment"],
        )
        assert_catalogs_deeply_equal(new_js_catalog, expected_js_catalog)
        assert_catalogs_deeply_equal(new_python_catalog, expected_python_catalog)
        self.assertEqual(fuzzy, frozenset())