def test_list(self): response = self.get(url_for('api.available_organization_badges')) self.assertStatus(response, 200) self.assertEqual(len(response.json), len(ORG_BADGE_KINDS)) for kind, label in ORG_BADGE_KINDS.items(): self.assertIn(kind, response.json) self.assertEqual(response.json[kind], label)
def test_create_2nd(self): # Explicitely setting the kind to avoid collisions given the # small number of choices for kinds. kinds_keys = ORG_BADGE_KINDS.keys() self.organization.badges.append( OrganizationBadgeFactory(kind=kinds_keys[0])) self.organization.save() data = OrganizationBadgeFactory.attributes() data['kind'] = kinds_keys[1] with self.api_user(): response = self.post( url_for('api.organization_badges', org=self.organization), data) self.assertStatus(response, 201) self.organization.reload() self.assertEqual(len(self.organization.badges), 2)
def organization_badge_labelizer(label, kind): return ORG_BADGE_KINDS.get(kind, '')