functional test fail due to pymongo library version

Bug #1952908 reported by Aymen Frikha
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MongoDB Charm
Fix Released
High
Aymen Frikha

Bug Description

Functional test is failing with this error:

2021-12-01 09:13:49 [INFO] Traceback (most recent call last):
2021-12-01 09:13:49 [INFO] File "./tests/tests_mongodb.py", line 73, in test_db_insert
2021-12-01 09:13:49 [INFO] insert_id = test_db.testcoll.insert({"assert": True})
2021-12-01 09:13:49 [INFO] File "/home/ubuntu/charm/.tox/func/lib/python3.6/site-packages/pymongo/collection.py", line 2587, in __call__
2021-12-01 09:13:49 [INFO] self.__name.split(".")[-1])
2021-12-01 09:13:49 [INFO] TypeError: 'Collection' object is not callable. If you meant to call the 'insert' method on a 'Collection' object it is failing because no such method exists.

tests/functional/requirements.txt lists pymongo without any version restriction. The error occur because the "insert" method does not exist anymore in the recent release of pymongo v4.0 (in v3.x, it did exist). Now, insert_one (the appropriate use in this case) or insert_many need to be used.

Related branches

Revision history for this message
Aymen Frikha (aym-frikha) wrote :

I'm wondering what is the best approach here, is it fixing the pymongo version in the requirement file or changing the functional test script by using insert_on or insert_many methods ?

Revision history for this message
Alvaro Uria (aluria) wrote :

This bug prevents functional tests from running, hence classified as "High".

To Aymen question, we should amend func tests to work with the latest version of pymongo. It seems to me that renaming the "insert" method to "insert_one" will be enough to make it work.

Changed in charm-mongodb:
status: New → Confirmed
importance: Undecided → High
Alvaro Uria (aluria)
Changed in charm-mongodb:
status: Confirmed → Fix Released
assignee: nobody → Aymen Frikha (aym-frikha)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.