예제 #1
0
    def test_get_all_parameters(self):
        context = self.add_context()
        sip = self.add_endpoint_sip()
        line_row = self.add_line(
            context=context.name,
            registrar='default',
            endpoint_sip_uuid=sip.uuid,
            provisioningid=123456,
            num=2,
        )

        line = line_dao.get(line_row.id)

        assert_that(
            line,
            has_properties(
                id=line_row.id,
                context=context.name,
                position=2,
                provisioning_code='123456',
                endpoint_sip_uuid=sip.uuid,
                endpoint_sccp_id=none(),
                endpoint_custom_id=none(),
                registrar='default',
                tenant_uuid=self.default_tenant.uuid,
            ))
예제 #2
0
    def test_given_line_has_custom_endpoint_when_setting_caller_id_then_raises_error(self):
        custom_row = self.add_usercustom()
        line_row = self.add_line(endpoint_custom_id=custom_row.id)

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_name', "Jôhn Smith")
        self.assertRaises(InputError, setattr, line, 'caller_id_num', "1000")
예제 #3
0
    def test_given_line_has_custom_endpoint_when_getting_then_line_has_no_caller_id(self):
        custom_row = self.add_usercustom()
        line_row = self.add_line(endpoint_custom_id=custom_row.id)

        line = line_dao.get(line_row.id)

        assert_that(line, has_properties(caller_id_name=none(), caller_id_num=none()))
예제 #4
0
    def test_given_line_has_custom_endpoint_when_setting_caller_id_then_raises_error(self):
        custom_row = self.add_usercustom()
        line_row = self.add_line(protocol='custom', protocolid=custom_row.id)

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_name', "Jôhn Smith")
        self.assertRaises(InputError, setattr, line, 'caller_id_num', "1000")
예제 #5
0
    def test_given_line_has_sccp_endpoint_when_setting_caller_id_num_then_raises_error(
            self):
        sccpline_row = self.add_sccpline(cid_name="Jôhn Smith", cid_num="1000")
        line_row = self.add_line(endpoint_sccp_id=sccpline_row.id)

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_num', '2000')
예제 #6
0
    def test_given_line_has_sip_endpoint_when_setting_caller_id_to_null_then_raises_error(self):
        usersip_row = self.add_usersip(callerid='"Jôhn Smith" <1000>')
        line_row = self.add_line(protocol='sip',
                                 protocolid=usersip_row.id)

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_name', None)
        self.assertRaises(InputError, setattr, line, 'caller_id_num', None)
예제 #7
0
    def test_given_line_has_custom_endpoint_when_getting_then_line_has_no_caller_id(self):
        custom_row = self.add_usercustom()
        line_row = self.add_line(protocol='custom',
                                 protocolid=custom_row.id)

        line = line_dao.get(line_row.id)

        assert_that(line.caller_id_name, none())
        assert_that(line.caller_id_num, none())
예제 #8
0
    def test_given_line_has_sip_endpoint_when_setting_caller_id_to_null_then_raises_error(
            self):
        usersip_row = self.add_endpoint_sip(
            endpoint_section_options=[['callerid', '"Jôhn Smith" <1000>']])
        line_row = self.add_line(endpoint_sip_uuid=usersip_row.uuid)

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_name', None)
        self.assertRaises(InputError, setattr, line, 'caller_id_num', None)
예제 #9
0
    def test_endpoint_sip_relationship(self):
        sip_row = self.add_endpoint_sip()
        line_row = self.add_line(endpoint_sip_uuid=sip_row.uuid)

        line = line_dao.get(line_row.id)
        assert_that(line, equal_to(line_row))
        assert_that(line.endpoint_sip, equal_to(sip_row))
        assert_that(line.endpoint_sccp, none())
        assert_that(line.endpoint_custom, none())
예제 #10
0
    def test_given_line_has_sccp_endpoint_when_setting_caller_id_to_null_then_raises_error(self):
        sccpline_row = self.add_sccpline(cid_name="Jôhn Smith",
                                         cid_num="1000")
        line_row = self.add_line(protocol='sccp',
                                 protocolid=sccpline_row.id)

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_name', None)
        self.assertRaises(InputError, setattr, line, 'caller_id_num', None)
예제 #11
0
    def test_endpoint_custom_relationship(self):
        custom_row = self.add_usercustom()
        line_row = self.add_line(endpoint_custom_id=custom_row.id)

        line = line_dao.get(line_row.id)
        assert_that(line, equal_to(line_row))
        assert_that(line.endpoint_sip, none())
        assert_that(line.endpoint_sccp, none())
        assert_that(line.endpoint_custom, equal_to(custom_row))
예제 #12
0
    def test_given_line_has_sip_endpoint_when_getting_then_line_has_caller_id(self):
        usersip_row = self.add_usersip(callerid='"Jôhn Smith" <1000>')
        line_row = self.add_line(protocol='sip',
                                 protocolid=usersip_row.id)

        line = line_dao.get(line_row.id)

        assert_that(line.caller_id_name, equal_to("Jôhn Smith"))
        assert_that(line.caller_id_num, equal_to("1000"))
예제 #13
0
    def test_given_line_has_sccp_endpoint_when_getting_then_line_has_caller_id(self):
        sccpline_row = self.add_sccpline(cid_name="Jôhn Smith",
                                         cid_num="1000")
        line_row = self.add_line(protocol='sccp',
                                 protocolid=sccpline_row.id)

        line = line_dao.get(line_row.id)

        assert_that(line.caller_id_name, equal_to("Jôhn Smith"))
        assert_that(line.caller_id_num, equal_to("1000"))
예제 #14
0
    def test_linefeatures_name_updated_after_custom_endpoint_association(self):
        usercustom_row = self.add_usercustom()
        line_row = self.add_line()

        line = line_dao.get(line_row.id)
        line_dao.associate_endpoint_custom(line, usercustom_row)
        line_dao.edit(line)

        edited_linefeatures = self.session.query(Line).get(line_row.id)
        assert_that(edited_linefeatures.name, equal_to(usercustom_row.interface))
예제 #15
0
    def test_users_relationship(self):
        user1_row = self.add_user()
        user2_row = self.add_user()
        line_row = self.add_line()
        self.add_user_line(line_id=line_row.id, user_id=user1_row.id, main_user=False)
        self.add_user_line(line_id=line_row.id, user_id=user2_row.id, main_user=True)

        line = line_dao.get(line_row.id)
        assert_that(line, equal_to(line_row))
        assert_that(line.users, contains(user2_row, user1_row))
예제 #16
0
    def test_linefeatures_name_updated_after_sccp_endpoint_association(self):
        sccpline_row = self.add_sccpline()
        line_row = self.add_line()

        line = line_dao.get(line_row.id)
        line_dao.associate_endpoint_sccp(line, sccpline_row)
        line_dao.edit(line)

        edited_linefeatures = self.session.query(Line).get(line_row.id)
        assert_that(edited_linefeatures.name, equal_to(sccpline_row.name))
예제 #17
0
    def test_given_line_has_sccp_endpoint_when_getting_then_line_has_caller_id(
            self):
        sccpline_row = self.add_sccpline(cid_name="Jôhn Smith", cid_num="1000")
        line_row = self.add_line(endpoint_sccp_id=sccpline_row.id)

        line = line_dao.get(line_row.id)

        assert_that(
            line,
            has_properties(caller_id_name="Jôhn Smith", caller_id_num="1000"))
예제 #18
0
    def test_given_line_has_sip_endpoint_when_getting_then_line_has_caller_id(
            self):
        usersip_row = self.add_endpoint_sip(
            endpoint_section_options=[['callerid', '"Jôhn Smith" <1000>']], )
        line_row = self.add_line(endpoint_sip_uuid=usersip_row.uuid)

        line = line_dao.get(line_row.id)

        assert_that(
            line,
            has_properties(caller_id_name="Jôhn Smith", caller_id_num="1000"))
예제 #19
0
    def test_given_line_has_sccp_endpoint_when_editing_then_sccpline_updated(self):
        sccpline_row = self.add_sccpline(cid_name="Jôhn Smith", cid_num="1000")
        line_row = self.add_line(endpoint_sccp_id=sccpline_row.id)

        line = line_dao.get(line_row.id)
        line.caller_id_name = "Rôger Rabbit"

        line_dao.edit(line)

        edited_sccpline = self.session.query(SCCPLine).get(sccpline_row.id)
        assert_that(edited_sccpline.cid_name, equal_to("Rôger Rabbit"))
예제 #20
0
    def test_given_line_has_sip_endpoint_when_editing_then_usersip_updated(self):
        usersip_row = self.add_usersip(callerid='"Jôhn Smith" <1000>')
        line_row = self.add_line(protocol='sip',
                                 protocolid=usersip_row.id)

        line = line_dao.get(line_row.id)
        line.caller_id_name = "Rôger Rabbit"
        line.caller_id_num = "2000"

        line_dao.edit(line)

        edited_usersip = self.session.query(UserSIP).get(usersip_row.id)
        assert_that(edited_usersip.callerid, equal_to('"Rôger Rabbit" <2000>'))
예제 #21
0
    def test_get_multi_tenant(self):
        tenant = self.add_tenant()
        context = self.add_context(tenant_uuid=tenant.uuid)

        line_row = self.add_line(context=context.name)
        line = line_dao.get(line_row.id, tenant_uuids=[tenant.uuid])
        assert_that(line, equal_to(line_row))

        line_row = self.add_line()
        self.assertRaises(
            NotFoundError,
            line_dao.get, line_row.id, tenant_uuids=[tenant.uuid],
        )
예제 #22
0
    def test_get_minimal_parameters(self):
        line_row = self.add_line(context='default',
                                 provisioningid=123456)

        line = line_dao.get(line_row.id)

        assert_that(line.id, equal_to(line_row.id))
        assert_that(line.context, equal_to(line_row.context))
        assert_that(line.provisioning_code, equal_to('123456'))
        assert_that(line.position, equal_to(1))
        assert_that(line.endpoint, none())
        assert_that(line.endpoint_id, none())
        assert_that(line.caller_id_name, none())
        assert_that(line.caller_id_num, none())
예제 #23
0
    def test_get_all_parameters(self):
        line_row = self.add_line(context='default',
                                 protocol='sip',
                                 protocolid=1234,
                                 provisioningid=123456,
                                 num=2)

        line = line_dao.get(line_row.id)

        assert_that(line.id, equal_to(line_row.id))
        assert_that(line.context, equal_to('default'))
        assert_that(line.position, equal_to(2))
        assert_that(line.provisioning_code, '123456')
        assert_that(line.endpoint, equal_to('sip'))
        assert_that(line.endpoint_id, equal_to(1234))
예제 #24
0
    def test_given_line_has_sccp_endpoint_when_editing_then_usersip_updated(self):
        sccpline_row = self.add_sccpline(cid_name="Jôhn Smith",
                                         cid_num="1000")
        line_row = self.add_line(protocol='sccp',
                                 protocolid=sccpline_row.id)

        line = line_dao.get(line_row.id)
        line.caller_id_name = "Rôger Rabbit"
        line.caller_id_num = "2000"

        line_dao.edit(line)

        edited_sccpline = self.session.query(SCCPLine).get(sccpline_row.id)
        assert_that(edited_sccpline.cid_name, equal_to("Rôger Rabbit"))
        assert_that(edited_sccpline.cid_num, equal_to("2000"))
예제 #25
0
    def test_given_line_has_sip_endpoint_when_editing_then_endpoint_updated(self):
        usersip_row = self.add_endpoint_sip(
            endpoint_section_options=[['callerid', '"Jôhn Smith" <1000>']]
        )
        line_row = self.add_line(endpoint_sip_uuid=usersip_row.uuid)
        line_id = line_row.id
        self.session.expire(line_row)

        line = line_dao.get(line_id)
        line.caller_id_name = "Rôger Rabbit"
        line.caller_id_num = "2000"

        line_dao.edit(line)

        edited_endpoint = self.session.query(EndpointSIP).get(usersip_row.uuid)
        assert_that(edited_endpoint.caller_id, equal_to('"Rôger Rabbit" <2000>'))
예제 #26
0
    def test_edit_null_parameters(self):
        line_row = self.add_line(endpoint='sccp',
                                 endpoint_id=1234)

        line = line_dao.get(line_row.id)
        line.endpoint = None
        line.endpoint_id = None

        line_dao.edit(line)

        edited_line = self.session.query(Line).get(line_row.id)
        assert_that(edited_line.id, equal_to(line.id))
        assert_that(edited_line.endpoint, none())
        assert_that(edited_line.protocol, none())
        assert_that(edited_line.endpoint_id, none())
        assert_that(edited_line.protocolid, none())
예제 #27
0
    def test_extensions_relationship(self):
        extension1_row = self.add_extension()
        extension2_row = self.add_extension()
        line_row = self.add_line()
        self.add_line_extension(
            line_id=line_row.id,
            extension_id=extension1_row.id,
            main_extension=False,
        )
        self.add_line_extension(
            line_id=line_row.id,
            extension_id=extension2_row.id,
            main_extension=True,
        )

        line = line_dao.get(line_row.id)
        assert_that(line, equal_to(line_row))
        assert_that(line.extensions, contains(extension2_row, extension1_row))
예제 #28
0
    def test_edit_null_parameters(self):
        sccp = self.add_sccpline()
        line_row = self.add_line(endpoint_sccp_id=sccp.id)

        line = line_dao.get(line_row.id)
        line.endpoint_sccp_id = None

        line_dao.edit(line)

        edited_line = self.session.query(Line).get(line_row.id)
        assert_that(
            edited_line,
            has_properties(
                id=line.id,
                endpoint_sip_uuid=none(),
                endpoint_sccp_id=none(),
                endpoint_custom_id=none(),
            ))
예제 #29
0
    def test_edit_all_parameters(self):
        line_row = self.add_line()

        line = line_dao.get(line_row.id)
        line.context = 'mycontext'
        line.provisioning_code = '234567'
        line.position = 3
        line.registrar = 'otherregistrar'

        line_dao.edit(line)

        edited_line = self.session.query(Line).get(line_row.id)
        assert_that(
            edited_line,
            has_properties(
                id=line.id,
                context='mycontext',
                provisioning_code='234567',
                provisioningid=234567,
                position=3,
                registrar='otherregistrar',
            ))
예제 #30
0
    def test_edit_all_parameters(self):
        line_row = self.add_line()

        line = line_dao.get(line_row.id)
        line.context = 'mycontext'
        line.endpoint = 'sccp'
        line.endpoint_id = 1234
        line.provisioning_code = '234567'
        line.position = 3

        line_dao.edit(line)

        edited_line = self.session.query(Line).get(line_row.id)
        assert_that(edited_line.id, equal_to(line.id))
        assert_that(edited_line.context, equal_to('mycontext'))
        assert_that(edited_line.endpoint, equal_to('sccp'))
        assert_that(edited_line.protocol, equal_to('sccp'))
        assert_that(edited_line.endpoint_id, equal_to(1234))
        assert_that(edited_line.protocolid, equal_to(1234))
        assert_that(edited_line.provisioning_code, equal_to('234567'))
        assert_that(edited_line.provisioningid, equal_to(234567))
        assert_that(edited_line.position, equal_to(3))
예제 #31
0
def validate_line(line_extension):
    try:
        line_dao.get(line_extension.line_id)
    except NotFoundError:
        raise errors.param_not_found('line_id', 'Line')
예제 #32
0
def _validate_line_id(user_line):
    try:
        return line_dao.get(user_line.line_id)
    except NotFoundError:
        raise errors.param_not_found('line_id', 'Line')
예제 #33
0
def validate_no_device(line_id):
    line = line_dao.get(line_id)
    if line.device_id:
        raise errors.resource_associated('Line', 'Device',
                                         line_id=line_id, device_id=line.device_id)
예제 #34
0
def get_by_line_id(line_id):
    line = line_dao.get(line_id)
    return line_extension_dao.get_by_line_id(line.id)
예제 #35
0
def get_all_by_line_id(line_id):
    line = line_dao.get(line_id)
    line_extensions = line_extension_dao.find_all_by_line_id(line.id)
    incalls = incall_dao.find_all_line_extensions_by_line_id(line.id)
    return line_extensions + incalls
예제 #36
0
 def get_line_for_user(self, user_id):
     user_line = new_user_line_dao.find_main_by_user_id(user_id)
     if user_line:
         return line_dao.get(user_line.line_id)
     raise LookupError("Unable to find main user line (user_id: %s)" % user_id)
예제 #37
0
def find_resources(main_user_line):
    main_user = user_dao.get(main_user_line.user_id)
    line = line_dao.get(main_user_line.line_id)
    extension = find_extension(main_user_line.line_id)
    return main_user, line, extension
예제 #38
0
    def test_given_line_has_no_endpoint_when_setting_caller_id_then_raises_error(self):
        line_row = self.add_line()

        line = line_dao.get(line_row.id)
        self.assertRaises(InputError, setattr, line, 'caller_id_name', "Jôhn Smith")
        self.assertRaises(InputError, setattr, line, 'caller_id_num', "1000")
예제 #39
0
def get(line_id):
    return dao.get(line_id)