Example #1
0
    def test_cursor_obj_contains_expected_value(self):
        returnedValue = queries.get_books_in_genre("genre1")
        firstIndexValue = returnedValue[0]
        expectedValue = {
            "_id": "3f5468de0bfbe111586f7649a3c8d115",
            "title": "title1"
        }

        self.assertEqual(expectedValue, firstIndexValue)
Example #2
0
    def test_returned_value_is_sorted_by_id(self):
        insertions.AddBook("title2", ["author2"], genres=["genre1"])
        returnedValue = list(queries.get_books_in_genre("genre1"))
        expectedValue = [{
            "_id": "3f5468de0bfbe111586f7649a3c8d115",
            "title": "title1"
        }, {
            "_id": "5d1cb9970fd74ed9f56a867a785a358f",
            "title": "title2"
        }]

        self.assertEqual(expectedValue, returnedValue)
Example #3
0
    def test_cursor_obj_returned(self):
        returnedValue = queries.get_books_in_genre("genre1")

        self.assertIsInstance(returnedValue, Cursor)
Example #4
0
    def test_cursor_obj_contains_dicts(self):
        returnedValue = queries.get_books_in_genre("genre1")
        firstIndexValue = returnedValue[0]

        self.assertIsInstance(firstIndexValue, dict)
Example #5
0
def get_genres_books(genre):
    return_obj = list(queries.get_books_in_genre(genre))
    if not return_obj:
        abort(404)

    return jsonify(return_obj)