# -*- coding: utf-8 -*-
from datetime import date, timedelta

from django.conf import settings
from django.core.management import call_command
from nose.tools import eq_

from kitsune.dashboards.management.commands.cache_most_unhelpful_kb_articles import (
    _get_current_unhelpful, _get_old_unhelpful)
from kitsune.dashboards.models import (L10N_ALL_CODE, L10N_TOP20_CODE,
                                       L10N_TOP100_CODE, WikiMetric)
from kitsune.products.tests import ProductFactory
from kitsune.sumo.redis_utils import RedisError, redis_client
from kitsune.sumo.tests import SkipTest, TestCase
from kitsune.users.tests import UserFactory
from kitsune.wiki.tests import (ApprovedRevisionFactory, DocumentFactory,
                                HelpfulVoteFactory, RevisionFactory)


def _add_vote_in_past(rev, vote, days_back):
    HelpfulVoteFactory(
        revision=rev,
        helpful=vote,
        created=date.today() - timedelta(days=days_back))


def _make_backdated_revision(backdate):
    return RevisionFactory(created=date.today() - timedelta(days=backdate))