Ejemplo n.º 1
0
def test_translation_label(mocker):
    mocker.patch("workflow._FALLBACK_LANG", "en")
    tr = workflow.TranslationLabel({"en": "cat", "es": "gato"})
    assert repr(tr) == "TranslationLabel({u'en': u'cat', u'es': u'gato'})"
    assert str(tr) == "cat"
    assert tr["es"] == "gato"
    assert tr["unexistent-lang-code"] == "cat"
    assert tr.get_label(lang="es") == "gato"
    assert tr.get_label(lang="is", fallback_label="köttur") == "köttur"
    assert tr.get_label(lang="??") == "cat"
    mocker.patch("workflow._FALLBACK_LANG", "xx")
    assert tr.get_label(lang="yy") == workflow._UNKNOWN_TRANSLATION_LABEL
Ejemplo n.º 2
0
def test_translation_label_string(mocker):
    mocker.patch("workflow._FALLBACK_LANG", "en")
    tr = workflow.TranslationLabel("cat")
    assert repr(tr) == "TranslationLabel({u'en': u'cat'})"
Ejemplo n.º 3
0
def test_translation_label_with_prepared_codes(mocker):
    mocker.patch("workflow._FALLBACK_LANG", "en")
    tr = workflow.TranslationLabel({"en": "dog", "pt_BR": "cão"})
    assert tr.get_label(lang="en") == "dog"
    assert tr.get_label(lang="pt-br") == "cão"
    assert tr.get_label(lang="pt_BR") == "cão"