Пример #1
0
    def test_given_list_of_columns_then_returns_all_all_search_columns(self):
        table = Mock()
        column1 = Mock()
        column2 = Mock()

        config = SearchConfig(table=table,
                              columns={'column1': column1, 'column2': column2},
                              default_sort='column1')

        result = config.all_search_columns()

        assert_that(result, contains_inanyorder(column1, column2))
Пример #2
0
    def test_given_list_of_search_columns_then_returns_only_all_search_columns(self):
        table = Mock()
        column = Mock()

        config = SearchConfig(table=table,
                              columns={'column1': column, 'column2': Mock()},
                              search=['column1'],
                              default_sort='column1')

        result = config.all_search_columns()

        assert_that(result, contains(column))
Пример #3
0
    def test_that_column_for_searching_results_the_column_or_none(self):
        table = Mock()
        column1 = Mock()
        column2 = Mock()

        config = SearchConfig(table=table,
                              columns={'column1': column1, 'column2': column2},
                              default_sort='column1')

        result = config.column_for_searching('column3')

        assert_that(result, equal_to(None))
Пример #4
0
    def test_given_list_of_sort_columns_then_returns_columns_for_sorting(self):
        table = Mock()
        column = Mock()
        column2 = Mock()
        config = SearchConfig(table=table,
                              columns={'column': column,
                                       'column2': column2,
                                       'column3': Mock()},
                              sort=['column', 'column2'],
                              default_sort='column')

        result = config.column_for_sorting('column2')

        assert_that(result, equal_to(column2))
Пример #5
0
    def test_given_list_of_columns_then_returns_all_all_search_columns(self):
        table = Mock()
        column1 = Mock()
        column2 = Mock()

        config = SearchConfig(table=table,
                              columns={
                                  'column1': column1,
                                  'column2': column2
                              },
                              default_sort='column1')

        result = config.all_search_columns()

        assert_that(result, contains_inanyorder(column1, column2))
Пример #6
0
    def test_that_column_for_searching_results_the_column_or_none(self):
        table = Mock()
        column1 = Mock()
        column2 = Mock()

        config = SearchConfig(table=table,
                              columns={
                                  'column1': column1,
                                  'column2': column2
                              },
                              default_sort='column1')

        result = config.column_for_searching('column3')

        assert_that(result, equal_to(None))
Пример #7
0
    def test_given_list_of_sort_columns_then_returns_columns_for_sorting(self):
        table = Mock()
        column = Mock()
        column2 = Mock()
        config = SearchConfig(table=table,
                              columns={
                                  'column': column,
                                  'column2': column2,
                                  'column3': Mock()
                              },
                              sort=['column', 'column2'],
                              default_sort='column')

        result = config.column_for_sorting('column2')

        assert_that(result, equal_to(column2))
Пример #8
0
    def test_given_list_of_search_columns_then_returns_only_all_search_columns(
            self):
        table = Mock()
        column = Mock()

        config = SearchConfig(table=table,
                              columns={
                                  'column1': column,
                                  'column2': Mock()
                              },
                              search=['column1'],
                              default_sort='column1')

        result = config.all_search_columns()

        assert_that(result, contains(column))
Пример #9
0
    def test_given_sort_column_does_not_exist_when_sorting_then_raises_error(
            self):
        table = Mock()

        config = SearchConfig(table=table,
                              columns={'column1': 'column1'},
                              default_sort='column1')

        self.assertRaises(InputError, config.column_for_sorting, 'column2')
Пример #10
0
 def setUp(self):
     DAOTestCase.setUp(self)
     self.config = SearchConfig(table=UserFeatures,
                                columns={
                                    'lastname': UserFeatures.lastname,
                                    'firstname': UserFeatures.firstname,
                                    'simultcalls': UserFeatures.simultcalls,
                                    'userfield': UserFeatures.userfield
                                },
                                default_sort='lastname')
     self.search = SearchSystem(self.config)
Пример #11
0
# -*- coding: utf-8 -*-
# Copyright 2016 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.paging import Paging
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=Paging,
                      columns={
                          'id': Paging.id,
                          'name': Paging.name,
                          'number': Paging.number,
                          'announce_sound': Paging.announce_sound
                      },
                      default_sort='name')

paging_search = SearchSystem(config)
Пример #12
0
# -*- coding: utf-8 -*-
# Copyright 2020 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.user_external_app import UserExternalApp
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(
    table=UserExternalApp,
    columns={'name': UserExternalApp.name},
    default_sort='name',
)

user_external_app_search = SearchSystem(config)
Пример #13
0
# -*- coding: utf-8 -*-
# Copyright 2016-2021 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.incall import Incall
from xivo_dao.resources.utils.search import SearchSystem, SearchConfig

config = SearchConfig(
    table=Incall,
    columns={
        'id': Incall.id,
        'preprocess_subroutine': Incall.preprocess_subroutine,
        'greeting_sound': Incall.greeting_sound,
        'user_id': Incall.user_id,
        'description': Incall.description,
        'exten': Incall.exten,
    },
    default_sort='id',
)

incall_search = SearchSystem(config)
Пример #14
0
# -*- coding: utf-8 -*-
# Copyright (C) 2014 Avencall
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.voicemail import Voicemail
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=Voicemail,
                      columns={
                          'name': Voicemail.fullname,
                          'number': Voicemail.mailbox,
                          'email': Voicemail.email,
                          'context': Voicemail.context,
                          'language': Voicemail.language,
                          'timezone': Voicemail.tz,
                          'pager': Voicemail.pager
                      },
                      search=['name', 'number', 'email', 'pager'],
                      default_sort='number')

voicemail_search = SearchSystem(config)
Пример #15
0
# -*- coding: utf-8 -*-
# Copyright 2020 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.pjsip_transport import PJSIPTransport
from xivo_dao.resources.utils.search import SearchConfig, SearchSystem

config = SearchConfig(
    table=PJSIPTransport,
    columns={
        'uuid': PJSIPTransport.uuid,
        'name': PJSIPTransport.name,
    },
    search={'name': PJSIPTransport.name},
    default_sort='name',
)
transport_search = SearchSystem(config)
Пример #16
0
    def test_given_no_columns_when_sorting_then_raises_error(self):
        table = Mock()

        config = SearchConfig(table=table, columns={}, default_sort='nothing')

        self.assertRaises(InputError, config.column_for_sorting, 'toto')
Пример #17
0
# -*- coding: utf-8 -*-
# Copyright 2018 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.useriax import UserIAX
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=UserIAX,
                      columns={
                          'name': UserIAX.name,
                          'type': UserIAX.type,
                          'host': UserIAX.host
                      },
                      default_sort='name')

iax_search = SearchSystem(config)
Пример #18
0
# -*- coding: utf-8 -*-
# Copyright 2020 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.tenant import Tenant
from xivo_dao.resources.utils.search import (
    SearchConfig,
    SearchSystem,
)

config = SearchConfig(
    table=Tenant,
    columns={
        'uuid': Tenant.uuid,
    },
    default_sort='uuid',
)

tenant_search = SearchSystem(config)
Пример #19
0
# -*- coding: utf-8 -*-
# Copyright 2018 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.agentfeatures import AgentFeatures as Agent
from xivo_dao.resources.utils.search import SearchSystem, SearchConfig

config = SearchConfig(table=Agent,
                      columns={
                          'id': Agent.id,
                          'firstname': Agent.firstname,
                          'lastname': Agent.lastname,
                          'number': Agent.number,
                          'preprocess_subroutine': Agent.preprocess_subroutine
                      },
                      default_sort='id')

agent_search = SearchSystem(config)
Пример #20
0
# -*- coding: utf-8 -*-
# Copyright 2017 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.staticiax import StaticIAX as RegisterIAX
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=RegisterIAX,
                      columns={'id': RegisterIAX.id},
                      default_sort='id')


class RegisterIAXSearchSystem(SearchSystem):
    def search(self, session, parameters=None):
        query = session.query(
            self.config.table).filter(RegisterIAX.var_name == 'register')
        return self.search_from_query(query, parameters)


register_iax_search = RegisterIAXSearchSystem(config)
Пример #21
0
# -*- coding: utf-8 -*-
# Copyright (C) 2015-2016 Avencall
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.usercustom import UserCustom
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=UserCustom,
                      columns={
                          'id': UserCustom.id,
                          'interface': UserCustom.interface,
                          'context': UserCustom.context
                      },
                      default_sort='interface')

custom_search = SearchSystem(config)
Пример #22
0
# -*- coding: utf-8 -*-
# Copyright 2017 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.schedule import Schedule
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=Schedule,
                      columns={
                          'id': Schedule.id,
                          'name': Schedule.name,
                          'timezone': Schedule.timezone
                      },
                      default_sort='name')

schedule_search = SearchSystem(config)
Пример #23
0
# -*- coding: utf-8 -*-
# Copyright (C) 2015 Avencall
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.sccpline import SCCPLine
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig


config = SearchConfig(table=SCCPLine,
                      columns={'id': SCCPLine.id},
                      default_sort='id')

sccp_search = SearchSystem(config)
Пример #24
0
# -*- coding: utf-8 -*-
# Copyright 2016-2021 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.trunkfeatures import TrunkFeatures as Trunk
from xivo_dao.resources.utils.search import SearchSystem, SearchConfig


config = SearchConfig(
    table=Trunk,
    columns={
        'id': Trunk.id,
        'context': Trunk.context,
        'description': Trunk.description,
        'name': Trunk.name,
        'label': Trunk.label,
    },
    default_sort='id',
)

trunk_search = SearchSystem(config)
Пример #25
0
from sqlalchemy.sql import and_, cast
from sqlalchemy.sql.sqltypes import String
from xivo_dao.alchemy.switchboard import Switchboard
from xivo_dao.alchemy.incall import Incall
from xivo_dao.alchemy.dialaction import Dialaction
from xivo_dao.resources.utils.search import SearchSystem, SearchConfig

config = SearchConfig(
    table=Switchboard,
    columns={
        "name": Switchboard.name,
        "exten": Incall.exten,
    },
    search=[
        "name",
        "exten",
    ],
    sort=[
        "name",
    ],
    default_sort="name",
)


class SwitchboardSearchSystem(SearchSystem):
    def _search_on_extension(self, query):
        return (query.outerjoin(
            Dialaction,
            and_(
                Dialaction.action == "switchboard",
Пример #26
0
# -*- coding: utf-8 -*-
# Copyright 2015-2020 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.endpoint_sip import EndpointSIP
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig


config = SearchConfig(
    table=EndpointSIP,
    columns={
        'name': EndpointSIP.name,
        'asterisk_id': EndpointSIP.asterisk_id,
        'label': EndpointSIP.label,
        'template': EndpointSIP.template,
    },
    default_sort='label',
)

sip_search = SearchSystem(config)
Пример #27
0
# -*- coding: utf-8 -*-
# Copyright (C) 2016 Avencall
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.outcall import Outcall
from xivo_dao.resources.utils.search import (SearchSystem, SearchConfig)

config = SearchConfig(table=Outcall,
                      columns={
                          'id': Outcall.id,
                          'description': Outcall.description,
                          'name': Outcall.name,
                          'preprocess_subroutine':
                          Outcall.preprocess_subroutine
                      },
                      default_sort='id')

outcall_search = SearchSystem(config)
Пример #28
0
# -*- coding: utf-8 -*-
# Copyright 2018-2021 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.queuefeatures import QueueFeatures
from xivo_dao.resources.utils.search import SearchSystem, SearchConfig

config = SearchConfig(
    table=QueueFeatures,
    columns={
        'id': QueueFeatures.id,
        'name': QueueFeatures.name,
        'label': QueueFeatures.label,
        'preprocess_subroutine': QueueFeatures.preprocess_subroutine,
        'exten': QueueFeatures.exten,
    },
    default_sort='id',
)

queue_search = SearchSystem(config)
Пример #29
0
# -*- coding: utf-8 -*-
# Copyright 2016-2021 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.context import Context
from xivo_dao.resources.utils.search import SearchSystem, SearchConfig

config = SearchConfig(
    table=Context,
    columns={
        'id': Context.id,
        'description': Context.description,
        'name': Context.name,
        'label': Context.label,
        'type': Context.type,
    },
    default_sort='id',
)

context_search = SearchSystem(config)
Пример #30
0
# -*- coding: utf-8 -*-
# Copyright (C) 2016 Avencall
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.rightcall import RightCall as CallPermission
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=CallPermission,
                      columns={
                          'id': CallPermission.id,
                          'name': CallPermission.name,
                          'description': CallPermission.description,
                          'enabled': CallPermission.enabled,
                          'mode': CallPermission.mode
                      },
                      default_sort='name')

call_permission_search = SearchSystem(config)
Пример #31
0
from xivo_dao.alchemy.extension import Extension
from xivo_dao.alchemy.line_extension import LineExtension
from sqlalchemy.sql.elements import and_
from xivo_dao.alchemy.linefeatures import LineFeatures
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(
    table=LineFeatures,
    columns={
        'context': LineFeatures.context,
        'provisioning_code': LineFeatures.provisioningid,
        'provisioning_extension': LineFeatures.provisioningid,
        'position': LineFeatures.num,
        'device_slot': LineFeatures.num,
        'protocol': LineFeatures.protocol,
        'device_id': LineFeatures.device,
        'name': LineFeatures.name,
        'caller_id_name': LineFeatures.caller_id_name,
        'caller_id_num': LineFeatures.caller_id_num,
        'exten': Extension.exten,
    },
    default_sort='name',
)


class LineSearchSystem(SearchSystem):
    def search_from_query(self, query, parameters):
        query = self._search_on_extension(query)
        return super(LineSearchSystem,
                     self).search_from_query(query, parameters)
Пример #32
0
# -*- coding: utf-8 -*-
# Copyright 2014-2018 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.extension import Extension
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=Extension,
                      columns={
                          'exten': Extension.exten,
                          'context': Extension.context,
                          'feature': Extension.feature,
                          'is_feature': Extension.is_feature,
                          'type': Extension.context_type
                      },
                      default_sort='exten')

extension_search = SearchSystem(config)
Пример #33
0
# -*- coding: utf-8 -*-
# Copyright 2018 The Wazo Authors  (see the AUTHORS file)
# SPDX-License-Identifier: GPL-3.0-or-later

from xivo_dao.alchemy.queueskill import QueueSkill
from xivo_dao.resources.utils.search import SearchSystem
from xivo_dao.resources.utils.search import SearchConfig

config = SearchConfig(table=QueueSkill,
                      columns={
                          'id': QueueSkill.id,
                          'name': QueueSkill.name,
                          'category': QueueSkill.category,
                          'description': QueueSkill.description,
                      },
                      default_sort='name')

skill_search = SearchSystem(config)
Пример #34
0
config = SearchConfig(
    table=UserFeatures,
    columns={
        'id': UserFeatures.id,
        'uuid': UserFeatures.uuid,
        'firstname': UserFeatures.firstname,
        'lastname': UserFeatures.lastname,
        'fullname': (UserFeatures.firstname + " " + UserFeatures.lastname),
        'caller_id': UserFeatures.callerid,
        'description': UserFeatures.description,
        'userfield': UserFeatures.userfield,
        'email': UserFeatures.email,
        'mobile_phone_number': UserFeatures.mobilephonenumber,
        'music_on_hold': UserFeatures.musiconhold,
        'outgoing_caller_id': UserFeatures.outcallerid,
        'preprocess_subroutine': UserFeatures.preprocess_subroutine,
        'voicemail_number': Voicemail.mailbox,
        'provisioning_code': LineFeatures.provisioning_code,
        'exten': Extension.exten,
        'extension': Extension.exten,
        'context': Extension.context,
        'username': UserFeatures.loginclient,
        'enabled': UserFeatures.enabled
    },
    search=[
        'fullname', 'caller_id', 'description', 'userfield', 'email',
        'mobile_phone_number', 'preprocess_subroutine', 'outgoing_caller_id',
        'exten', 'username', 'provisioning_code'
    ],
    default_sort='lastname')