def test_people_favorites_result(self): favorites_result = { 'column_headers': [ 'Firstname', 'Lastname', 'Phone number', 'Mobile', 'Fax', 'Email', 'Agent', 'Favorite' ], 'column_types': [ None, 'name', 'number_office', 'number_mobile', 'fax', 'email', 'relation_agent', 'favorite' ], 'results': [{ 'column_values': [ 'Bob', 'Marley', '5555555', '5556666', '5553333', '*****@*****.**', None, True ], 'relations': { 'agent': None, 'user': None, 'endpoint': None }, 'source': 'my_ldap_directory' }, { 'column_values': [ 'Charlie', 'Boblin', '5555556', '5554444', '5552222', '*****@*****.**', None, True ], 'relations': { 'agent': { 'id': 12, 'xivo_id': 'ad2f36c7-b0f3-48da-a63c-37434fed479b' }, 'user': { 'id': 34, 'xivo_id': 'ad2f36c7-b0f3-48da-a63c-37434fed479b' }, 'endpoint': { 'id': 56, 'xivo_id': 'ad2f36c7-b0f3-48da-a63c-37434fed479b' }, }, 'source': 'internal' }] } result = CTIMessageFormatter.people_favorites_result(favorites_result) expected = dict(favorites_result) expected.update({'class': 'people_favorites_result'}) assert_that(result, equal_to(expected))
def _send_favorites_result(self, user_id, result): xuserid = 'xivo/{user_id}'.format(user_id=user_id) message = CTIMessageFormatter.people_favorites_result(result) self._cti_server.send_to_cti_client(xuserid, message)