Пример #1
0
def test_util_tags_stats_tool_groupby_locale(
    tag_matrix,
    calculate_tags,
    assert_tags,
    tag_test_kwargs,
):
    name, kwargs = tag_test_kwargs

    # this is only used with slug set to a unique slug, and doesnt work
    # correctly without
    if name == "slug_contains" or not kwargs.get("slug"):
        kwargs["slug"] = tag_matrix["tags"][0].slug

    stats_tool = TagsStatsTool(groupby="locale", **kwargs)
    data = stats_tool.get_data()
    # assert isinstance(data, QuerySet)
    exp = calculate_tags(groupby="locale", **kwargs)
    data = stats_tool.coalesce(data)
    assert len(data) == len(exp)
    for locale in data:
        locale_exp = exp[locale["locale"]]
        assert locale_exp["total_strings"] == locale["total_strings"]
        assert locale_exp["pretranslated_strings"] == locale[
            "pretranslated_strings"]
        assert locale_exp["approved_strings"] == locale["approved_strings"]
Пример #2
0
def test_util_tags_stats_tool_groupby_locale(tag_matrix,
                                             calculate_tags,
                                             assert_tags, tag_test_kwargs):
    name, kwargs = tag_test_kwargs

    # this is only used with slug set to a unique slug, and doesnt work
    # correctly without
    if name in ['slug_glob', 'party_glob'] or not kwargs.get('slug'):
        kwargs['slug'] = tag_matrix['tags'][0].slug

    stats_tool = TagsStatsTool(
        groupby="locale",
        **kwargs)
    data = stats_tool.get_data()
    # assert isinstance(data, QuerySet)
    exp = calculate_tags(groupby='locale', **kwargs)
    data = stats_tool.coalesce(data)
    assert len(data) == len(exp)
    for locale in data:
        locale_exp = exp[locale['locale']]
        assert locale_exp['total_strings'] == locale['total_strings']
        assert locale_exp['fuzzy_strings'] == locale['fuzzy_strings']
        assert locale_exp['approved_strings'] == locale['approved_strings']
Пример #3
0
def test_util_tags_stats_tool_groupby_locale(
    tag_matrix,
    calculate_tags,
    assert_tags,
    tag_test_kwargs,
):
    name, kwargs = tag_test_kwargs

    # this is only used with slug set to a unique slug, and doesnt work
    # correctly without
    if name in ['slug_glob', 'party_glob'] or not kwargs.get('slug'):
        kwargs['slug'] = tag_matrix['tags'][0].slug

    stats_tool = TagsStatsTool(groupby="locale", **kwargs)
    data = stats_tool.get_data()
    # assert isinstance(data, QuerySet)
    exp = calculate_tags(groupby='locale', **kwargs)
    data = stats_tool.coalesce(data)
    assert len(data) == len(exp)
    for locale in data:
        locale_exp = exp[locale['locale']]
        assert locale_exp['total_strings'] == locale['total_strings']
        assert locale_exp['fuzzy_strings'] == locale['fuzzy_strings']
        assert locale_exp['approved_strings'] == locale['approved_strings']