I have no problem to test get_movies_by_country(countries) using jupyter providing uri, client… info like shown in the lecture and providing the syntax within the movies.find() query, the values of the len(result) for the two test cases returned are same as the assert values in test_projection.py but i am not using the ‘db’ within the return list syntax as given in the db.py file.
Below is how I tested and it worked in Jupyter:-
connection info from lecture (uri, client, mflix, movies)
return dumps(cursor, indent=2)
result = get_movies_by_country([‘xxx’])
print(len(result)) # returned values are correct for the countries specified in test_projection.py
But when I copied the above connection info and return list syntax above to the get_movies_by_country(countries) in db.py, it doesn’t work.
Do we need to supply uri, client… info to either db.py or test_projection.py script or should it automatically pick up from the .ini file we modified earlier?
Do we have to use the db from db = LocalProxy(get_db) in db.py file ?
Do we just need to modify the line by supplying the query within the find() for the return list(db.movies.find()) ?