Beispiel #1
0
    def test_l10n_badge(self):
        """Verify the L10n Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        user = UserFactory()
        b = BadgeFactory(
            slug=WIKI_BADGES["l10n-badge"]["slug"].format(year=year),
            title=WIKI_BADGES["l10n-badge"]["title"].format(year=year),
            description=WIKI_BADGES["l10n-badge"]["description"].format(
                year=year),
        )

        # Create 9 approved es revisions.
        doc = DocumentFactory(locale="es")
        ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1,
                                             creator=user,
                                             document=doc)

        # User should NOT have the badge yet
        assert not b.is_awarded_to(user)

        # Create 1 more approved es revision.
        RevisionFactory(creator=user, document=doc, is_approved=True)

        # User should have the badge now
        assert b.is_awarded_to(user)
Beispiel #2
0
    def test_l10n_badge(self):
        """Verify the L10n Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        b = BadgeFactory(
            slug=WIKI_BADGES['l10n-badge']['slug'].format(year=year),
            title=WIKI_BADGES['l10n-badge']['title'].format(year=year),
            description=WIKI_BADGES['l10n-badge']['description'].format(
                year=year))

        # Create 9 approved es revisions.
        d = DocumentFactory(locale='es')
        ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1,
                                             creator=u,
                                             document=d)

        # User should NOT have the badge yet
        assert not b.is_awarded_to(u)

        # Create 1 more approved es revision.
        RevisionFactory(creator=u, document=d, is_approved=True)

        # User should have the badge now
        assert b.is_awarded_to(u)
Beispiel #3
0
    def test_kb_badge(self):
        """Verify the KB Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        b = BadgeFactory(
            slug=WIKI_BADGES["kb-badge"]["slug"].format(year=year),
            title=WIKI_BADGES["kb-badge"]["title"].format(year=year),
            description=WIKI_BADGES["kb-badge"]["description"].format(
                year=year),
        )

        # Create 9 approved en-US revisions.
        d = DocumentFactory(locale=settings.WIKI_DEFAULT_LANGUAGE)
        ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1,
                                             creator=u,
                                             document=d)

        # User should NOT have the badge yet
        assert not b.is_awarded_to(u)

        # Create 1 more approved en-US revision.
        RevisionFactory(creator=u, document=d, is_approved=True)

        # User should have the badge now
        assert b.is_awarded_to(u)
Beispiel #4
0
    def test_answer_badge(self):
        """Verify the Support Forum Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        badge_template = QUESTIONS_BADGES['answer-badge']
        b = BadgeFactory(
            slug=badge_template['slug'].format(year=year),
            title=badge_template['title'].format(year=year),
            description=badge_template['description'].format(year=year))

        # Create one less answer than reqiured to earn badge
        AnswerFactory.create_batch(settings.BADGE_LIMIT_SUPPORT_FORUM - 1, creator=u)

        # User should NOT have the badge yet.
        assert not b.is_awarded_to(u)

        # Create 1 more answer.
        AnswerFactory(creator=u)

        # User should have the badge now.
        assert b.is_awarded_to(u)
Beispiel #5
0
    def test_l10n_badge(self):
        """Verify the L10n Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        b = BadgeFactory(
            slug=WIKI_BADGES['l10n-badge']['slug'].format(year=year),
            title=WIKI_BADGES['l10n-badge']['title'].format(year=year),
            description=WIKI_BADGES['l10n-badge']['description'].format(year=year))

        # Create 9 approved es revisions.
        d = DocumentFactory(locale='es')
        ApprovedRevisionFactory.create_batch(9, creator=u, document=d)

        # User should NOT have the badge yet
        assert not b.is_awarded_to(u)

        # Create 1 more approved es revision.
        RevisionFactory(creator=u, document=d, is_approved=True)

        # User should have the badge now
        assert b.is_awarded_to(u)
Beispiel #6
0
    def test_answer_badge(self):
        """Verify the Support Forum Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        badge_template = QUESTIONS_BADGES['answer-badge']
        b = BadgeFactory(
            slug=badge_template['slug'].format(year=year),
            title=badge_template['title'].format(year=year),
            description=badge_template['description'].format(year=year))

        # Create 29 answers.
        AnswerFactory.create_batch(29, creator=u)

        # User should NOT have the badge yet.
        assert not b.is_awarded_to(u)

        # Create 1 more answer.
        AnswerFactory(creator=u)

        # User should have the badge now.
        assert b.is_awarded_to(u)
Beispiel #7
0
    def test_aoa_badge(self):
        """Verify the KB Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        b = BadgeFactory(
            slug=AOA_BADGE['slug'].format(year=year),
            title=AOA_BADGE['title'].format(year=year),
            description=AOA_BADGE['description'].format(year=year))

        # Create 49 replies.
        # FIXME: Do this as a batch
        for _ in range(49):
            ReplyFactory(user=u)

        # User should NOT have the badge yet.
        assert not b.is_awarded_to(u)

        # Create 1 more reply.
        ReplyFactory(user=u)

        # User should have the badge now.
        assert b.is_awarded_to(u)
Beispiel #8
0
    def test_kb_badge(self):
        """Verify the KB Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        b = BadgeFactory(
            slug=WIKI_BADGES['kb-badge']['slug'].format(year=year),
            title=WIKI_BADGES['kb-badge']['title'].format(year=year),
            description=WIKI_BADGES['kb-badge']['description'].format(year=year))

        # Create 9 approved en-US revisions.
        d = DocumentFactory(locale=settings.WIKI_DEFAULT_LANGUAGE)
        ApprovedRevisionFactory.create_batch(settings.BADGE_LIMIT_L10N_KB - 1,
                                             creator=u, document=d)

        # User should NOT have the badge yet
        assert not b.is_awarded_to(u)

        # Create 1 more approved en-US revision.
        RevisionFactory(creator=u, document=d, is_approved=True)

        # User should have the badge now
        assert b.is_awarded_to(u)
Beispiel #9
0
    def test_aoa_badge(self):
        """Verify the KB Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        b = BadgeFactory(
            slug=AOA_BADGE['slug'].format(year=year),
            title=AOA_BADGE['title'].format(year=year),
            description=AOA_BADGE['description'].format(year=year))

        # Create 49 replies.
        # FIXME: Do this as a batch
        for _ in range(49):
            ReplyFactory(user=u)

        # User should NOT have the badge yet.
        assert not b.is_awarded_to(u)

        # Create 1 more reply.
        ReplyFactory(user=u)

        # User should have the badge now.
        assert b.is_awarded_to(u)
Beispiel #10
0
    def test_answer_badge(self):
        """Verify the Support Forum Badge is awarded properly."""
        # Create the user and badge.
        year = date.today().year
        u = UserFactory()
        badge_template = QUESTIONS_BADGES["answer-badge"]
        b = BadgeFactory(
            slug=badge_template["slug"].format(year=year),
            title=badge_template["title"].format(year=year),
            description=badge_template["description"].format(year=year),
        )

        # Create one less answer than reqiured to earn badge
        AnswerFactory.create_batch(settings.BADGE_LIMIT_SUPPORT_FORUM - 1,
                                   creator=u)

        # User should NOT have the badge yet.
        assert not b.is_awarded_to(u)

        # Create 1 more answer.
        AnswerFactory(creator=u)

        # User should have the badge now.
        assert b.is_awarded_to(u)