def users_view(): """ Users listing for dropdown. """ users = get_users() return [{'user_id': i, 'name': row['name'], 'avatar': row['avatar']} for i, row in users.items()]
def test_get_users(self): """ Test getting users """ data = utils.get_users() self.assertIsInstance(data, dict) self.assertEqual(data.keys(), ['10']) self.assertEqual(data['10'], u'Maciej Zięba')
def users_view(): """ Users listing for dropdown. """ data = get_users() return [ {'user_id': k, 'name': v['name'], 'avatar_url': v['avatar_url']} for k, v in data.items() ]
def users_view(): """ Users listing for dropdown. """ data = get_users() return [{ 'user_id': k, 'name': v['name'], 'avatar_url': v['avatar_url'] } for k, v in data.items()]
def users_view(): """ Users listing for dropdown. """ users = get_users() data = get_data() result = [{'user_id': i, 'name': users[i]} for i in users.keys() if int(i) in data.keys()] #import pdb; pdb.set_trace() result.sort(key=lambda item: item['name'], cmp=locale.strcoll) return result
def test_get_users(self): """ Test parsing of Users XML file. """ data = utils.get_users() self.assertItemsEqual(data.keys(), [10, 11, 141]) self.assertDictEqual( data[10], { 'avatar_url': 'https://intranet.stxnext.pl:443' '/api/images/users/10', 'name': 'Maciej Z.', })
def test_get_users(self): """ Test parsing of XML file. """ data = utils.get_users() self.assertIsInstance(data, list) self.assertIsInstance(data[0], dict) self.assertEqual(len(data), 7) sample_id = 141 self.assertIn(sample_id, data[0].values()) sample_url = 'https://intranet.stxnext.pl/api/images/users/141' self.assertIn(sample_url, data[0].values()) self.assertIn(u"Wojciech", data[-1]['name']) self.assertIn(u"Adam", data[0]['name'])
def test_get_users(self): """ Test parsing of Users XML file. """ data = utils.get_users() self.assertItemsEqual(data.keys(), [10, 11, 141]) self.assertDictEqual( data[10], { 'avatar_url': 'https://intranet.stxnext.pl:443' '/api/images/users/10', 'name': 'Maciej Z.', } )
def test_get_users(self): """ Test parsing of xml file with users data. """ data = utils.get_users() self.assertIsInstance(data, dict) self.assertItemsEqual(data.keys(), ['141', '176']) expexted_output = { '141': { 'name': u'Adam P.', 'avatar': 'https://intranet.stxnext.pl:443/' / 'api/images/users/141' } } self.assertEqual(expexted_output['141'], data['141'])
def test_get_user(self): """ Test for reading data from users.xml """ users = utils.get_users() users_items = users.items() self.assertEqual(len(users), 9) self.assertIsInstance(users, dict) self.assertIsInstance(users[122], dict) self.assertIn(36, users) self.assertIn(122, users) self.assertIsInstance(users[122], dict) self.assertEqual(len(users_items[1][1]), 2)
def users_json_view(): """ Users listing for dropdown. """ return utils.get_users()
def users_view_v2(): """ Users listing for api_v2 dropdown. """ users = get_users() return users
def users_view(): """ Users listing for dropdown. """ return get_users()
def test_get_user(self): """ Test for reading data from users.xml with bad entries """ with self.assertRaises(AttributeError): utils.get_users()