示例#1
0
 def test_badges_listed(self):
     """Verify that awarded badges appear on the profile page."""
     badge_title = 'awesomesauce badge'
     b = BadgeFactory(title=badge_title)
     u = UserFactory()
     AwardFactory(user=u, badge=b)
     r = self.client.get(reverse('users.profile', args=[u.username]))
     assert badge_title in r.content
示例#2
0
    def test_list_with_awards(self):
        b = BadgeFactory()
        a1 = AwardFactory(description=u'A1 AWARD', badge=b)
        a2 = AwardFactory(description=u'A2 AWARD', badge=b)
        a3 = AwardFactory(description=u'A3 AWARD', badge=b)

        resp = self.client.get(reverse('kbadge.awards_list'), follow=True)
        eq_(200, resp.status_code)
        self.assertContains(resp, a1.user.username)
        self.assertContains(resp, a1.get_absolute_url())
        self.assertContains(resp, a2.user.username)
        self.assertContains(resp, a2.get_absolute_url())
        self.assertContains(resp, a3.user.username)
        self.assertContains(resp, a3.get_absolute_url())
示例#3
0
    def test_notification(self):
        # Note: Need to do this import here so the
        # notify_award_recipient function handles the
        # badge_was_awarded signal. This works fine in production
        # because badges gets loaded by kitsune.kbadge in startup.
        from kitsune.kbadge import badges  # noqa

        new_badge = BadgeFactory()

        # Check the mail queue first.
        eq_(0, len(mail.outbox))

        # Create an award and save it. This triggers the notification.
        AwardFactory(description="yay!", badge=new_badge)

        eq_(1, len(mail.outbox))
示例#4
0
    def test_details_page(self):
        # This is a just basic test to make sure the template loads.
        a1 = AwardFactory(description=u'A1 AWARD')

        resp = self.client.get(a1.get_absolute_url(), follow=True)
        eq_(200, resp.status_code)