Example #1
0
    def test_revoke_bad_aid(self):
        badgeid = self.user_settings.badges[0]._id
        initnum = get_node_badges(self.project).count()
        assert_true(self.user_settings.can_award)
        url = api_url_for('award_badge', pid=self.project._id)
        ret = self.app.post_json(url, {'badgeid': badgeid}, auth=self.user.auth)
        self.project.reload()
        assert_equals(ret.status_int, 200)
        assert_equals(initnum + 1, get_node_badges(self.project).count())

        assertion = get_node_badges(self.project)[0]

        revoke = api_url_for('revoke_badge', pid=self.project._id)

        ret = self.app.post_json(revoke,
            {
                'id': 'Im a bad id :D',
                'reason': ''
            }, auth=self.user.auth, expect_errors=True)
        self.project.reload()
        self.user_settings.reload()
        assertion.reload()

        assert_equals(ret.status_int, 400)
        assert_false(assertion.revoked)
        assert_true(get_node_badges(self.project)[0]._id, assertion._id)
        assert_false(assertion._id in self.user_settings.revocation_list)
Example #2
0
    def test_revoke_badge_reason(self):
        badgeid = self.user_settings.badges[0]._id
        initnum = get_node_badges(self.project).count()
        assert_true(self.user_settings.can_award)
        url = api_url_for('award_badge', pid=self.project._id)
        ret = self.app.post_json(url, {'badgeid': badgeid}, auth=self.user.auth)
        self.project.reload()
        assert_equals(ret.status_int, 200)
        assert_equals(initnum + 1, get_node_badges(self.project).count())

        assertion = get_node_badges(self.project)[0]

        revoke = api_url_for('revoke_badge', pid=self.project._id)
        ret = self.app.post_json(revoke,
            {
                'id': assertion._id,
                'reason': 'Is a loser'
            }, auth=self.user.auth)
        self.project.reload()
        self.user_settings.reload()
        assertion.reload()

        assert_equals(ret.status_int, 200)
        assert_true(get_node_badges(self.project)[0]._id, assertion._id)
        assert_true(assertion._id in self.user_settings.revocation_list)
        assert_equals(len(self.user_settings.revocation_list), 1)
        assert_true(assertion.revoked)
        assert_equals(self.user_settings.revocation_list[assertion._id], 'Is a loser')
Example #3
0
    def test_revoke_bad_aid(self):
        badgeid = self.user_settings.badges[0]._id
        initnum = get_node_badges(self.project).count()
        assert_true(self.user_settings.can_award)
        url = api_url_for('award_badge', pid=self.project._id)
        ret = self.app.post_json(url, {'badgeid': badgeid},
                                 auth=self.user.auth)
        self.project.reload()
        assert_equals(ret.status_int, 200)
        assert_equals(initnum + 1, get_node_badges(self.project).count())

        assertion = get_node_badges(self.project)[0]

        revoke = api_url_for('revoke_badge', pid=self.project._id)

        ret = self.app.post_json(revoke, {
            'id': 'Im a bad id :D',
            'reason': ''
        },
                                 auth=self.user.auth,
                                 expect_errors=True)
        self.project.reload()
        self.user_settings.reload()
        assertion.reload()

        assert_equals(ret.status_int, 400)
        assert_false(assertion.revoked)
        assert_true(get_node_badges(self.project)[0]._id, assertion._id)
        assert_false(assertion._id in self.user_settings.revocation_list)
Example #4
0
    def test_revoke_badge_reason(self):
        badgeid = self.user_settings.badges[0]._id
        initnum = get_node_badges(self.project).count()
        assert_true(self.user_settings.can_award)
        url = api_url_for('award_badge', pid=self.project._id)
        ret = self.app.post_json(url, {'badgeid': badgeid},
                                 auth=self.user.auth)
        self.project.reload()
        assert_equals(ret.status_int, 200)
        assert_equals(initnum + 1, get_node_badges(self.project).count())

        assertion = get_node_badges(self.project)[0]

        revoke = api_url_for('revoke_badge', pid=self.project._id)
        ret = self.app.post_json(revoke, {
            'id': assertion._id,
            'reason': 'Is a loser'
        },
                                 auth=self.user.auth)
        self.project.reload()
        self.user_settings.reload()
        assertion.reload()

        assert_equals(ret.status_int, 200)
        assert_true(get_node_badges(self.project)[0]._id, assertion._id)
        assert_true(assertion._id in self.user_settings.revocation_list)
        assert_equals(len(self.user_settings.revocation_list), 1)
        assert_true(assertion.revoked)
        assert_equals(self.user_settings.revocation_list[assertion._id],
                      'Is a loser')
Example #5
0
 def test_award_badge(self):
     badgeid = self.user_settings.badges[0]._id
     initnum = get_node_badges(self.project).count()
     assert_true(self.user_settings.can_award)
     url = api_url_for('award_badge', pid=self.project._id)
     ret = self.app.post_json(url, {'badgeid': badgeid}, auth=self.user.auth)
     self.project.reload()
     assert_equals(ret.status_int, 200)
     assert_equals(initnum + 1, get_node_badges(self.project).count())
Example #6
0
 def test_award_badge(self):
     badgeid = self.user_settings.badges[0]._id
     initnum = get_node_badges(self.project).count()
     assert_true(self.user_settings.can_award)
     url = api_url_for('award_badge', pid=self.project._id)
     ret = self.app.post_json(url, {'badgeid': badgeid},
                              auth=self.user.auth)
     self.project.reload()
     assert_equals(ret.status_int, 200)
     assert_equals(initnum + 1, get_node_badges(self.project).count())