Пример #1
0
def assert_catalog_deeply_contains_catalog(
    catalog: Catalog, other_catalog: Catalog, msg: str = ""
):
    """Assert that `other_catalog` contains all the messages of `catalog`, where message equality is deep.

    Ignores header message.
    """
    tc = unittest.TestCase()
    msg = f"{msg}: " if msg else ""
    tc.assertEqual(
        catalog.locale,
        other_catalog.locale,
        msg=f"{msg}The two catalogs have different locales",
    )
    for message in catalog:
        if message.id:  # ignore header
            other_message = find_corresponding_message(other_catalog, message)
            tc.assertTrue(
                other_message, msg=f"{msg}Message {message} not found in catalog"
            )
            assert_messages_deeply_equal(
                message,
                other_message,
                msg=f"{msg}The two catalogs have different properties in a message",
            )
Пример #2
0
 def test_find_corresponding_message_not_exists(self):
     catalog = Catalog()
     catalog.add("id", string="Text")
     corresponding = find_corresponding_message(catalog,
                                                Message("other id"))
     self.assertIsNone(corresponding)
     self.assertIsNone(
         find_corresponding_string(catalog, Message("other id")))
Пример #3
0
 def test_find_corresponding_message_exists(self):
     catalog = Catalog()
     catalog.add("id", string="Text")
     corresponding = find_corresponding_message(catalog, Message("id"))
     self.assertTrue(corresponding)
     assert_messages_deeply_equal(corresponding, catalog.get("id"))
     self.assertEqual(find_corresponding_string(catalog, Message("id")),
                      "Text")