Text and Subfield Search: Assertion error Python

I have the correct query in my db.py under the method build_query_sort_project(), because my cluster returns the values correctly.

However, when I run the tests, I get assertion errors as below. What am I doing wrong? Can someone help.

====================================================================================== FAILURES =======================================================================================
__________________________________________________________________________________ test_genre_search __________________________________________________________________________________

client = <FlaskClient <Flask 'mflix.factory'>>

    def test_genre_search(client):
        filter = {'genres': ['Action']}
        (movies, results) = get_movies(filter, 0, 20)
        assert len(list(movies)) == 20
>       assert results == 5917
E       assert 45993 == 5917

tests/test_text_and_subfield_search.py:27: AssertionError
_____________________________________________________________________________ test_multiple_genre_search ______________________________________________________________________________

client = <FlaskClient <Flask 'mflix.factory'>>

    def test_multiple_genre_search(client):
        filter = {'genres': ['Action', 'Adventure']}
        (movies, results) = get_movies(filter, 0, 25)
        assert len(list(movies)) == 25
>       assert results == 8385
E       assert 45993 == 8385

tests/test_text_and_subfield_search.py:35: AssertionError```

Nevermind, it worked. I had an empty query={} that was overwriting my earlier query.

Hey @Aarthi_Narayan

Perhaps you could remove your answer code as it is against forum guidelines to post code. Thanks a lot and glad you got it working!

Sorry about that, when I pasted the query initially, I was under the assumption that it was an incorrect one. I’ve removed it now.

1 Like