def test_search_services_loading_time(self):
        """websearch - speed of loading all search services"""

        # Load search services, maybe first time
        t1 = time.time()
        services = get_search_services()
        t2 = time.time()
        search_services_loading_time = t2 - t1

        # We expect search services on the demo site to be loaded
        # in any case under 10 seconds
        max_seconds_services_loading_time_first_time = 10
        if search_services_loading_time > max_seconds_services_loading_time_first_time:
            self.fail("""Loading Search services (from scratch) took too much time:
%s seconds.
Limit: %s seconds""" % (search_services_loading_time,
                        max_seconds_services_loading_time_first_time))

        # Load search services, hopefully from cache
        t1 = time.time()
        services = get_search_services()
        t2 = time.time()
        search_services_loading_time = t2 - t1

        # We expect search services on the demo site to be loaded
        # under 1 second, i.e. retrieved from cache
        max_seconds_services_loading_time_from_cache = 1
        if search_services_loading_time > max_seconds_services_loading_time_from_cache:
            self.fail("""Loading Search services from cache took too much time:
%s seconds.
Limit: %s second""" % (search_services_loading_time,
                       max_seconds_services_loading_time_from_cache))
    def test_search_services_loading_time(self):
        """websearch - speed of loading all search services"""

        # Load search services, maybe first time
        t1 = time.time()
        get_search_services()
        t2 = time.time()
        search_services_loading_time = t2 - t1

        # We expect search services on the demo site to be loaded
        # in any case under 10 seconds
        max_seconds_services_loading_time_first_time = 10
        if search_services_loading_time > max_seconds_services_loading_time_first_time:
            self.fail("""Loading Search services (from scratch) took too much time:
%s seconds.
Limit: %s seconds""" % (search_services_loading_time,
                        max_seconds_services_loading_time_first_time))

        # Load search services, hopefully from cache
        t1 = time.time()
        get_search_services()
        t2 = time.time()
        search_services_loading_time = t2 - t1

        # We expect search services on the demo site to be loaded
        # under 1 second, i.e. retrieved from cache
        max_seconds_services_loading_time_from_cache = 1
        if search_services_loading_time > max_seconds_services_loading_time_from_cache:
            self.fail("""Loading Search services from cache took too much time:
%s seconds.
Limit: %s second""" % (search_services_loading_time,
                       max_seconds_services_loading_time_from_cache))
    def test_search_services_loading(self):
        """websearch - loading default search services"""
        error_messages = []
        services_classes = [str(service.__class__) for service in get_search_services()]
        for expected_service_class in ('CollectionNameSearchService.CollectionNameSearchService',
                                       'FAQKBService.FAQKBService',
                                       'SubmissionNameSearchService.SubmissionNameSearchService'):
            if not expected_service_class in services_classes:
                error_messages.append('%s not found in list of loaded services.' % expected_service_class)

        if error_messages:
            self.fail(merge_error_messages(error_messages) + \
                      '\nList of loaded services: \n%s' % repr(services_classes))
    def test_search_services_loading(self):
        """websearch - loading default search services"""
        error_messages = []
        services_classes = [str(service.__class__)
                            for service in get_search_services()]
        for expected_service_class in (
                'CollectionNameSearchService.CollectionNameSearchService',
                'FAQKBService.FAQKBService',
                'SubmissionNameSearchService.SubmissionNameSearchService'):
            if not expected_service_class in services_classes:
                error_messages.append(
                    '%s not found in list of loaded services.' % expected_service_class)

        if error_messages:
            self.fail(merge_error_messages(error_messages) +
                      '\nList of loaded services: \n%s' % repr(services_classes))