Ejemplo n.º 1
0
def test_locale_parts_stats_pages_tied_to_resources(locale_parts):
    """
    Return subpage name and stats for locales resources are available for.
    """
    locale_a, locale_b, entity_a = locale_parts
    project = entity_a.resource.project
    resourceX = ResourceFactory.create(project=project, path="/other/path.po",)
    EntityFactory.create(resource=resourceX, string="Entity X")
    TranslatedResourceFactory.create(
        resource=resourceX, locale=locale_a,
    )
    TranslatedResourceFactory.create(
        resource=resourceX, locale=locale_b,
    )
    sub1 = SubpageFactory.create(project=project, name="Subpage",)
    sub1.resources.add(resourceX)
    sub2 = SubpageFactory.create(project=project, name="Other Subpage",)
    sub2.resources.add(resourceX)
    details0 = locale_a.parts_stats(project)
    detailsX = locale_b.parts_stats(project)
    assert details0[0]["title"] == "Other Subpage"
    assert details0[0]["unreviewed_strings"] == 0
    assert details0[1]["title"] == "Subpage"
    assert details0[1]["unreviewed_strings"] == 0
    assert detailsX[0]["title"] == "Other Subpage"
    assert detailsX[0]["unreviewed_strings"] == 0
Ejemplo n.º 2
0
def test_locale_parts_stats_pages_tied_to_resources(locale_parts):
    """
    Return subpage name and stats for locales resources are available for.
    """
    locale_a, locale_b, entity_a = locale_parts
    project = entity_a.resource.project
    resourceX = ResourceFactory.create(
        project=project,
        path='/other/path.po',
    )
    EntityFactory.create(resource=resourceX, string="Entity X")
    TranslatedResourceFactory.create(
        resource=resourceX, locale=locale_a,
    )
    TranslatedResourceFactory.create(
        resource=resourceX, locale=locale_b,
    )
    sub1 = SubpageFactory.create(
        project=project, name='Subpage',
    )
    sub1.resources.add(resourceX)
    sub2 = SubpageFactory.create(
        project=project, name='Other Subpage',
    )
    sub2.resources.add(resourceX)
    details0 = locale_a.parts_stats(project)
    detailsX = locale_b.parts_stats(project)
    assert details0[0]['title'] == 'Other Subpage'
    assert details0[0]['unreviewed_strings'] == 0
    assert details0[1]['title'] == 'Subpage'
    assert details0[1]['unreviewed_strings'] == 0
    assert detailsX[0]['title'] == 'Other Subpage'
    assert detailsX[0]['unreviewed_strings'] == 0
Ejemplo n.º 3
0
def test_locale_parts_stats_pages_not_tied_to_resources(locale_parts):
    """
    Return subpage name and stats.
    """
    locale_a, locale_b, entity_a = locale_parts
    project = entity_a.resource.project
    SubpageFactory.create(project=project, name="Subpage")
    details = locale_a.parts_stats(project)
    assert details[0]["title"] == "Subpage"
    assert details[0]["unreviewed_strings"] == 0
Ejemplo n.º 4
0
def test_locale_parts_stats_pages_not_tied_to_resources(locale_parts):
    """
    Return subpage name and stats.
    """
    locale_a, locale_b, entity_a = locale_parts
    project = entity_a.resource.project
    SubpageFactory.create(project=project, name='Subpage')
    details = locale_a.parts_stats(project)
    assert details[0]['title'] == 'Subpage'
    assert details[0]['unreviewed_strings'] == 0
Ejemplo n.º 5
0
def entity_test_models(translation_a, locale_b):
    """This fixture provides:

    - 2 translations of a plural entity
    - 1 translation of a non-plural entity
    - A subpage that contains the plural entity
    """

    entity_a = translation_a.entity
    locale_a = translation_a.locale
    project_a = entity_a.resource.project

    locale_a.cldr_plurals = "0,1"
    locale_a.save()
    translation_a.plural_form = 0
    translation_a.active = True
    translation_a.save()
    resourceX = ResourceFactory(
        project=project_a,
        path="resourceX.po",
    )
    entity_a.string = "Entity zero"
    entity_a.key = entity_a.string
    entity_a.string_plural = "Plural %s" % entity_a.string
    entity_a.order = 0
    entity_a.save()
    entity_b = EntityFactory(
        resource=resourceX,
        string="entity_b",
        key="Key%sentity_b" % KEY_SEPARATOR,
        order=0,
    )
    translation_a_pl = TranslationFactory(
        entity=entity_a,
        locale=locale_a,
        plural_form=1,
        active=True,
        string="Plural %s" % translation_a.string,
    )
    translationX = TranslationFactory(
        entity=entity_b,
        locale=locale_a,
        active=True,
        string="Translation %s" % entity_b.string,
    )
    subpageX = SubpageFactory(
        project=project_a,
        name="Subpage",
    )
    subpageX.resources.add(entity_a.resource)
    return translation_a, translation_a_pl, translationX, subpageX