Ejemplo n.º 1
0
def main():
    cli_args = parse_cli_args()
    config = load_config()
    xivo_logging.setup_logging('/dev/null', log_level=cli_args['log_level'])
    xivo_logging.silence_loggers(['stevedore.extension'], logging.WARNING)

    tenant_uuid = get_master_tenant_uuid(config['auth'])
    init_db_from_config(config)

    wazo_uuid = info_dao.get().uuid
    bus = BusPublisher.from_config(
        config['bus'],
        wazo_uuid,
    )
    sysconfd = SysconfdPublisher.from_config(config)

    if not cli_args['authorizations_only']:
        ingress_http_service = build_ingress_http_service()
        extension_features_service = build_extension_features_service()
        meeting_service = CRUDService(
            meeting_dao,
            build_meeting_validator(),
            MeetingNotifier(
                bus,
                sysconfd,
                ingress_http_service,
                extension_features_service,
                tenant_uuid,
            ),
        )

        meeting_date_limit = datetime.now(timezone.utc) - timedelta(hours=24)
        remove_meetings_older_than(meeting_date_limit, meeting_service)

    authorization_notifier = MeetingAuthorizationNotifier(bus)
    meeting_authorization_service = build_authorization_service(
        authorization_notifier)

    meeting_authorization_date_limit = datetime.now(
        timezone.utc) - timedelta(hours=24)
    remove_meeting_authorizations_older_than(meeting_authorization_date_limit,
                                             meeting_authorization_service)

    sysconfd.flush()
    bus.flush()
Ejemplo n.º 2
0
def build_service():
    return CRUDService(call_permission_dao, build_validator(),
                       build_notifier())
Ejemplo n.º 3
0
def build_service():
    return CRUDService(external_app_dao, build_validator(), build_notifier())
Ejemplo n.º 4
0
def build_service():
    return CRUDService(outcall_dao, build_validator(), build_notifier())
Ejemplo n.º 5
0
def build_service():
    return CRUDService(context_dao, build_validator(), build_notifier())
Ejemplo n.º 6
0
class TestCRUDService(unittest.TestCase):
    def setUp(self):
        self.dao = Mock()
        self.validator = Mock()
        self.notifier = Mock()
        self.service = CRUDService(self.dao, self.validator, self.notifier)

    def test_when_searching_then_dao_is_searched(self):
        parameters = {'param': 'value'}
        expected_search_result = self.dao.search.return_value

        result = self.service.search(parameters)

        self.dao.search.assert_called_once_with(tenant_uuids=None,
                                                **parameters)
        assert_that(result, equal_to(expected_search_result))

        self.dao.search.reset_mock()
        tenant_uuids = [sentinel.tenant_uuid1, sentinel.tenant_uuid2]

        result = self.service.search(parameters, tenant_uuids=tenant_uuids)

        self.dao.search.assert_called_once_with(tenant_uuids=tenant_uuids,
                                                **parameters)

    def test_when_getting_then_resource_is_fetched_from_dao(self):
        expected_resource = self.dao.get.return_value

        result = self.service.get(sentinel.resource_id)

        self.dao.get.assert_called_once_with(sentinel.resource_id)
        assert_that(result, equal_to(expected_resource))

    def test_when_creating_then_resource_validated(self):
        self.service.create(sentinel.resource)

        self.validator.validate_create.assert_called_once_with(
            sentinel.resource)

    def test_when_creating_then_resource_created_with_dao(self):
        expected_resource = self.dao.create.return_value

        result = self.service.create(sentinel.resource)

        self.dao.create.assert_called_with(sentinel.resource)
        assert_that(result, equal_to(expected_resource))

    def test_when_creating_then_notifier_is_notified_using_resource(self):
        expected_resource = self.dao.create.return_value

        self.service.create(sentinel.resource)

        self.notifier.created.assert_called_once_with(expected_resource)

    def test_when_editing_then_resource_validated(self):
        self.service.edit(sentinel.resource)

        self.validator.validate_edit.assert_called_once_with(sentinel.resource)

    def test_when_editing_then_resource_edited_with_dao(self):
        self.service.edit(sentinel.resource)

        self.dao.edit.assert_called_with(sentinel.resource)

    def test_when_editing_then_notifier_is_notified_using_resource(self):
        self.service.edit(sentinel.resource)

        self.notifier.edited.assert_called_once_with(sentinel.resource)

    def test_when_deleting_then_resource_validated(self):
        self.service.delete(sentinel.resource)

        self.validator.validate_delete.assert_called_once_with(
            sentinel.resource)

    def test_when_deleting_then_resource_edited_with_dao(self):
        self.service.delete(sentinel.resource)

        self.dao.delete.assert_called_with(sentinel.resource)

    def test_when_deleting_then_notifier_is_notified_using_resource(self):
        self.service.delete(sentinel.resource)

        self.notifier.deleted.assert_called_once_with(sentinel.resource)
Ejemplo n.º 7
0
 def setUp(self):
     self.dao = Mock()
     self.validator = Mock()
     self.notifier = Mock()
     self.service = CRUDService(self.dao, self.validator, self.notifier)
Ejemplo n.º 8
0
def build_service():
    return CRUDService(group_dao, build_validator(), build_notifier())
Ejemplo n.º 9
0
def build_service():
    return CRUDService(register_iax_dao, build_validator(), build_notifier())
Ejemplo n.º 10
0
def build_service():
    return CRUDService(call_pickup_dao, build_validator(), build_notifier())
Ejemplo n.º 11
0
def build_service():
    return CRUDService(dao, None, None)
Ejemplo n.º 12
0
def build_service():
    return CRUDService(paging_dao, build_validator(), build_notifier())
Ejemplo n.º 13
0
def build_service():
    return CRUDService(skill_rule_dao, build_validator(), build_notifier())
Ejemplo n.º 14
0
def build_service():
    return CRUDService(call_filter_dao, build_validator(), build_notifier())
Ejemplo n.º 15
0
def build_service(notifier):
    return CRUDService(dao, build_validator(), notifier)
Ejemplo n.º 16
0
def build_service():
    return CRUDService(application_dao, build_validator(), build_notifier())