django-easy-audit icon indicating copy to clipboard operation
django-easy-audit copied to clipboard

Exception When running tests

Open devtoro opened this issue 3 years ago • 6 comments

I have a Django (v 3.2.12 - Python 3.8) app and django-easy-audit version 1.3.2. Although in general everything is working fine, when I am running the test suit (django.test) I get the following exception:

psycopg2.errors.UndefinedTable: relation "easyaudit_crudevent" does not exist

In my understanding, the table is not created at the point of the execution of the test. I have added the following dependency to my initial migration:

dependencies = [ ("easyaudit", "__latest__") ]

But the error persists.

Is there anything else I can try?

devtoro avatar Feb 03 '22 12:02 devtoro

i have the same issue

hainkind avatar Feb 18 '22 10:02 hainkind

Could you please post the output of running ./manage.py migrate on an empty database?

Lukasdoe avatar Jul 23 '22 22:07 Lukasdoe

Having the same error when running tests. Will investigate and publish logs here.

samamorgan avatar May 26 '23 16:05 samamorgan

Looks like the issue was being caused by one of my data migrations that was pre-populating the database. I just had to add the following to the migration dependencies list:

    dependencies = [
        ...,
        ("easyaudit", "__latest__"),
    ]

samamorgan avatar May 26 '23 16:05 samamorgan

Can you post some logs?

And what’s the order of INSTALLED_APPS and MIDDLEWARE?

mschoettle avatar May 26 '23 22:05 mschoettle

Ended up running into the same issue. It happens when running migrate and a data migration is applied and therefore also when running tests (since migrations are run on the test database as well).

I wonder if there is a way to disable the model signals during migrations. I would prefer not to have to make the migrations depend on easyaudit.

mschoettle avatar Jul 05 '23 20:07 mschoettle