0

i'm using django rest framework and mongo DB for app backend. I'm implementing a testsuite ex:

class RegisterViewSetTestCase(APITestCase):
    def setUp(self):

    def test1(self):

I'm runnig my test with the following command:

python ./manage.py test

SO test are working but an error is raise while deleting test database, this error:

Destroying test database for alias 'default'...
Traceback (most recent call last):
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\djongo\sql2mongo\query.py", line 857, in parse
    return handler(self, statement)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\djongo\sql2mongo\query.py", line 909, in _drop
    self.cli_con.drop_database(db_name)
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pymongo\mongo_client.py", line 2093, in drop_database
    self[name]._command(
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pymongo\database.py", line 641, in _command
    return sock_info.command(
           ^^^^^^^^^^^^^^^^^^
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pymongo\pool.py", line 710, in command
    return command(self, dbname, spec, secondary_ok,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pymongo\network.py", line 161, in command
    helpers._check_command_response(
  File "C:\Users\toto\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\pymongo\helpers.py", line 167, in _check_command_response
    raise OperationFailure(errmsg, code, response, max_wire_version)
pymongo.errors.OperationFailure: user is not allowed to do action [dropDatabase] on [test_EamionTest.], full error: {'ok': 0, 'errmsg': 'user is not allowed to do action [dropDatabase] on [test_EamionTest.]', 'code': 8000, 'codeName': 'AtlasError'}

It's not critical because i can run my testsuite but an help might be usefull :)

I want to know what cause this error and how to fix it

Kulasangar
  • 9,046
  • 5
  • 51
  • 82
Bobuse
  • 3
  • 3
  • as per the error suggests, probably a user/role privilege issue. https://stackoverflow.com/questions/46649390/mongoerror-user-is-not-allowed-to-do-action – Kulasangar Apr 20 '23 at 14:26
  • Thank's for your answer, but it's look like i have the correct right db access – Bobuse Apr 20 '23 at 14:43

0 Answers0