def get(self, user=None): requested_query = request.args.get('query', type = str) requested_page = request.args.get('page', default = 1, type = int) if (requested_query): response = Tmdb.search(query = requested_query, page = requested_page) if (response): response_object = Tmdb.convert_list_to_response_object(response, user) return make_response(jsonify(response_object)), 200 else: response_object = { 'status': 'fail', 'status_code': 500, 'message': 'Failed to communicate with the tmdb API.' } return make_response(jsonify(response_object)), 500 else: response_object = { 'status': 'fail', 'status_code': 404, 'message': 'You need to specify the searched term.' } return make_response(jsonify(response_object)), 404
def test_search(self): """ Testing the TMDB API search endpoint """ response = Tmdb.search('ozark') self.assertTrue(int(response.status_code) == 200) data = response.json() self.assertTrue(isinstance(data['results'], list))