예제 #1
0
def test_get_failed_checks_db_objects(translation_a):
    """
    Return model instances of warnings and errors
    """
    warnings, errors = get_failed_checks_db_objects(
        translation_a,
        {
            "clWarnings": ["compare-locales warning 1"],
            # Warnings from some libraries e.g. Translate Toolkit, shouldn't land in the database.
            "ttWarnings": ["translate-toolkit warning 1"],
            "clErrors": ["compare-locales error 1"],
            "pErrors": ["pontoon error 1"],
        },
    )

    # Check if objects aren't saved in DB
    assert all([w.pk is None for w in warnings])
    assert all([e.pk is None for e in errors])

    (cl_warning, ) = warnings
    cl_error, p_error = sorted(errors, key=lambda e: e.library)

    assert cl_warning.library == "cl"
    assert cl_warning.message == "compare-locales warning 1"
    assert cl_warning.translation == translation_a

    assert cl_error.library == "cl"
    assert cl_error.message == "compare-locales error 1"
    assert cl_error.translation == translation_a

    assert p_error.library == "p"
    assert p_error.message == "pontoon error 1"
    assert p_error.translation == translation_a
예제 #2
0
파일: test_models.py 프로젝트: Pike/pontoon
def test_get_failed_checks_db_objects(translation_a):
    """
    Return model instances of warnings and errors
    """
    warnings, errors = get_failed_checks_db_objects(
        translation_a, {
            'clWarnings': [
                'compare-locales warning 1',
            ],

            # Warnings from some libraries e.g. Translate Toolkit, shouldn't land in the database.
            'ttWarnings': [
                'translate-toolkit warning 1',
            ],
            'clErrors': [
                'compare-locales error 1',
            ],
            'pErrors': [
                'pontoon error 1'
            ]
        }
    )

    # Check if objects aren't saved in DB
    assert all([w.pk is None for w in warnings])
    assert all([e.pk is None for e in errors])

    cl_warning, = warnings
    p_error, cl_error = errors

    assert cl_warning.library == 'cl'
    assert cl_warning.message == 'compare-locales warning 1'
    assert cl_warning.translation == translation_a

    assert cl_error.library == 'cl'
    assert cl_error.message == 'compare-locales error 1'
    assert cl_error.translation == translation_a

    assert p_error.library == 'p'
    assert p_error.message == 'pontoon error 1'
    assert p_error.translation == translation_a
예제 #3
0
def test_get_failed_checks_db_objects(translation_a):
    """
    Return model instances of warnings and errors
    """
    warnings, errors = get_failed_checks_db_objects(
        translation_a,
        {
            'clWarnings': [
                'compare-locales warning 1',
            ],

            # Warnings from some libraries e.g. Translate Toolkit, shouldn't land in the database.
            'ttWarnings': [
                'translate-toolkit warning 1',
            ],
            'clErrors': [
                'compare-locales error 1',
            ],
            'pErrors': ['pontoon error 1']
        })

    # Check if objects aren't saved in DB
    assert all([w.pk is None for w in warnings])
    assert all([e.pk is None for e in errors])

    cl_warning, = warnings
    cl_error, p_error = sorted(errors, key=lambda e: e.library)

    assert cl_warning.library == 'cl'
    assert cl_warning.message == 'compare-locales warning 1'
    assert cl_warning.translation == translation_a

    assert cl_error.library == 'cl'
    assert cl_error.message == 'compare-locales error 1'
    assert cl_error.translation == translation_a

    assert p_error.library == 'p'
    assert p_error.message == 'pontoon error 1'
    assert p_error.translation == translation_a