def test_to_obj_dict_with_existing_line(self): expected_obj_dict = { 'userfeatures': { 'musiconhold': 'default', 'entityid': 2, 'enablehint': True, 'enablexfer': True, 'firstname': 'Jack', 'lastname': 'Johnson', 'language': 'en_US', 'enableclient': True, 'loginclient': 'jack', 'passwdclient': 'jack', 'profileclient': 'Agent', 'bsfilter': 'boss', 'agentid': 1, 'mobilephonenumber': '5555555555', }, 'linefeatures': { 'id': ['23'] }, 'dialaction': { 'noanswer': { 'actiontype': 'none', }, 'busy': { 'actiontype': 'none', }, 'congestion': { 'actiontype': 'none', }, 'chanunavail': { 'actiontype': 'none', } } } user = User(firstname='Jack', lastname='Johnson', language='en_US', enable_client=True, client_username='******', client_password='******', client_profile='Agent', bsfilter='boss', entity_id=2, agent_id=1, enable_hint=True, line=UserLine(id='23'), mobile_number='5555555555') obj_dict = user.to_obj_dict() self.assertEqual(expected_obj_dict, obj_dict)
def insert_adv_user_full_infos(entries): users = list() for entry in entries: mailbox = entry.get('linenumber', None) exten = entry.get('linenumber', None) context = entry.get('context', None) ule_helper.delete_user_line_extension_voicemail(entry['firstname'], entry['lastname'], exten=exten, context=context, mailbox=mailbox) incall_helper.delete_incalls_with_did(entry['incall']) user = User() user.firstname = entry['firstname'] user.lastname = entry['lastname'] user.language = 'fr_FR' user.line = UserLine() user.line.context = entry['context'] user.line.number = entry['linenumber'] user.line.secret = entry.get('linesecret', '') user.voicemail = UserVoicemail() user.voicemail.name = '%s %s' % (entry['firstname'], entry['lastname']) user.voicemail.number = entry['voicemail'] user.incall = UserIncall() user.incall.exten = entry['incall'] user.incall.context = 'from-extern' users.append(user) world.ws.users.import_(users)
def insert_adv_user_with_mevo(entries): users = list() for entry in entries: mailbox = entry.get('linenumber', None) exten = entry.get('linenumber', None) context = entry.get('context', None) ule_helper.delete_user_line_extension_voicemail(entry['firstname'], entry['lastname'], exten=exten, context=context, mailbox=mailbox) user = User() user.firstname = entry['firstname'] user.lastname = entry['lastname'] user.language = 'fr_FR' user.line = UserLine() user.line.context = entry['context'] user.line.number = entry['linenumber'] user.voicemail = UserVoicemail() user.voicemail.name = '%s %s' % (entry['firstname'], entry['lastname']) user.voicemail.number = entry['voicemail'] users.append(user) world.ws.users.import_(users)
def insert_simple_user(entries): users = list() for entry in entries: mailbox = entry.get('linenumber', None) exten = entry.get('linenumber', None) context = entry.get('context', None) ule_helper.delete_user_line_extension_voicemail(entry['firstname'], entry['lastname'], exten=exten, context=context, mailbox=mailbox) user = User() user.firstname = entry['firstname'] user.lastname = entry['lastname'] if 'enable_transfer' in entry: user.enable_transfer = entry['enable_transfer'] user.line = UserLine() user.line.context = entry['context'] user.line.number = entry['linenumber'] users.append(user) world.ws.users.import_(users)
def test_to_obj_dict(self): expected_obj_dict = { 'userfeatures': { 'musiconhold': 'default', 'entityid': 2, 'enablehint': True, 'enablexfer': True, 'firstname': 'Jack', 'lastname': 'Johnson', 'language': 'en_US', 'enableclient': True, 'loginclient': 'jack', 'passwdclient': 'jack', 'profileclient': 'Agent', 'bsfilter': 'no', 'agentid': 1, 'mobilephonenumber': '5555555555', }, 'linefeatures': { 'protocol': ['sip'], 'context': ['default'], 'number': [1000], 'device': [42], 'num': [2], 'secret': ['toto'] }, 'dialaction': { 'noanswer': { 'actiontype': 'none', }, 'busy': { 'actiontype': 'none', }, 'congestion': { 'actiontype': 'none', }, 'chanunavail': { 'actiontype': 'none', }, }, 'voicemail': { 'name': 'jack johnson', 'number': 1000, 'password': '******', 'context': 'default', } } user = User(firstname='Jack', lastname='Johnson', language='en_US', enable_client=True, client_username='******', client_password='******', client_profile='Agent', bsfilter='no', entity_id=2, agent_id=1, enable_hint=True, line=UserLine(number=1000, context='default', device_id=42, device_slot=2, secret='toto'), voicemail=UserVoicemail(number=1000, name='jack johnson', password='******', context='default'), mobile_number='5555555555') obj_dict = user.to_obj_dict() self.assertEqual(expected_obj_dict, obj_dict)
def test_from_list_obj_dict(self): obj_dict = { 'id': 4, 'entityid': 2, 'firstname': 'Jack', 'lastname': 'Johnson', "agentid": 1, "pictureid": None, "callerid": "\"Jack Johnson\"", "ringseconds": "30", "simultcalls": "5", "enableclient": False, "loginclient": "jack", "passwdclient": "johnson", "cti_profile_id": "5", "enablehint": True, "enablevoicemail": False, "enablexfer": True, "enableonlinerec": False, "callrecord": False, "incallfilter": False, "enablednd": False, "enableunc": False, "destunc": "", "enablerna": False, "destrna": "", "enablebusy": False, "destbusy": "", "musiconhold": "default", "outcallerid": "default", "mobilephonenumber": "5555555555", "userfield": "", "bsfilter": "no", "preprocess_subroutine": None, "timezone": "", "language": None, "ringintern": "", "ringextern": "", "ringgroup": "", "ringforward": "", "rightcallcode": "", "pitch": None, "pitchdirection": None, "commented": False, "description": "", "fullname": "Jack Johnson", "identity": "Jack Johnson" } user = User.from_list_obj_dict(obj_dict) self.assertEqual(user.id, 4) self.assertEqual(user.entity_id, 2) self.assertEqual(user.firstname, 'Jack') self.assertEqual(user.lastname, 'Johnson') self.assertEqual(user.enable_client, False) self.assertEqual(user.client_username, 'jack') self.assertEqual(user.client_password, 'johnson') self.assertEqual(user.client_profile_id, '5') self.assertEqual(user.agent_id, 1) self.assertEqual(user.mobile_number, '5555555555')