示例#1
0
def test_lang_newlines(get_entity_mock):
    """Newlines aren't allowed in lang files"""
    assert run_checks(get_entity_mock("lang"), "", "aaa\nbbb") == {
        "pErrors": [u"Newline characters are not allowed"]
    }

    assert run_checks(get_entity_mock("po"), "", "aaa\nbbb") == {}
示例#2
0
def test_lang_newlines(get_entity_mock):
    """Newlines aren't allowed in lang files"""
    assert run_checks(get_entity_mock('lang'), 'aaa\nbbb') == {
        'pErrors': [u'Newline characters are not allowed']
    }

    assert run_checks(get_entity_mock('po'), 'aaa\nbbb') == {}
示例#3
0
def test_too_long_translation_html_tags(get_entity_mock):
    """
    HTML tags can't be included in the MAX_LENGTH check.
    """
    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '<a href="pontoon.mozilla.org">01</a><i>23</i>'
    ) == {}

    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '<a href="pontoon.mozilla.org">012</a><i>23</i>'
    ) == {
        'pErrors': ['Translation too long']
    }

    # Check if entities are causing false errors
    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '<a href="pontoon.mozilla.org">ł&nbsp;</a><i>ń&nbsp;</i>'
    ) == {}

    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '<a href="pontoon.mozilla.org">ł&nbsp;&nbsp;</a><i>ń&nbsp;</i>'
    ) == {
        'pErrors': ['Translation too long']
    }
示例#4
0
def test_too_long_translation_html_tags(get_entity_mock):
    """
    HTML tags can't be included in the MAX_LENGTH check.
    """
    assert (
        run_checks(
            get_entity_mock("lang", "MAX_LENGTH: 4"),
            "",
            '<a href="pontoon.mozilla.org">01</a><i>23</i>',
        )
        == {}
    )

    assert run_checks(
        get_entity_mock("lang", "MAX_LENGTH: 4"),
        "",
        '<a href="pontoon.mozilla.org">012</a><i>23</i>',
    ) == {"pErrors": ["Translation too long"]}

    # Check if entities are causing false errors
    assert (
        run_checks(
            get_entity_mock("lang", "MAX_LENGTH: 4"),
            "",
            '<a href="pontoon.mozilla.org">ł&nbsp;</a><i>ń&nbsp;</i>',
        )
        == {}
    )

    assert run_checks(
        get_entity_mock("lang", "MAX_LENGTH: 4"),
        "",
        '<a href="pontoon.mozilla.org">ł&nbsp;&nbsp;</a><i>ń&nbsp;</i>',
    ) == {"pErrors": ["Translation too long"]}
示例#5
0
def test_ftl_parse_error(get_entity_mock):
    """Invalid FTL strings are not allowed"""
    assert run_checks(get_entity_mock(
        'ftl', string='key = value'), 'key =') == {
            'pErrors':
            [u'Expected message "key" to have a value or attributes']
        }

    assert run_checks(get_entity_mock('ftl', string='key = value'),
                      'key = translation') == {}
示例#6
0
def test_ftl_parse_error(get_entity_mock):
    """Invalid FTL strings are not allowed"""
    assert run_checks(get_entity_mock(
        "ftl", string="key = value"), "", "key =") == {
            "pErrors":
            ['Expected message "key" to have a value or attributes']
        }

    assert (run_checks(get_entity_mock("ftl", string="key = value"), "",
                       "key = translation") == {})
示例#7
0
def test_lang_newlines(get_entity_mock):
    """Newlines aren't allowed in lang files"""
    assert run_checks(
        get_entity_mock('lang'),
        'aaa\nbbb'
    ) == {
        'pErrors': [u'Newline characters are not allowed']
    }

    assert run_checks(
        get_entity_mock('po'),
        'aaa\nbbb'
    ) == {}
示例#8
0
def test_ftl_parse_error(get_entity_mock):
    """Invalid FTL strings are not allowed"""
    assert run_checks(
        get_entity_mock('ftl', string='key = value'),
        'key ='
    ) == {
        'pErrors': [u'Expected message "key" to have a value or attributes']
    }

    assert run_checks(
        get_entity_mock('ftl', string='key = value'),
        'key = translation'
    ) == {}
示例#9
0
def test_ending_newline(get_entity_mock):
    """
    Original and translation in a PO file must either both end
    in a newline, or none of them should.
    """
    assert run_checks(get_entity_mock("po"), "Original", "Translation\n") == {
        "pErrors": [u"Ending newline mismatch"]
    }

    assert run_checks(get_entity_mock("po"), "Original\n", "Translation") == {
        "pErrors": [u"Ending newline mismatch"]
    }

    assert run_checks(get_entity_mock("po"), "Original\n", "Translation\n") == {}

    assert run_checks(get_entity_mock("po"), "Original", "Translation") == {}
示例#10
0
def test_ftl_id_missmatch(get_entity_mock):
    """ID of the source string and translation must be the same"""
    assert run_checks(get_entity_mock("ftl", string="key = value"), "",
                      "key1 = translation") == {
                          "pErrors":
                          ["Translation key needs to match source string key"]
                      }
示例#11
0
def test_too_long_translation_invalid_length(get_entity_mock):
    """
    Checks should return an error if a translation is too long.
    """
    assert run_checks(get_entity_mock("lang", "MAX_LENGTH: 2"), "", "0123") == {
        "pErrors": ["Translation too long"]
    }
示例#12
0
def test_empty_translations(get_entity_mock):
    """
    Empty translations shouldn't be allowed for some extensions.
    """
    assert run_checks(get_entity_mock('po'), '') == {
        'pErrors': [u'Empty translations are not allowed']
    }
示例#13
0
def test_too_long_translation_invalid_length(get_entity_mock):
    """
    Checks should return an error if a translation is too long.
    """
    assert run_checks(get_entity_mock('lang', 'MAX_LENGTH: 2'), '0123') == {
        'pErrors': ['Translation too long']
    }
示例#14
0
def test_empty_translations(get_entity_mock):
    """
    Empty translations shouldn't be allowed for some extensions.
    """
    assert run_checks(get_entity_mock("po"), "", "") == {
        "pErrors": [u"Empty translations are not allowed"]
    }
示例#15
0
def test_ftl_non_localizable_entries(get_entity_mock):
    """Non-localizable entries are not allowed"""
    assert run_checks(
        get_entity_mock('ftl', string='key = value'),
        '[[foo]]'
    ) == {
        'pErrors': [u'Expected an entry start']
    }
示例#16
0
def test_ftl_id_missmatch(get_entity_mock):
    """ID of the source string and translation must be the same"""
    assert run_checks(
        get_entity_mock('ftl', string='key = value'),
        'key1 = translation'
    ) == {
        'pErrors': [u'Translation key needs to match source string key']
    }
示例#17
0
def test_too_long_translation_valid_length(get_entity_mock):
    """
    Checks shouldn't return an error if a translation isn't too long.
    """
    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '0123'
    ) == {}
示例#18
0
def test_too_long_translation_invalid_length(get_entity_mock):
    """
    Checks should return an error if a translation is too long.
    """
    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 2'),
        '0123'
    ) == {'pErrors': ['Translation too long']}
示例#19
0
def test_empty_translations(get_entity_mock):
    """
    Empty translations shouldn't be allowed for some extensions.
    """
    assert run_checks(
        get_entity_mock('po'),
        ''
    ) == {
        'pErrors': [u'Empty translations are not allowed']
    }
示例#20
0
def test_too_long_translation_html_tags(get_entity_mock):
    """
    HTML tags can't be included in the MAX_LENGTH check.
    """
    assert run_checks(get_entity_mock('lang', 'MAX_LENGTH: 4'),
                      '<a href="pontoon.mozilla.org">01</a><i>23</i>') == {}

    assert run_checks(get_entity_mock('lang', 'MAX_LENGTH: 4'),
                      '<a href="pontoon.mozilla.org">012</a><i>23</i>') == {
                          'pErrors': ['Translation too long']
                      }

    # Check if entities are causing false errors
    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '<a href="pontoon.mozilla.org">ł&nbsp;</a><i>ń&nbsp;</i>') == {}

    assert run_checks(
        get_entity_mock('lang', 'MAX_LENGTH: 4'),
        '<a href="pontoon.mozilla.org">ł&nbsp;&nbsp;</a><i>ń&nbsp;</i>') == {
            'pErrors': ['Translation too long']
        }
示例#21
0
def test_ftl_non_localizable_entries(get_entity_mock):
    """Non-localizable entries are not allowed"""
    assert run_checks(get_entity_mock('ftl', string='key = value'),
                      '[[foo]]') == {
                          'pErrors': [u'Expected an entry start']
                      }
示例#22
0
def test_too_long_translation_valid_length(get_entity_mock):
    """
    Checks shouldn't return an error if a translation isn't too long.
    """
    assert run_checks(get_entity_mock("lang", "MAX_LENGTH: 4"), "", "0123") == {}
示例#23
0
def test_ftl_non_localizable_entries(get_entity_mock):
    """Non-localizable entries are not allowed"""
    assert run_checks(get_entity_mock("ftl", string="key = value"), "", "[[foo]]") == {
        "pErrors": [u"Expected an entry start"]
    }
示例#24
0
def test_ftl_id_missmatch(get_entity_mock):
    """ID of the source string and translation must be the same"""
    assert run_checks(get_entity_mock(
        'ftl', string='key = value'), 'key1 = translation') == {
            'pErrors': [u'Translation key needs to match source string key']
        }
示例#25
0
def test_too_long_translation_valid_length(get_entity_mock):
    """
    Checks shouldn't return an error if a translation isn't too long.
    """
    assert run_checks(get_entity_mock('lang', 'MAX_LENGTH: 4'), '0123') == {}