def test_ac_provider_specific_max_results_setting(self):
        """
        Autocompleter/Provider specific MAX_RESULTS is respected
        """
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches), 10)

        registry.set_ac_provider_setting("stock", StockAutocompleteProvider, 'MAX_RESULTS', 5)
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches), 5)

        # Must set the setting back to where it was as it will persist
        registry.del_ac_provider_setting("stock", StockAutocompleteProvider, 'MAX_RESULTS')
示例#2
0
    def test_ac_provider_specific_max_results_setting(self):
        """
        Autocompleter/Provider specific MAX_RESULTS is respected
        """
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches), 10)

        registry.set_ac_provider_setting("stock", StockAutocompleteProvider, 'MAX_RESULTS', 5)
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches), 5)

        # Must set the setting back to where it was as it will persist
        registry.del_ac_provider_setting("stock", StockAutocompleteProvider, 'MAX_RESULTS')
    def test_ac_provider_specific_min_letters_setting(self):
        """
        Autocompleter/Provider specific MIN_LETTERS is respected in multi-type search case.
        """
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches['stock']), 10)
        self.assertEqual(len(matches['ind']), 10)

        registry.set_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MIN_LETTERS', 2)
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches), 10)
        self.assertEqual('ind' not in matches, True)

        registry.del_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MIN_LETTERS')
    def test_ac_provider_specific_min_letters_setting(self):
        """
        Autocompleter/Provider specific MIN_LETTERS is respected in multi-type search case.
        """
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches['stock']), 6)
        self.assertEqual(len(matches['ind']), 4)

        registry.set_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MIN_LETTERS', 2)
        registry.set_ac_provider_setting("mixed", CalcAutocompleteProvider, 'MIN_LETTERS', 2)
        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches), 10)
        self.assertEqual('ind' not in matches, True)

        registry.del_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MIN_LETTERS')
        registry.del_ac_provider_setting("mixed", CalcAutocompleteProvider, 'MIN_LETTERS')
示例#5
0
    def test_matching_with_uneven_max_results_cap_and_elasticity(self):
        """
        Test uneven redistribution of surplus result slots
        """
        registry.set_ac_provider_setting("mixed",
                                         IndicatorAutocompleteProvider,
                                         'MAX_RESULTS', 5)
        registry.set_ac_provider_setting("mixed", StockAutocompleteProvider,
                                         'MAX_RESULTS', 4)
        registry.set_ac_provider_setting("mixed", CalcAutocompleteProvider,
                                         'MAX_RESULTS', 6)

        setattr(auto_settings, 'ELASTIC_RESULTS', True)

        matches = self.autocomp.suggest('pe')
        self.assertEqual(len(matches['stock']), 5)
        self.assertEqual(len(matches['ind']), 9)
        self.assertEqual(len(matches['metric']), 1)

        setattr(auto_settings, 'ELASTIC_RESULTS', False)
        registry.del_ac_provider_setting("mixed",
                                         IndicatorAutocompleteProvider,
                                         'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", StockAutocompleteProvider,
                                         'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", CalcAutocompleteProvider,
                                         'MAX_RESULTS')
示例#6
0
    def test_matching_with_max_results_cap(self):
        """
        Test that basic matching with results limit works
        """
        registry.set_ac_provider_setting("mixed",
                                         IndicatorAutocompleteProvider,
                                         'MAX_RESULTS', 5)
        registry.set_ac_provider_setting("mixed", StockAutocompleteProvider,
                                         'MAX_RESULTS', 5)
        registry.set_ac_provider_setting("mixed", CalcAutocompleteProvider,
                                         'MAX_RESULTS', 5)

        matches = self.autocomp.suggest('pe')

        self.assertEqual(len(matches['stock']), 5)
        self.assertEqual(len(matches['ind']), 5)
        self.assertEqual(len(matches['metric']), 1)

        registry.del_ac_provider_setting("mixed",
                                         IndicatorAutocompleteProvider,
                                         'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", StockAutocompleteProvider,
                                         'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", CalcAutocompleteProvider,
                                         'MAX_RESULTS')
    def test_matching_with_max_results_cap(self):
        """
        Test that basic matching with results limit works
        """
        registry.set_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MAX_RESULTS', 5)
        registry.set_ac_provider_setting("mixed", StockAutocompleteProvider, 'MAX_RESULTS', 5)
        registry.set_ac_provider_setting("mixed", CalcAutocompleteProvider, 'MAX_RESULTS', 5)

        matches = self.autocomp.suggest('pe')

        self.assertEqual(len(matches['stock']), 5)
        self.assertEqual(len(matches['ind']), 5)
        self.assertEqual(len(matches['metric']), 1)

        registry.del_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", StockAutocompleteProvider, 'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", CalcAutocompleteProvider, 'MAX_RESULTS')
    def test_matching_with_uneven_max_results_cap_and_elasticity(self):
        """
        Test uneven redistribution of surplus result slots
        """
        registry.set_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MAX_RESULTS',5)
        registry.set_ac_provider_setting("mixed", StockAutocompleteProvider, 'MAX_RESULTS', 4)
        registry.set_ac_provider_setting("mixed", CalcAutocompleteProvider, 'MAX_RESULTS', 6)

        setattr(auto_settings, 'ELASTIC_RESULTS', True)

        matches = self.autocomp.suggest('pe')
        self.assertEqual(len(matches['stock']), 5)
        self.assertEqual(len(matches['ind']), 9)
        self.assertEqual(len(matches['metric']), 1)

        setattr(auto_settings, 'ELASTIC_RESULTS', False)
        registry.del_ac_provider_setting("mixed", IndicatorAutocompleteProvider, 'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", StockAutocompleteProvider, 'MAX_RESULTS')
        registry.del_ac_provider_setting("mixed", CalcAutocompleteProvider, 'MAX_RESULTS')