Exemple #1
0
    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=None,
            delete_messages=False,
            ask_password=True,
            enabled=True,
            options=[]
        )

        voicemail = voicemail_dao.get(voicemail_id)

        assert_that(voicemail, equal_to(expected_voicemail))
Exemple #2
0
def delete_voicemail(user):
    try:
        voicemail = voicemail_dao.get(user.voicemail_id)
    except NotFoundError:
        return
    else:
        voicemail_dao.delete(voicemail)
Exemple #3
0
    def test_edit_with_all_parameters(self):
        expected_options = [['envelope', 'yes'],
                            ['minsecs', '10']]

        voicemail_row = self.add_voicemail(
            mailbox='1000',
            context='default',
            password='******',
            email='email@email',
            pager='pager@email',
            language='fr_FR',
            tz='eu-fr',
            attach=0,
            deletevoicemail=0,
            maxmsg=0,
            skipcheckpass=0,
            commented=0,
            options=[['saycid', 'yes']]
        )

        voicemail = voicemail_dao.get(voicemail_row.uniqueid)

        voicemail.name = 'newname'
        voicemail.number = '1001'
        voicemail.password = '******'
        voicemail.email = '*****@*****.**'
        voicemail.pager = '*****@*****.**'
        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.enabled = False
        voicemail.options = expected_options

        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.pager, voicemail.pager)
        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)
        self.assertEquals(row.commented, 1)
        self.assertEquals(row.options, expected_options)
Exemple #4
0
    def test_get_multi_tenant(self):
        tenant = self.add_tenant()
        context = self.add_context(tenant_uuid=tenant.uuid)

        voicemail_row = self.add_voicemail(context=context.name)
        voicemail = voicemail_dao.get(voicemail_row.id, tenant_uuids=[tenant.uuid])
        assert_that(voicemail, equal_to(voicemail_row))

        voicemail_row = self.add_voicemail()
        self.assertRaises(
            NotFoundError,
            voicemail_dao.get, voicemail_row.id, tenant_uuids=[tenant.uuid],
        )
Exemple #5
0
    def test_edit_set_fields_to_null(self):
        voicemail = voicemail_dao.create(
            Voicemail(
                name='MyVoicemail',
                number='1000',
                context='default',
                password='******',
                email='*****@*****.**',
                pager='12345',
                timezone='timezone',
                language='english',
                max_messages=999,
                attach_audio=False,
            )
        )

        voicemail = voicemail_dao.get(voicemail.id)
        voicemail.password = None
        voicemail.email = None
        voicemail.pager = None
        voicemail.timezone = None
        voicemail.language = None
        voicemail.max_messages = None
        voicemail.attach_audio = None

        voicemail_dao.edit(voicemail)

        row = self.session.query(Voicemail).first()
        assert_that(voicemail, equal_to(row))
        assert_that(
            row,
            has_properties(
                password=none(),
                email=none(),
                pager=none(),
                timezone=none(),
                language=none(),
                max_messages=none(),
                attach_audio=none(),
            )
        )
Exemple #6
0
    def test_get_with_one_voicemail_and_all_properties(self):
        name = 'voicemail name'
        number = '42'
        context = 'context-42'
        options = [['saycid', 'yes'],
                   ['emailsubject', 'subject']]

        voicemail_row = VoicemailSchema(
            fullname=name,
            mailbox=number,
            context=context,
            password='******',
            email='email',
            pager='pager',
            language='fr_FR',
            tz='eu-fr',
            maxmsg=1,
            attach=1,
            deletevoicemail=None,
            skipcheckpass=0,
            options=options
        )

        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.pager, voicemail_row.pager)
        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)
        self.assertEquals(voicemail.options, options)
Exemple #7
0
    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)
Exemple #8
0
    def test_edit_with_null_parameters(self):
        voicemail_row = self.add_voicemail(
            mailbox='1000',
            context='default',
            password='******',
            email='email@email',
            pager='pager@email',
            language='fr_FR',
            tz='eu-fr',
            attach=1,
            maxmsg=10,
        )

        voicemail = voicemail_dao.get(voicemail_row.uniqueid)

        voicemail.password = None
        voicemail.email = None
        voicemail.pager = None
        voicemail.language = None
        voicemail.timezone = None
        voicemail.max_messages = None
        voicemail.attach_audio = None

        voicemail_dao.edit(voicemail)

        row = (self.session.query(VoicemailSchema)
               .filter(VoicemailSchema.uniqueid == voicemail.id)
               .first())

        self.assertEquals(row.uniqueid, voicemail.id)
        self.assertEquals(row.password, '')
        self.assertEquals(row.email, None)
        self.assertEquals(row.pager, None)
        self.assertEquals(row.language, None)
        self.assertEquals(row.tz, None)
        self.assertEquals(row.maxmsg, None)
        self.assertEquals(row.attach, None)
Exemple #9
0
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)
Exemple #10
0
    def test_get(self):
        voicemail_row = self.add_voicemail()

        voicemail = voicemail_dao.get(voicemail_row.id)

        assert_that(voicemail, equal_to(voicemail_row))
Exemple #11
0
    def test_edit_all_fields(self):
        voicemail = voicemail_dao.create(
            Voicemail(
                name='MyVoicemail',
                number='1000',
                context='from-extern',
                password='******',
                email='*****@*****.**',
                pager='12345',
                timezone='timezone',
                language='english',
                options=[],
                max_messages=999,
                attach_audio=False,
                delete_messages=True,
                ask_password=False,
                enabled=False,
            )
        )

        voicemail = voicemail_dao.get(voicemail.id)
        voicemail.name = 'other_name'
        voicemail.number = '1001'
        voicemail.context = 'default'
        voicemail.password = '******'
        voicemail.email = '*****@*****.**'
        voicemail.pager = '6789'
        voicemail.timezone = 'other_timezone'
        voicemail.language = 'french'
        voicemail.options = [['option1', 'toto']]
        voicemail.max_messages = 8888
        voicemail.attach_audio = True
        voicemail.delete_messages = False
        voicemail.ask_password = True
        voicemail.enabled = True

        row = self.session.query(Voicemail).first()

        assert_that(voicemail, equal_to(row))
        assert_that(
            row,
            has_properties(
                id=is_not(none()),
                name='other_name',
                fullname='other_name',
                number='1001',
                mailbox='1001',
                context='default',
                password='******',
                email='*****@*****.**',
                pager='6789',
                timezone='other_timezone',
                tz='other_timezone',
                language='french',
                options=[['option1', 'toto']],
                max_messages=8888,
                maxmsg=8888,
                attach_audio=True,
                attach=True,
                delete_messages=False,
                deletevoicemail=False,
                ask_password=True,
                skipcheckpass=False,
                enabled=True,
                commented=False,
            )
        )