-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
One should run tests from src/feedback/tests
folder.
$ python manage.py test
However there are couple of problems:
1. Problem - missing alter grant
User has to have alter
privilege on all tables
./manage.py test
Creating test database for alias 'default'...
Traceback (most recent call last):
File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql, params)
File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/django/db/backends/mysql/base.py", line 73, in execute
return self.cursor.execute(query, args)
File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/MySQLdb/cursors.py", line 206, in execute
res = self._query(query)
File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/MySQLdb/cursors.py", line 319, in _query
db.query(q)
File "/home/anel/mariadb/feedback-plugin-backend/env/lib/python3.8/site-packages/MySQLdb/connections.py", line 254, in query
_mysql.connection.query(self, query)
MySQLdb._exceptions.OperationalError: (1142, "ALTER command denied to user 'feedback'@'localhost' for table 'django_content_type'")
One need to update the privilege in docker/mariadb/create_database_user.py
as it was the example for me which privilege user should have.
- Observation
After setting up thealter
privilege obtained in 1.problem, we can see that database is created (since we havecreate
priv on all tables), but we need priv ontest_feedback_plugin
- just notification about reason of having the privilege.
$ ./manage.py test
Creating test database for alias 'default'...
Got an error creating the test database: (1007, "Can't create database 'test_feedback_plugin'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_feedback_plugin', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
Got an error recreating the test database: (1044, "Access denied for user 'feedback'@'localhost' to database 'test_feedback_plugin'")
2. Problem - python 3.9 version of zoneinfo
$ ./manage.py test
Creating test database for alias 'default'...
Got an error creating the test database: (1007, "Can't create database 'test_feedback_plugin'; database exists")
Type 'yes' if you would like to try deleting the test database 'test_feedback_plugin', or 'no' to cancel: yes
Destroying old test database for alias 'default'...
System check identified no issues (0 silenced).
.....E
======================================================================
ERROR: feedback_plugin.tests.test_process_raw_data (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: feedback_plugin.tests.test_process_raw_data
Traceback (most recent call last):
File "/usr/lib/python3.8/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.8/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/home/anel/mariadb/feedback-plugin-backend/src/feedback_plugin/tests/test_process_raw_data.py", line 3, in <module>
from zoneinfo import ZoneInfo
ModuleNotFoundError: No module named 'zoneinfo'
----------------------------------------------------------------------
Ran 6 tests in 0.062s
FAILED (errors=1)
Destroying test database for alias 'default'...
Instead one should use alternative module backports.zoneinfo
Metadata
Metadata
Assignees
Labels
No labels