201 & 400 Error for Comment Create/Update and Delete

Hello,

PASSED all the tests for (mflix) ➜ mflix-python pytest -m create_update_comments

======================================= test session starts =======================================
platform darwin – Python 3.7.3, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: /Users/asalineroj/Documents/Personal/Studies/MongoDB/M220/mflix-python, inifile:
plugins: flask-0.10.0
collected 43 items

tests/test_create_update_comments.py … [100%]

======================================= 39 tests deselected =======================================
============================= 4 passed, 39 deselected in 1.43 seconds ===

But when I try to validate on the STATUS page I get an error message saying
“Create/Update Comments: Unable to update comment”
and the following output from the terminal

127.0.0.1 - - [26/Sep/2019 17:53:58] “POST /api/v1/user/register HTTP/1.1” 201 -
127.0.0.1 - - [26/Sep/2019 17:53:59] “POST /api/v1/user/register HTTP/1.1” 201 -
127.0.0.1 - - [26/Sep/2019 17:53:59] “POST /api/v1/movies/comment HTTP/1.1” 200 -
127.0.0.1 - - [26/Sep/2019 17:54:00] “PUT /api/v1/movies/comment HTTP/1.1” 400 -
127.0.0.1 - - [26/Sep/2019 17:54:00] “PUT /api/v1/movies/comment HTTP/1.1” 400 -

The 3 tests for Deletion PASS work
mflix-python pytest -m delete_comments
============================================= test session starts =============================================
platform darwin – Python 3.7.3, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: /Users/asalineroj/Documents/Personal/Studies/MongoDB/M220/mflix-python, inifile:
plugins: flask-0.10.0
collected 43 items

tests/test_delete_comments.py … [100%]

============================================= 40 tests deselected =============================================
=================================== 3 passed, 40 deselected in 2.68 seconds

And even though the console is not showing clear error messages, I get the following message on the status page
“Delete Comments: Deletion was performed but unsuccessful”

127.0.0.1 - - [26/Sep/2019 19:47:32] “POST /api/v1/user/register HTTP/1.1” 201 -
127.0.0.1 - - [26/Sep/2019 19:47:36] “POST /api/v1/user/register HTTP/1.1” 201 -
127.0.0.1 - - [26/Sep/2019 19:47:39] “POST /api/v1/movies/comment HTTP/1.1” 200 -
127.0.0.1 - - [26/Sep/2019 19:47:40] “DELETE /api/v1/movies/comment HTTP/1.1” 200 -
127.0.0.1 - - [26/Sep/2019 19:47:41] “DELETE /api/v1/movies/comment HTTP/1.1” 200 -
127.0.0.1 - - [26/Sep/2019 19:47:43] “GET /api/v1/movies/id/573a13b7f29313caabd490b9 HTTP/1.1” 200 -

Any help is greatly appreciated

I’m having the same issue

this worked for me

{"_id": ObjectId(comment_id), ‘email’: user_email},

3 Likes

This worked for me too! Thanks Paul