def delete_voicemail(user): try: voicemail = voicemail_dao.get(user.voicemail_id) except LookupError: return else: voicemail_dao.delete(voicemail)
def test_get_with_one_voicemail_and_all_properties(self): name = 'voicemail name' number = '42' context = 'context-42' voicemail_row = VoicemailSchema( fullname=name, mailbox=number, context=context, password='******', email='email', language='fr_FR', tz='eu-fr', maxmsg=1, attach=1, deletevoicemail=None, skipcheckpass=0 ) self.add_me(voicemail_row) voicemail = voicemail_dao.get(voicemail_row.uniqueid) self.assertEquals(voicemail.id, voicemail_row.uniqueid) self.assertEquals(voicemail.name, voicemail_row.fullname) self.assertEquals(voicemail.number, voicemail_row.mailbox) self.assertEquals(voicemail.context, voicemail_row.context) self.assertEquals(voicemail.password, voicemail_row.password) self.assertEquals(voicemail.email, voicemail_row.email) self.assertEquals(voicemail.language, voicemail_row.language) self.assertEquals(voicemail.timezone, voicemail_row.tz) self.assertEquals(voicemail.max_messages, voicemail_row.maxmsg) self.assertEquals(voicemail.attach_audio, True) self.assertEquals(voicemail.delete_messages, False) self.assertEquals(voicemail.ask_password, True)
def _associate_voicemail_with_line(session, user_voicemail): voicemail = voicemail_dao.get(user_voicemail.voicemail_id) user_lines = _find_main_user_lines(user_voicemail.user_id) for user_line in user_lines: _associate_voicemail_with_protocol(session, voicemail, user_line.line_id)
def test_get_with_one_voicemail(self): name = 'voicemail name' number = '42' context = 'context-42' voicemail_row = VoicemailSchema( context=context, mailbox=number, fullname=name, ) self.add_me(voicemail_row) voicemail_id = voicemail_row.uniqueid expected_voicemail = Voicemail( name=name, number=number, context=context, id=voicemail_id, attach_audio=False, delete_messages=False, ask_password=True ) voicemail = voicemail_dao.get(voicemail_id) self.assertEquals(expected_voicemail, voicemail)
def test_edit_with_all_parameters(self): voicemail_row = self.add_voicemail( mailbox='1000', context='default', password='******', email='email@email', language='fr_FR', tz='eu-fr', attach=0, deletevoicemail=0, maxmsg=0, skipcheckpass=0 ) voicemail = voicemail_dao.get(voicemail_row.uniqueid) voicemail.name = 'newname' voicemail.number = '1001' voicemail.password = '******' voicemail.email = '*****@*****.**' voicemail.language = 'en_US' voicemail.timezone = 'en-ca' voicemail.max_messages = 10 voicemail.attach_audio = True voicemail.delete_messages = True voicemail.ask_password = False voicemail_dao.edit(voicemail) row = (self.session.query(VoicemailSchema) .filter(VoicemailSchema.uniqueid == voicemail.id) .first()) self.assertEquals(row.uniqueid, voicemail.id) self.assertEquals(row.fullname, voicemail.name) self.assertEquals(row.mailbox, voicemail.number) self.assertEquals(row.context, voicemail.context) self.assertEquals(row.password, voicemail.password) self.assertEquals(row.email, voicemail.email) self.assertEquals(row.language, voicemail.language) self.assertEquals(row.tz, voicemail.timezone) self.assertEquals(row.maxmsg, voicemail.max_messages) self.assertEquals(row.attach, voicemail.attach_audio) self.assertEquals(row.deletevoicemail, voicemail.delete_messages) self.assertEquals(row.skipcheckpass, 1)
def test_edit(self): number = '42' context = 'default' expected_name = 'totitu' voicemail = self.add_voicemail(mailbox=number, context=context) voicemail = voicemail_dao.get(voicemail.uniqueid) voicemail.name = expected_name voicemail_dao.edit(voicemail) row = (self.session.query(VoicemailSchema) .filter(VoicemailSchema.uniqueid == voicemail.id) .first()) self.assertEquals(row.uniqueid, voicemail.id) self.assertEquals(row.fullname, expected_name) self.assertEquals(row.mailbox, number) self.assertEquals(row.context, context)
def validate_existing_number_context(voicemail): existing_voicemail = voicemail_dao.get(voicemail.id) if voicemail.number_at_context != existing_voicemail.number_at_context: validate_number_context(voicemail)
def _validate_voicemail_id(user_voicemail): try: return voicemail_dao.get(user_voicemail.voicemail_id) except NotFoundError: raise errors.param_not_found('voicemail_id', 'Voicemail')
def update_voicemail_fullname(user): if hasattr(user, 'voicemail_id') and user.voicemail_id is not None: voicemail = voicemail_dao.get(user.voicemail_id) voicemail.name = user.fullname voicemail_dao.edit(voicemail)
def get(voicemail_id): return voicemail_dao.get(voicemail_id)
def _validate_voicemail_id(user_voicemail): try: return voicemail_dao.get(user_voicemail.voicemail_id) except ElementNotExistsError: raise NonexistentParametersError(voicemail=user_voicemail.voicemail_id)