morlandi / django-ajax-datatable

A Django app which provides the integration of a Django project with the jQuery Javascript library DataTables.net
MIT License
204 stars 64 forks source link

Unit tests issues #69

Open morlandi opened 2 years ago

morlandi commented 2 years ago

Running the unit tests from a Django project (I did this from the Example project) has been improved thanks to PR #65 contributed by @PetrDlouhy:

$ cd example
$ python manage.py test ajax_datatable

...
...
...

one: DESC
....
----------------------------------------------------------------------
Ran 9 tests in 0.936s

OK

However, I also provided a script whose purpose was to run the unit tests from withing the package itself; it used to be working, but doesn't work any more:

❯ pwd
/Users/morlandi/Projects/github_public/django-ajax-datatable

❯ python runtests.py
Traceback (most recent call last):
  File "runtests.py", line 14, in <module>
    django.setup()
  File "/Users/morlandi/.virtualenvs/django-ajax-datatable/lib/python3.8/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/morlandi/.virtualenvs/django-ajax-datatable/lib/python3.8/site-packages/django/apps/registry.py", line 91, in populate
    app_config = AppConfig.create(entry)
  File "/Users/morlandi/.virtualenvs/django-ajax-datatable/lib/python3.8/site-packages/django/apps/config.py", line 90, in create
    module = import_module(entry)
  File "/usr/local/opt/python@3.8/Frameworks/Python.framework/Versions/3.8/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'user'

Tox has problem with the same "user" table as well

❯ tox
GLOB sdist-make: /Users/morlandi/Projects/github_public/django-ajax-datatable/setup.py

...
...
...
  File "/Users/morlandi/Projects/github_public/django-ajax-datatable/.tox/py38-django-22/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/morlandi/Projects/github_public/django-ajax-datatable/.tox/py38-django-22/lib/python3.8/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/morlandi/Projects/github_public/django-ajax-datatable/.tox/py38-django-22/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "user_testuser" does not exist
LINE 1: INSERT INTO "user_testuser" ("password", "last_login", "is_s...
                    ^

A final question for @PetrDlouhy .. I noticed you switched from sqlite3/memory to postgres in test_settings. Any particular reason for this ? I would rather user sqlite to avoid creating an extra specific user for postgres needed just to run using tests. On the other side, my production project always use postgresql, so that would be more significant.