示例#1
0
def api_ids_to_names():
    """
    Gets the IDs of names of a given category.

    Returns a dict whose keys are IDs and values are dicts with keys `name` (str)
    and `redlisted` (bool).

    Args:
        ids (list of int)
            IDs whose names we want to retrieve.
    Example:
        response = {
            'info': {
                '1937622137': {
                    'name': 'Twine Endashi',
                     'redlisted': False,
                },
                ...
            }
        }

    Error codes:
        Forbidden (403): If logged in user is not a recruiter or admin
    """
    id_list = request.get_json().get('ids')
    return jsonify(get_ids_to_names(id_list, current_user=current_user))
示例#2
0
 def test_get_empty_list(self):
     response = get_ids_to_names(
         [],
         current_user=self.admin,
     )
     self.assertIn('info', response)
     data = response['info']
     self.assertEqual(len(data), 0)
示例#3
0
 def test_get_jita_name(self):
     jita_id = 30000142
     response = get_ids_to_names(
         [jita_id],
         current_user=self.admin,
     )
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(jita_id, data)
     self.assertEqual(data[jita_id]['name'], 'Jita')
     self.assertEqual(data[jita_id]['redlisted'], False)
示例#4
0
 def test_character_redlisted(self):
     self.applicant_character.redlisted = True
     response = get_ids_to_names(
         [self.applicant.id],
         current_user=self.admin,
     )
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(self.applicant.id, data)
     self.assertEqual(data[self.applicant.id]['name'], self.applicant.name)
     self.assertEqual(data[self.applicant.id]['redlisted'], True)
示例#5
0
 def test_applicant_name(self):
     response = get_ids_to_names(
         [self.applicant.id],
         current_user=self.admin,
     )
     self.applicant.redlisted = False
     db.session.commit()
     self.assertIn('info', response)
     data = response['info']
     self.assertIn(self.applicant.id, data)
     self.assertEqual(data[self.applicant.id]['name'], self.applicant.name)
     self.assertEqual(data[self.applicant.id]['redlisted'], False)
示例#6
0
 def test_no_not_applicant_access(self):
     with self.assertRaises(ForbiddenException):
         get_ids_to_names([self.applicant.id],
                          current_user=self.not_applicant)