当前位置: 首页>>代码示例>>Python>>正文


Python Autocompleter.remove_all方法代码示例

本文整理汇总了Python中autocompleter.Autocompleter.remove_all方法的典型用法代码示例。如果您正苦于以下问题:Python Autocompleter.remove_all方法的具体用法?Python Autocompleter.remove_all怎么用?Python Autocompleter.remove_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在autocompleter.Autocompleter的用法示例。


在下文中一共展示了Autocompleter.remove_all方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_dict_store_and_remove_all_basic_with_caching

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
    def test_dict_store_and_remove_all_basic_with_caching(self):
        """
        Storing and removing items all at once works with caching turned on on dict ac
        """
        # Let's turn on caching because that will store things in Redis and we want to make
        # sure we clean them up.
        setattr(auto_settings, 'CACHE_TIMEOUT', 3600)

        autocomp = Autocompleter("metric")
        autocomp.store_all()

        keys = self.redis.hkeys('djac.test.metric')
        self.assertEqual(len(keys), 8)

        autocomp = Autocompleter("metric")
        for i in range(0, 3):
            autocomp.suggest('m')
            autocomp.suggest('e')
            autocomp.exact_suggest('PE Ratio TTM')
            autocomp.exact_suggest('Market Cap')

        autocomp.remove_all()

        keys = self.redis.keys('djac.test.metric*')
        self.assertEqual(len(keys), 0)

        # Must set the setting back to where it was as it will persist
        setattr(auto_settings, 'CACHE_TIMEOUT', 0)
开发者ID:jb076,项目名称:django-autocompleter,代码行数:30,代码来源:test_storage.py

示例2: MultiExactMatchTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class MultiExactMatchTestCase(AutocompleterTestCase):
    fixtures = ['stock_test_data_small.json', 'indicator_test_data_small.json']

    def setUp(self):
        super(MultiExactMatchTestCase, self).setUp()
        setattr(auto_settings, 'MAX_EXACT_MATCH_WORDS', 10)

        self.autocomp = Autocompleter("mixed")
        self.autocomp.store_all()
        

    def tearDown(self):
        setattr(auto_settings, 'MAX_EXACT_MATCH_WORDS', 0)
        self.autocomp.remove_all()

    def test_exact_suggest(self):
        """
        Exact matching works in multi-provider autocompleters
        """
        matches = self.autocomp.exact_suggest('ma')
        self.assertEqual(len(matches['stock']), 1)

        matches = self.autocomp.exact_suggest('US Unemployment Rate')
        self.assertEqual(len(matches['ind']), 1)

    def test_move_exact_matches_to_top(self):
        """
        MOVE_EXACT_MATCHES_TO_TOP works in multi-provider autocompleters
        """
        matches = self.autocomp.suggest('Ma')
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', True)
        matches2 = self.autocomp.suggest('Ma')
        self.assertNotEqual(matches['stock'][0]['search_name'], matches2['stock'][0]['search_name'])
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', False)
开发者ID:jb076,项目名称:django-autocompleter,代码行数:36,代码来源:test_exact.py

示例3: MultiMatchingPerfTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class MultiMatchingPerfTestCase(AutocompleterTestCase):
    fixtures = ['stock_test_data.json', 'indicator_test_data.json']
    num_iterations = 1000

    def setUp(self):
        self.autocomp = Autocompleter("mixed")
        self.autocomp.store_all()

    def tearDown(self):
        self.autocomp.remove_all()

    def test_repeated_matches(self):
        """
        Matching is fast
        """
        setattr(auto_settings, 'MATCH_OUT_OF_ORDER_WORDS', True)
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', True)

        for i in range(1, self.num_iterations):
            self.autocomp.suggest('ma')

        for i in range(1, self.num_iterations):
            self.autocomp.suggest('price consumer')

        for i in range(1, self.num_iterations):
            self.autocomp.suggest('a')

        for i in range(1, self.num_iterations):
            self.autocomp.suggest('non revolving')

        # Must set the setting back to where it was as it will persist
        setattr(auto_settings, 'MATCH_OUT_OF_ORDER_WORDS', False)
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', True)
开发者ID:pombredanne,项目名称:django-autocompleter,代码行数:35,代码来源:test_perf.py

示例4: IndicatorAliasedMatchTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class IndicatorAliasedMatchTestCase(AutocompleterTestCase):
    fixtures = ['indicator_test_data_small.json']

    def setUp(self):
        self.autocomp = Autocompleter("indicator_aliased")
        self.autocomp.store_all()
        super(IndicatorAliasedMatchTestCase, self).setUp()

    def tearDown(self):
        self.autocomp.remove_all()

    def test_aliasing(self):
        """
        Various permutations of aliased matching work
        """
        matches = self.autocomp.suggest('us consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('united states consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('us cpi')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('united states consumer price index')
        self.assertNotEqual(len(matches), 0)
开发者ID:pombredanne,项目名称:django-autocompleter,代码行数:28,代码来源:test_matching.py

示例5: test_store_and_remove_all_basic_with_caching

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
    def test_store_and_remove_all_basic_with_caching(self):
        """
        Storing and removing items all the once works with caching turned on
        """
        # Let's turn on caching because that will store things in Redis and we want to make
        # sure we clean them up.
        setattr(auto_settings, 'CACHE_TIMEOUT', 3600)

        autocomp = Autocompleter("stock")

        autocomp.store_all()
        keys = self.redis.hkeys('djac.stock')
        self.assertEqual(len(keys), 101)

        autocomp = Autocompleter("stock")
        for i in range(0, 3):
            autocomp.suggest('a')
            autocomp.suggest('z')
            autocomp.exact_suggest('aapl')
            autocomp.exact_suggest('xyz')

        autocomp.remove_all()
        keys = self.redis.keys('djac.stock*')
        self.assertEqual(len(keys), 0)

        # Must set the setting back to where it was as it will persist
        setattr(auto_settings, 'CACHE_TIMEOUT', 0)
开发者ID:pombredanne,项目名称:django-autocompleter,代码行数:29,代码来源:test_storage.py

示例6: test_facet_match_with_move_exact_matches

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
    def test_facet_match_with_move_exact_matches(self):
        """
        Exact matching still works with facet suggest
        """
        setattr(auto_settings, 'MAX_EXACT_MATCH_WORDS', 10)
        temp_autocomp = Autocompleter('faceted_stock')
        temp_autocomp.store_all()

        facets = [
            {
                'type': 'or',
                'facets': [
                    {'key': 'sector', 'value': 'Technology'},
                    {'key': 'industry', 'value': 'Software'}
                ]
            }
        ]

        matches = temp_autocomp.suggest('Ma', facets=facets)
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', True)
        matches2 = temp_autocomp.suggest('Ma', facets=facets)
        self.assertNotEqual(matches[0]['search_name'], matches2[0]['search_name'])

        # Must set the setting back to where it was as it will persist
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', False)
        temp_autocomp.remove_all()
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:28,代码来源:test_matching.py

示例7: IndicatorAliasedMatchTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class IndicatorAliasedMatchTestCase(AutocompleterTestCase):
    fixtures = ['indicator_test_data_small.json']

    def setUp(self):
        super(IndicatorAliasedMatchTestCase, self).setUp()
        self.autocomp = Autocompleter("indicator_aliased")
        self.autocomp.store_all()

    def tearDown(self):
        self.autocomp.remove_all()

    def test_basic_aliasing(self):
        """
        Various permutations of aliased matching work
        """
        matches = self.autocomp.suggest('us consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('united states consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('us cpi')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('united states consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('u s a consumer price index')
        self.assertNotEqual(len(matches), 0)

    def test_alias_list_creation(self):
        """
        Alias lists have replacement char variations
        """
        provider = registry._providers_by_ac["indicator_aliased"][0]
        aliases = provider.get_norm_phrase_aliases()
        usa_aliases = aliases['usa']
        self.assertTrue('u sa' in usa_aliases)
        self.assertTrue('us a' in usa_aliases)
        self.assertTrue('u s a' in usa_aliases)
        self.assertFalse('usa' in usa_aliases)

    def test_multi_term_aliasing(self):
        matches = self.autocomp.suggest('us consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('usa consumer price index')
        self.assertNotEqual(len(matches), 0)

        matches = self.autocomp.suggest('america consumer price index')
        self.assertNotEqual(len(matches), 0)

    def test_double_aliasing(self):
        """
        Double aliasing does not happen.
        California -> CA -> Canada
        """
        matches = self.autocomp.suggest('california unemployment')
        self.assertEqual(len(matches), 1)
开发者ID:KFoxder,项目名称:django-autocompleter,代码行数:61,代码来源:test_aliasing.py

示例8: MultiMatchingTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class MultiMatchingTestCase(AutocompleterTestCase):
    fixtures = ['stock_test_data_small.json', 'indicator_test_data_small.json']

    def setUp(self):
        super(MultiMatchingTestCase, self).setUp()
        self.autocomp = Autocompleter("mixed")
        self.autocomp.store_all()

    def tearDown(self):
        self.autocomp.remove_all()

    def test_basic_match(self):
        """
        A single autocompleter can return results from multiple models.
        """
        matches = self.autocomp.suggest('Aapl')
        self.assertEqual(len(matches['stock']), 1)

        matches = self.autocomp.suggest('US Initial Claims')
        self.assertEqual(len(matches['ind']), 1)

        matches = self.autocomp.suggest('m')
        self.assertEqual(len(matches), 3)

        matches = self.autocomp.suggest('a')
        self.assertEqual(len(matches['stock']), 10)
        self.assertEqual(len(matches['ind']), 10)

    def test_min_letters_setting(self):
        """
        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)

        setattr(auto_settings, 'MIN_LETTERS', 2)
        matches = self.autocomp.suggest('a')
        self.assertEqual(matches, {})

        setattr(auto_settings, 'MIN_LETTERS', 1)

    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)
        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')
开发者ID:jb076,项目名称:django-autocompleter,代码行数:60,代码来源:test_matching.py

示例9: StockExactMatchTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class StockExactMatchTestCase(AutocompleterTestCase):
    fixtures = ['stock_test_data_small.json']

    def setUp(self):
        super(StockExactMatchTestCase, self).setUp()
        setattr(auto_settings, 'MAX_EXACT_MATCH_WORDS', 10)

        self.autocomp = Autocompleter("stock")
        self.autocomp.store_all()

    def tearDown(self):
        setattr(auto_settings, 'MAX_EXACT_MATCH_WORDS', 0)
        self.autocomp.remove_all()

    def test_exact_suggest(self):
        """
        Exact matching works
        """
        matches_symbol = self.autocomp.exact_suggest('ma')
        self.assertEqual(len(matches_symbol), 1)

    def test_move_exact_matches_to_top_setting(self):
        """
        MOVE_EXACT_MATCHES_TO_TOP works
        """
        matches = self.autocomp.suggest('Ma')
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', True)
        matches2 = self.autocomp.suggest('Ma')
        self.assertNotEqual(matches[0]['search_name'], matches2[0]['search_name'])

        # Must set the setting back to where it was as it will persist
        setattr(auto_settings, 'MOVE_EXACT_MATCHES_TO_TOP', False)

    def test_move_exact_matches_overridable_at_ac_level(self):
        """
        MOVE_EXACT_MATCHES_TO_TOP can be set at the autocompleter level
        """
        matches = self.autocomp.suggest('Ma')
        registry.set_autocompleter_setting(self.autocomp.name, 'MOVE_EXACT_MATCHES_TO_TOP', True)
        matches2 = self.autocomp.suggest('Ma')
        registry.del_autocompleter_setting(self.autocomp.name, 'MOVE_EXACT_MATCHES_TO_TOP')
        self.assertNotEqual(matches[0]['search_name'], matches2[0]['search_name'])

    def test_exact_caching(self):
        """
        Exact caching works
        """
        matches = self.autocomp.exact_suggest('aapl')

        setattr(auto_settings, 'CACHE_TIMEOUT', 3600)

        for i in range(0, 10):
            matches2 = self.autocomp.exact_suggest('aapl')

        self.assertEqual(len(matches), len(matches2))

        # Must set the setting back to where it was as it will persist
        setattr(auto_settings, 'CACHE_TIMEOUT', 0)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:60,代码来源:test_exact.py

示例10: test_exact_matches_not_stored_by_default

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
 def test_exact_matches_not_stored_by_default(self):
     """
     Exact matches are not stored by default
     """
     autocomp = Autocompleter("stock")
     autocomp.store_all()
     keys = self.redis.keys('djac.test.stock.e.*')
     self.assertEqual(len(keys), 0)
     self.assertFalse(self.redis.exists('djac.test.stock.es'))
     autocomp.remove_all()
开发者ID:jb076,项目名称:django-autocompleter,代码行数:12,代码来源:test_exact.py

示例11: DictProviderMatchingTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class DictProviderMatchingTestCase(AutocompleterTestCase):
    def setUp(self):
        super(DictProviderMatchingTestCase, self).setUp()
        self.autocomp = Autocompleter("metric")
        self.autocomp.store_all()

    def tearDown(self):
        self.autocomp.remove_all()

    def test_basic_match(self):
        matches = self.autocomp.suggest('m')
        self.assertEqual(len(matches), 1)
开发者ID:jb076,项目名称:django-autocompleter,代码行数:14,代码来源:test_matching.py

示例12: test_store_and_remove_all_basic

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
    def test_store_and_remove_all_basic(self):
        """
        Storing and removing items all at once works for a dictionary obj autocompleter.
        """
        autocomp = Autocompleter("stock")

        autocomp.store_all()
        keys = self.redis.hkeys('djac.test.stock')
        self.assertEqual(len(keys), 104)

        autocomp.remove_all()
        keys = self.redis.keys('djac.test.stock*')
        self.assertEqual(len(keys), 0)
开发者ID:ycharts,项目名称:django-autocompleter,代码行数:15,代码来源:test_storage.py

示例13: test_dict_store_and_remove_all_basic

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
    def test_dict_store_and_remove_all_basic(self):
        """
        Storing and removing items all at once works for a single-model autocompleter.
        """
        autocomp = Autocompleter("metric")

        autocomp.store_all()
        keys = self.redis.hkeys('djac.test.metric')
        self.assertEqual(len(keys), 8)

        autocomp.remove_all()
        keys = self.redis.keys('djac.test.metric')
        self.assertEqual(len(keys), 0)
开发者ID:jb076,项目名称:django-autocompleter,代码行数:15,代码来源:test_storage.py

示例14: test_store_and_remove_all_basic

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
    def test_store_and_remove_all_basic(self):
        """
        Storing and removing items all the once works for a single-model autocompleter.
        """
        autocomp = Autocompleter("stock")

        autocomp.store_all()
        keys = self.redis.hkeys('djac.stock')
        self.assertEqual(len(keys), 101)

        autocomp.remove_all()
        keys = self.redis.keys('djac.stock*')
        self.assertEqual(len(keys), 0)
开发者ID:pombredanne,项目名称:django-autocompleter,代码行数:15,代码来源:test_storage.py

示例15: CalcAutocompleteProviderTestCase

# 需要导入模块: from autocompleter import Autocompleter [as 别名]
# 或者: from autocompleter.Autocompleter import remove_all [as 别名]
class CalcAutocompleteProviderTestCase(AutocompleterTestCase):
    fixtures = ['indicator_test_data_small.json']

    def setUp(self):
        super(CalcAutocompleteProviderTestCase, self).setUp()
        self.autocomp = Autocompleter("metric_aliased")
        self.autocomp.store_all()

    def tearDown(self):
        self.autocomp.remove_all()

    def test_one_way_alias_list_creation(self):
        """
        Test that oneway alias lists are created properly
        """
        provider = registry._providers_by_ac["metric_aliased"][0]
        aliases = provider.get_norm_phrase_aliases()
        self.assertTrue('revenue' in aliases)
        self.assertFalse('turnover' in aliases)

    def test_one_way_aliasing(self):
        """
        Aliases in get_one_way_phrase_aliases are not aliased both ways.
        """
        matches = self.autocomp.suggest('revenue')
        self.assertEqual(len(matches), 1)
        matches = self.autocomp.suggest('Turnover')
        self.assertEqual(len(matches), 2)

    def test_one_way_with_two_way_alias_list_creation(self):
        """
        Two way and one way aliases are both included/treated properly
        """
        provider = registry._providers_by_ac["metric_aliased"][0]
        aliases = provider.get_norm_phrase_aliases()
        self.assertTrue('ev' in aliases)
        self.assertTrue('enterprise value' in aliases)
        self.assertTrue('revenue' in aliases)
        self.assertFalse('turnover' in aliases)

    def test_one_way_with_two_way_aliasing(self):
        """
        Aliases in get_one_way_phrase_aliases are not aliased both ways.
        """
        rev_matches = self.autocomp.suggest('revenue')
        turn_matches = self.autocomp.suggest('Turnover')
        self.assertFalse(rev_matches == turn_matches)

        ev_matches = self.autocomp.suggest('EV')
        ent_val_matches = self.autocomp.suggest('Enterprise Value')
        self.assertEqual(ev_matches, ent_val_matches)
开发者ID:KFoxder,项目名称:django-autocompleter,代码行数:53,代码来源:test_aliasing.py


注:本文中的autocompleter.Autocompleter.remove_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。