def test_get_users_xml(self): ''' Test loads users from xml file ''' data = utils.get_users_xml() self.assertIsInstance(data, dict) self.assertItemsEqual(data.keys(), [141, 176, 170, 10, 11]) self.assertDictEqual(data[10], { u'name': u'Maciej Zięba', u'avatar': u'https://intranet.stxnext.pl/api/images/users/10' })
def users_v2_view(): """ Users listing for dropdown. """ data = get_data() data_xml = get_users_xml() result = [] for i in data.keys(): try: name = data_xml[i]['name'] avatar = data_xml[i]['avatar'] except KeyError: log.debug('User %d don\'t have name.', i, exc_info=True) else: result.append({'user_id': i, 'name': name, 'avatar': avatar}) locale.setlocale(locale.LC_ALL, 'pl_PL.UTF-8') result_sorted = sorted( result, key=lambda k: k["name"], cmp=locale.strcoll ) return result_sorted