def test_badge_award(self):
        """Can award badges from API"""
        invite_email = 'someguy@example.com'
        invalid_email = 'THISISINVALID'
        description = "Is a hoopy frood."
        award_user = self._get_user(username="awardee1",
                                    email="awardee1@example.com")

        # Construct the request data...
        data = dict(
            description = description,
            emails = [
                award_user.email,
                invite_email,
                invalid_email,
            ],
        )

        # POST to the awards URL
        resp = self.client.post(self.awards_url, json.dumps(data),
                                content_type='application/json',
                                HTTP_AUTHORIZATION=self.basic_auth)
        
        ok_(self.badge.is_awarded_to(award_user))
        award = Award.objects.get(user=award_user, badge=self.badge)
        eq_(description, award.description)

        eq_('application/json', resp['Content-Type'])
        data = json.loads(resp.content)

        ok_('successes' in data)
        ok_(award_user.email in data['successes'])
        eq_('AWARDED', data['successes'][award_user.email])
        ok_(invite_email in data['successes'])
        eq_('INVITED', data['successes'][invite_email])

        ok_('errors' in data)
        ok_(invalid_email in data['errors'])
        eq_('INVALID', data['errors'][invalid_email])
dataset/ETHPy150Open lmorchard/badg.us/badgus/badger_api/tests/test_views.py/BadgerApiViewsTests.test_badge_award/original