def test_issue_award(self):
        SAMPLE_DESCRIPTION = u'This is a sample description'

        user1 = self._get_user(username="creator", email="creator@example.com")
        user2 = self._get_user(username="awardee", email="awardee@example.com")

        b1 = Badge.objects.create(creator=user1, title="Badge to awarded")

        url = reverse('badger.views.award_badge', args=(b1.slug,))

        # Non-creator should be denied attempt to award badge
        self.client.login(username="awardee", password="trustno1")
        r = self.client.get(url, follow=True)
        eq_(403, r.status_code)

        # But, the creator should be allowed
        self.client.login(username="creator", password="trustno1")
        r = self.client.get(url, follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        form = doc('form#award_badge')
        eq_(1, form.length)
        eq_(1, form.find('*[name=emails]').length)
        eq_(1, form.find('*[name=description]').length)
        eq_(1, form.find('input.submit,button.submit').length)

        r = self.client.post(url, dict(
            emails=user2.email,
            description=SAMPLE_DESCRIPTION
        ), follow=False)

        ok_('award' in r['Location'])

        ok_(b1.is_awarded_to(user2))

        award = Award.objects.filter(user=user2, badge=b1)[0]
        eq_(SAMPLE_DESCRIPTION, award.description)

        r = self.client.get(award.get_absolute_url(), follow=True)
        eq_(200, r.status_code)

        doc = pq(r.content)
        eq_(SAMPLE_DESCRIPTION, doc.find('.award .description').text())
Badge creator can issue award to another user
dataset/ETHPy150Open mozilla/django-badger/badger/tests/test_views.py/BadgerViewsTest.test_issue_award