def test_register(self):
        """
        Register/Unregister works
        """
        registry.unregister("stock", StockAutocompleteProvider)
        providers = registry.get_all_by_autocompleter("stock")
        self.assertEqual(len(providers), 0)

        # Have to leave things the way models.py init-ed them for other tests!
        registry.register("stock", StockAutocompleteProvider)
        providers = registry.get_all_by_autocompleter("stock")
        self.assertEqual(len(providers), 1)
Example #2
0
    def test_register(self):
        """
        Register/Unregister works
        """
        registry.unregister("stock", StockAutocompleteProvider)
        providers = registry.get_all_by_autocompleter("stock")
        self.assertEqual(len(providers), 0)

        # Have to leave things the way models.py init-ed them for other tests!
        registry.register("stock", StockAutocompleteProvider)
        providers = registry.get_all_by_autocompleter("stock")
        self.assertEqual(len(providers), 1)
Example #3
0
 def _get_provider(self):
     providers = registry.get_all_by_autocompleter(self.autocompleter_name)
     if not providers or len(providers) != 1:
         raise ImproperlyConfigured('The Autocompleter used by the AutocompleterDictProviderSelectWidget '
                                    'must have only 1 provider.')
     provider = providers[0]
     if not issubclass(provider, AutocompleterDictProvider):
         raise ImproperlyConfigured('The Autocompleter used by the AutocompleterDictProviderSelectWidget '
                                    'must be of type `AutocompleterDictProvider`.')
     return provider
Example #4
0
 def _get_provider(self):
     providers = registry.get_all_by_autocompleter(self.autocompleter_name)
     if not providers or len(providers) != 1:
         raise ImproperlyConfigured(
             'The Autocompleter used by the AutocompleterDictProviderSelectWidget '
             'must have only 1 provider.')
     provider = providers[0]
     if not issubclass(provider, AutocompleterDictProvider):
         raise ImproperlyConfigured(
             'The Autocompleter used by the AutocompleterDictProviderSelectWidget '
             'must be of type `AutocompleterDictProvider`.')
     return provider
Example #5
0
 def _get_all_providers_by_autocompleter(self):
     return registry.get_all_by_autocompleter(self.name)
Example #6
0
 def _get_provider_class(self, name, model):
     provider_classes = registry.get_all_by_autocompleter(name)
     for provider_class in provider_classes:
         if provider_class.model == model:
             return provider_class
     return None