Ejemplo n.º 1
0

class TypeTranslationContextManager(TranslationContextManager):
    """ TranslationContextManager for Kaiso types """

    context = TYPE_CONTEXT

    def __init__(self, manager, **kwargs):
        self.manager = manager

    def list_message_ids(self):
        manager = self.manager
        type_hierarchy = manager.get_type_hierarchy()
        return (type_[0] for type_ in type_hierarchy)

translation_manager.register(TypeTranslationContextManager)


class AttributeTranslationContextManager(TranslationContextManager):
    """ TranslationContextManager for Kaiso attributes """

    context = "taal:kaiso_attr"

    def __init__(self, manager, **kwargs):
        self.manager = manager

    @staticmethod
    def get_message_id(type_id, attr_name):
        return json.dumps(
            [type_id, attr_name]
        )
Ejemplo n.º 2
0
def test_duplicate_registration():
    translation_manager.register(Manager)
    with pytest.raises(KeyError):
        translation_manager.register(Manager)