示例#1
0
 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)
示例#2
0
 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)
示例#3
0
 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)
示例#4
0
 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)
示例#5
0
文件: search.py 项目: grouan/udata
def organization_badge_labelizer(label, kind):
    return ORG_BADGE_KINDS.get(kind, '')