Пример #1
0
    def test_get(self):
        exten = 'sdklfj'

        expected_extension = self.add_extension(exten=exten)

        extension = extension_dao.get(expected_extension.id)

        assert_that(extension.exten, equal_to(exten))
Пример #2
0
    def test_get(self):
        exten = 'sdklfj'

        expected_extension = self.add_extension(exten=exten)

        extension = extension_dao.get(expected_extension.id)

        assert_that(extension.exten, equal_to(exten))
Пример #3
0
def build_line_for_device(device, line):
    provd_config_manager = provd_connector.config_manager()
    config = provd_config_manager.get(device.id)
    confregistrar = provd_config_manager.get(line.configregistrar)
    line_extension = line_extension_dao.find_by_line_id(line.id)
    if line_extension:
        if line.protocol == 'sip':
            extension = extension_dao.get(line_extension.extension_id)
            provd_converter.populate_sip_line(config, confregistrar, line, extension)
        elif line.protocol == 'sccp':
            provd_converter.populate_sccp_line(config, confregistrar)
Пример #4
0
def build_line_for_device(device, line):
    provd_config_manager = provd_connector.config_manager()
    config = provd_config_manager.get(device.id)
    confregistrar = provd_config_manager.get(line.configregistrar)
    line_extension = line_extension_dao.find_by_line_id(line.id)
    if line_extension:
        if line.protocol == 'sip':
            extension = extension_dao.get(line_extension.extension_id)
            provd_converter.populate_sip_line(config, confregistrar, line, extension)
        elif line.protocol == 'sccp':
            provd_converter.populate_sccp_line(config, confregistrar)
Пример #5
0
def create(session, incall):
    extension = extension_dao.get(incall.extension_id)

    incall_row = incall_db_converter.to_incall(incall, extension)
    with commit_or_abort(session, ElementCreationError, 'Incall'):
        session.add(incall_row)

    incall.id = incall_row.id

    dialaction_row = incall_db_converter.to_dialaction(incall)
    with commit_or_abort(session, ElementCreationError, 'Incall'):
        session.add(dialaction_row)

    return incall
Пример #6
0
def create(session, incall):
    extension = extension_dao.get(incall.extension_id)

    incall_row = incall_db_converter.to_incall(incall, extension)
    with commit_or_abort(session, ElementCreationError, 'Incall'):
        session.add(incall_row)

    incall.id = incall_row.id

    dialaction_row = incall_db_converter.to_dialaction(incall)
    with commit_or_abort(session, ElementCreationError, 'Incall'):
        session.add(dialaction_row)

    return incall
Пример #7
0
    def test_delete(self):
        exten = 'sdklfj'
        context = 'toto'

        expected_extension = self.add_extension(exten=exten,
                                                context=context)

        extension = extension_dao.get(expected_extension.id)

        extension_dao.delete(extension)

        row = self.session.query(ExtensionSchema).filter(ExtensionSchema.id == expected_extension.id).first()

        self.assertEquals(row, None)
Пример #8
0
    def test_delete(self):
        exten = 'sdklfj'
        context = 'toto'

        expected_extension = self.add_extension(exten=exten, context=context)

        extension = extension_dao.get(expected_extension.id)

        extension_dao.delete(extension)

        row = self.session.query(ExtensionSchema).filter(
            ExtensionSchema.id == expected_extension.id).first()

        self.assertEquals(row, None)
Пример #9
0
    def test_associate_extension(self):
        exten = '1000'
        context = 'default'
        provisioningid = 123456

        line_row = self.add_line(provisioningid=provisioningid)

        extension_row = self.add_extension(exten=exten,
                                           context=context,
                                           typeval=str(line_row.id))

        extension = extension_dao.get(extension_row.id)

        line_dao.associate_extension(extension, line_row.id)

        line_row = self.session.query(LineSchema).get(line_row.id)

        self.assertEquals(line_row.number, exten)
        self.assertEquals(line_row.context, context)
        self.assertEquals(line_row.provisioningid, provisioningid)
Пример #10
0
    def test_dissociate_extension(self):
        exten = '1000'
        context = 'default'
        type = 'user'
        provisioningid = 12

        line_row = self.add_line(context=context,
                                 provisioningid=provisioningid,
                                 number=exten)

        extension_row = self.add_extension(exten=exten,
                                           context=context,
                                           type=type,
                                           typeval=str(line_row.id))

        extension = extension_dao.get(extension_row.id)

        line_dao.dissociate_extension(extension)

        line_row = self.session.query(LineSchema).get(line_row.id)

        self.assertEquals(line_row.number, '')
        self.assertEquals(line_row.context, context)
        self.assertEquals(line_row.provisioningid, provisioningid)
Пример #11
0
def validate_extension_exists(extension):
    extension_dao.get(extension.id)
Пример #12
0
def validate_extension_available_for_edit(extension):
    existing_extension = extension_dao.get(extension.id)

    if existing_extension.exten != extension.exten or \
       existing_extension.context != extension.context:
        validate_extension_available(extension)
Пример #13
0
def validate_extension(line_extension):
    try:
        return extension_dao.get(line_extension.extension_id)
    except ElementNotExistsError:
        raise NonexistentParametersError(extension_id=line_extension.extension_id)
Пример #14
0
def dissociate_line_extension(line_extension):
    line_extension_dao.dissociate(line_extension)
    extension = extension_dao.get(line_extension.extension_id)
    remove_exten_and_context(extension)
Пример #15
0
def find_extension(line_id):
    line_extension = line_extension_dao.find_by_line_id(line_id)
    if line_extension:
        return extension_dao.get(line_extension.extension_id)
    return None
Пример #16
0
def validate_extension_available_for_edit(extension):
    existing_extension = extension_dao.get(extension.id)

    if existing_extension.exten != extension.exten or \
       existing_extension.context != extension.context:
        validate_extension_available(extension)
Пример #17
0
def dissociate_line_extension(line_extension):
    line_extension_dao.dissociate(line_extension)
    extension = extension_dao.get(line_extension.extension_id)
    remove_exten_and_context(extension)
Пример #18
0
def validate_extension(line_extension):
    try:
        extension_dao.get(line_extension.extension_id)
    except NotFoundError:
        raise errors.param_not_found('extension_id', 'Extension')
Пример #19
0
def validate_extension_exists(extension):
    extension_dao.get(extension.id)
Пример #20
0
def find_extension(line_id):
    line_extension = line_extension_dao.find_by_line_id(line_id)
    if line_extension:
        return extension_dao.get(line_extension.extension_id)
    return None