def test_no_url_non_empty_registry(self):
     registry = autocomplete_light.AutocompleteRegistry()
     registry.register(AutocompleteListMock)
     exception = autocomplete_light.AutocompleteNotRegistered(
             'NotRegistered', registry)
     self.assertEqual(str(exception),
             "NotRegistered not registered, you have registered: ['AutocompleteListMock']")
    def test_lazy_autocomplete_init(self):
        registry = autocomplete_light.AutocompleteRegistry()

        try:
            self.widget_class('LazyAutocomplete', registry=registry)
        except autocomplete_light.AutocompleteNotRegistered:
            self.fail('WidgetBase initialization should not trigger registry '
                      'access')
Ejemplo n.º 3
0
    def setUp(self):
        self.admin = Client()
        self.admin.login(username='******', password='******')

        self.superuser = Client()
        self.superuser.login(username='******', password='******')

        self.anonymous = Client()

        self.registry = autocomplete_light.AutocompleteRegistry()
Ejemplo n.º 4
0
    def test_empty_registry(self):
        registry = autocomplete_light.AutocompleteRegistry()

        class ModelForm(autocomplete_light.ModelForm):
            relation = self.field_class(registry=registry,
                autocomplete=registry.register(self.model_class))
            relation2 = self.field_class(registry=registry,
                autocomplete=registry.register(self.model_class))

            class Meta(DjangoCompatMeta):
                model = self.model_class

        self.form = ModelForm()

        self.assertExpectedFormField()
        self.assertExpectedFormField('relation2')
Ejemplo n.º 5
0
    def test_empty_registry(self):
        registry = autocomplete_light.AutocompleteRegistry()

        class ModelForm(autocomplete_light.ModelForm):
            relation = self.field_class(registry=registry,
                autocomplete=registry.register(autocomplete_light.AutocompleteGenericBase,
                    choices=[self.model_class.objects.all()],
                    search_fields=['name']))

            class Meta(DjangoCompatMeta):
                model = self.model_class

        self.form = ModelForm()

        self.assertExpectedFormField()
        self.assertInForm('name')
        self.assertIsAutocomplete('noise')
    def test_lazy_autcomplete_access(self):
        registry = autocomplete_light.AutocompleteRegistry()

        widget = self.widget_class('LazyAutocomplete', registry=registry)

        try:
            widget.autocomplete
            self.fail('Should raise AutocompleteNotRegistered on unregistered '
                      'LazyAutocomplete')
        except autocomplete_light.AutocompleteNotRegistered:
            pass

        registry.register(LazyAutocomplete)
        self.assertIn('LazyAutocomplete', registry.keys())

        try:
            widget.autocomplete
        except autocomplete_light.AutocompleteNotRegistered:
            self.fail('widget.autocomplete access should not raise '
                      'AutocompleteNotRegistered')
 def test_no_url_empty_registry(self):
     exception = autocomplete_light.AutocompleteNotRegistered(
             'NotRegistered', autocomplete_light.AutocompleteRegistry())
     self.assertEqual(str(exception),
             'NotRegistered not registered (registry is empty)')
    def test_init_with_registry(self):
        registry = autocomplete_light.AutocompleteRegistry()
        registry.register(FkModel, name='TestAutocomplete')

        widget = self.widget_class('TestAutocomplete', registry=registry)
        self.assertEqual(widget.autocomplete.__name__, 'TestAutocomplete')
Ejemplo n.º 9
0
 def setUp(self):
     self.registry = autocomplete_light.AutocompleteRegistry()
Ejemplo n.º 10
0
 def setUp(self):
     self.registry = autocomplete_light.AutocompleteRegistry()
     self.registry.register(Foo)
     self.registry.register(Generic)