예제 #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') == {}