Backend unit test inside plugin: teardown shows django.db.utils.IntegrityError: insert or update on table "database_field" violates foreign key constraint

Two suggestions (not tested):

  • Have you tried to decorate your test with @pytest.mark.django_db(transaction=True)
  • You can also try to add a models.py file that import and export (with __all__=["field1", "field2"]) in src/baserow_vocabai_plugin, may be the content_type module needs a models.py file to work properly?

May be you can remove some code in your test to locate exactly what’s actually triggering the error to have a more precise analysis?