Error running test_user_report.py

I’m running the tests for the user report and I got this error and I cannot get my around what is wrong:

client = <FlaskClient <Flask ‘mflix.factory’>>

@pytest.mark.user_report
def test_check_report(client):
    result = most_active_commenters()
  assert {'_id': 'roger_ashton-griffiths@gameofthron.es', 'count': 909} in result

E AssertionError: assert {’_id’: ‘roger_ashton-griffiths@gameofthron.es’, ‘count’: 909} in [{’_id’: ‘Mace Tyrell’, ‘count’: 909}, {’_id’: ‘Megan Richards’, ‘count’: 880}, {’_id’: ‘Bradley Brooks’, ‘count’: 880}, {’_id’: ‘Missandei’, ‘count’: 874}, {’_id’: ‘Thoros of Myr’, ‘count’: 870}, {’_id’: ‘Yara Greyjoy’, ‘count’: 868}, …]

tests/test_user_report.py:20: AssertionError

My pipeline and read_concern is like this:

pipeline = [
{’$group’: {’_id’: ‘$name’,‘count’: {’$sum’: 1}}},
{’$sort’: {‘count’: -1}},
{’$limit’: 20}
]

# you may want to change this read concern!
comments = db.comments.with_options(read_concern=ReadConcern("majority"))
result = comments.aggregate(pipeline)
return list(result)

I appreciate any help you can give me

3 Likes

Nevermind, I found my error: I put in the “_id”: ‘$name’ instead of ‘$email’

2 Likes