M220P: create/update comments (ticket in Chapter 2)

I recall someone else having the same problem and it got fixed. @Kanika will sort it out.

Hi Kanika

I think I got the source of the mistake. However, I won’t be able to tackle the problem today. I guess the best thing to do is to unsubscribe to the present course and then to re-subscribe for the next edition.

Moreover, I didn’t wan’t to complain regarding your absence last week, I perfectly understand. I appreciate the offer of MongoDB with this courses, it’s great.

I’ll be back with more time available.

Kind regards,

Vinz

Please check the console for any error messages when you try to get the validation code.

Kanika

This is what I’m getting when I run the validation codes:

without seeing the rest of the code @Vinz_16012,

what is being returned? the C in crud has to be implemented for RUD to work…
Just based on what i see, as a side note, you may want to install black in your virtualenv and format your code… some IDEs get fussy when using double quotes and single quotes in the same block.

Hi, I am having the same issue. Passed validation tests but couldn’t get validation code on mflix. Got this “Create/Update Comments: Unable to update comment”

Please help. Thanks.

Test output

platform win32 – Python 3.7.4, pytest-3.3.0, py-1.8.0, pluggy-0.6.0
plugins: remotedata-0.3.2, openfiles-0.4.0, flask-0.10.0, doctestplus-0.4.0, arraydiff-0.3
collected 43 items

tests\test_create_update_comments.py … [100%]

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

C:\m220\mflix-python>python run.py

  • Restarting with stat
  • Debugger is active!
  • Debugger PIN: 140-639-943
  • Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
    127.0.0.1 - - [21/Nov/2019 22:33:00] “GET /api/v1/movies/facet-search?cast=Denzel%20Washington&page=0 HTTP/1.1” 200 -
    127.0.0.1 - - [21/Nov/2019 22:33:00] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [21/Nov/2019 22:33:00] “GET /api/v1/movies/facet-search?cast=Morgan%20Freeman&page=2 HTTP/1.1” 200 -
    127.0.0.1 - - [21/Nov/2019 22:33:00] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [21/Nov/2019 22:33:01] “GET /favicon.ico HTTP/1.1” 200 -
    127.0.0.1 - - [21/Nov/2019 22:33:07] “POST /api/v1/user/register HTTP/1.1” 201 -
    127.0.0.1 - - [21/Nov/2019 22:33:08] “POST /api/v1/user/register HTTP/1.1” 201 -
    127.0.0.1 - - [21/Nov/2019 22:33:09] “POST /api/v1/movies/comment HTTP/1.1” 200 -
    127.0.0.1 - - [21/Nov/2019 22:33:10] “PUT /api/v1/movies/comment HTTP/1.1” 400 -
    127.0.0.1 - - [21/Nov/2019 22:33:10] “PUT /api/v1/movies/comment HTTP/1.1” 400 -

Hi @harrysiu,

I have sent you a message for sharing the code.

Kanika

same issue here, for both the create/update, and delete comment tickets. my output looks the same as above posts. is there a problem with the tests? it seems that the alternative solution is to send you (@kanikasingla) a copy of those functions privately, right? thank you!

i finally figured it out. in my case, there was nothing wrong with my update_comment(), nor delete_comment() code, but there were 2 other functions that i had to tweak to get the validation codes.

for others running into this same issue, make sure that:

  • the comments returned in the mongo doc by get_movie() are sorted in descending order by date
  • movie_id in add_comment() gets converted to ObjectId
  • comment_id in update_comment() and delete_comment() is also converted to ObjectId

i really wish there were better feedback from the api, and by the way, you can get a validation code from the Get Comments ticket, even if you don’t sort the returning result, which might be the reason why there is this many posts related to this issue.

This is a great feedback @Luis_40892! Thank you so much, I will make sure to forward it to the team to see what we can do here.

Kanika