Ticket: Create/Update Comments error in validation

I have tried several methods and passed from the pytest without error:

(base) C:\Users\Rashidov\Desktop\mflix-python>pytest -m create_update_comments
============================= test session starts =============================
platform win32 – Python 3.8.3, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
rootdir: C:\Users\Rashidov\Desktop\mflix-python, inifile: pytest.ini
plugins: flask-0.11.0
collected 43 items

tests\test_create_update_comments.py … [100%]

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

But when it comes to get the validation key it is showing an error:

(base) C:\Users\Rashidov\Desktop\mflix-python>python run.py

  • Restarting with windowsapi reloader

  • Debugger is active!

  • Debugger PIN: 206-990-236

  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [13/Mar/2021 03:35:42] “GET / HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:45] “GET /api/v1/movies/ HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:48] “GET /api/v1/movies/facet-search?cast=Denzel%20Wash
    ington&page=0 HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:48] “GET /manifest.json HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:48] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:48] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:50] “GET /api/v1/movies/facet-search?cast=Morgan%20Free
    man&page=2 HTTP/1.1” 200 -
    127.0.0.1 - - [13/Mar/2021 03:35:54] “POST /api/v1/user/register HTTP/1.1” 400 -
    127.0.0.1 - - [13/Mar/2021 03:35:59] “POST /api/v1/user/register HTTP/1.1” 400 -
    127.0.0.1 - - [13/Mar/2021 03:35:59] “POST /api/v1/movies/comment HTTP/1.1” 422 -
    you can see my code below:
    def add_comment(movie_id, user, comment, date):
    “”"
    Inserts a comment into the comments collection, with the following fields:

    • “name”
    • “email”
    • “movie_id”
    • “text”
    • “date”

    Name and email must be retrieved from the “user” object.
    “”"

    TODO: Create/Update Comments

    Construct the comment document to be inserted into MongoDB.

    comment_doc = {
    “movie_id”: ObjectId(movie_id),
    “name”: user.name,
    “email”: user.email,
    “text”: comment,
    “date”: date
    }
    return db.comments.insert_one(comment_doc)

def update_comment(comment_id, user_email, text, date):
“”"
Updates the comment in the comment collection. Queries for the comment
based by both comment _id field as well as the email field to doubly ensure
the user has permission to edit this comment.
“”"
# TODO: Create/Update Comments
# Use the user_email and comment_id to select the proper comment, then
# update the “text” and “date” of the selected comment.
response = db.comments.update_one(
{"_id": comment_id, “email”: user_email},
{"$set": {“text”: text, “date”: date}}
)

return response

Please help!

The above prompt make me feel like you have to activated your mflix virtual environment.

Hi @BEK_Rashidov

I believe @steevej has a good observation for your command line, can you confirm if this error occurs when you have activated your virtual environment ‘mflix’ ?

Kindest regards,
Eoin