Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MDBF-424: Multiple problems when running the tests #5

Open
an3l opened this issue May 30, 2022 · 0 comments
Open

MDBF-424: Multiple problems when running the tests #5

an3l opened this issue May 30, 2022 · 0 comments

Comments

@an3l
Copy link
Contributor

an3l commented May 30, 2022

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 the alter privilege obtained in 1.problem, we can see that database is created (since we have create priv on all tables), but we need priv on test_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

@an3l an3l changed the title Multiple problems when running the tests MDBF-424: Multiple problems when running the tests May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant