Ticket: Create/Update Comments InsertOneResult error

why i am getting this error.

def test_add_comment(client):
    result = add_comment(movie_id, user, comment['text'], now)
    assert isinstance(result, InsertOneResult)
    assert result.acknowledged is True
    assert result.inserted_id is not None

    comments = get_movie(movie_id).get('comments')
  assert comments[0].get('_id') == result.inserted_id

E AssertionError: assert ObjectId(‘5a9427658b0beebeb697bc39’) == ObjectId(‘5c438104b9d57900d8f80d20’)
E + where ObjectId(‘5a9427658b0beebeb697bc39’) = <built-in method get of dict object at 0x000002DE3ADB8948>(’_id’)
E + where <built-in method get of dict object at 0x000002DE3ADB8948> = {’_id’: ObjectId(‘5a9427658b0beebeb697bc39’), ‘date’: datetime.datetime(1985, 6, 16, 3, 31, 57), ‘email’: ‘blake_fitzgerald@fakegmail.com’, ‘movie_id’: ObjectId(‘573a13eff29313caabdd82f3’), …}.get
E + and ObjectId(‘5c438104b9d57900d8f80d20’) = <pymongo.results.InsertOneResult object at 0x000002DE3AD9F988>.inserted_id

The unit test takes a movie, then call add_comment(), the function we have to implement for this lab.
It then uses get_movie(), another function we had to implement and retrieves the comments. It then conclude that the test has succeeded or not be comparing the first comment to the comment that was added by add_comment().

In your case, it finds that they are not the same. I see 3 possible reasons.

  1. The added comment is not associated with the movie. So when get_movie() is called the new comment is not in the list of comments. So add_comment() is wrong.
  2. The added comment is associated with the movie, but get_movie() does not return the appropriate list of comments. So get_movie() is wrong.
  3. The added comment is associated with the movie, but some fields do not have the correct values needed by get_movie() to return the comments in the appropriate order. So add_comment() is wrong.

Yes, my get_movie() implementation was wrong. it was not sorting the comment in according to date. But in status page it was showing the Get Comments in green.
But now it is correct. Thanks