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

        resp = self.client.get(reverse('badger.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())
Example #4
0
    def test_details_page(self):
        # This is a just basic test to make sure the template loads.
        b = badge(save=True)
        a1 = award(description=u'A1 AWARD', badge=b, save=True)

        resp = self.client.get(a1.get_absolute_url(), follow=True)
        eq_(200, resp.status_code)
Example #5
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 django-badger in startup.
        from kitsune.kbadge import badges  # noqa

        new_badge = badge(save=True)

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

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

        eq_(1, len(mail.outbox))