def test_lazy_model(self): class InlineModelAdmin(LazyChoiceInlineModelAdminMixin, BaseInlineModelAdmin): lazy_model = Book model = Chapter errors = run_model_admin_check(InlineModelAdmin, model=Book) self.assertEqual(errors, [])
def test_missing_lazy_model(self): class InlineModelAdmin(LazyChoiceInlineModelAdminMixin, BaseInlineModelAdmin): model = Chapter errors = run_model_admin_check(InlineModelAdmin, model=Book) expected = [ checks.Error( "The value of 'lazy_model' must be defined.", hint=None, obj=InlineModelAdmin, id='lazychoices.E101', ), ] self.assertEqual(errors, expected)
def test_invalid_lazy_model(self): class InlineModelAdmin(LazyChoiceInlineModelAdminMixin, BaseInlineModelAdmin): lazy_model = Chapter model = Chapter errors = run_model_admin_check(InlineModelAdmin, model=Book) expected = [ checks.Error( "The value of 'lazy_model' must inherit from 'LazyChoiceModelMixin'.", hint=None, obj=InlineModelAdmin, id='lazychoices.E102', ), ] self.assertEqual(errors, expected)