def seed(self): print("Movie seed ..") with open(self.seed_file) as json_file: data = json.load(json_file) for index in range(len(data)): movie = MoviesModel().get({'Title': data[index]['Title']}) movie = [doc for doc in movie] if (0 == len(movie)): MoviesModel().insert(data[index])
def get(self): # get all tags for all movies in DB movies = MoviesModel().get({}) movies_dict = [doc for doc in movies] tempList = [mov['Tags'] for mov in movies_dict] flatList = list(set(itertools.chain(*tempList))) return http_response(200, flatList)
def get(self, movie_id): result = MoviesModel.get_movie(movie_id) print(result) if not result: abort(404, message="Could not find video with that id") return result
def get(self, query): movies = MoviesModel().getMovieRegex(query) movies_dict = [doc for doc in movies] return http_response(200, movies_dict)
def get(self, id): movie = MoviesModel().getByIdNew(id) return http_response(200, movie)
def delete(self, objectId): MoviesModel().delete(objectId) return http_response(204, {"status": "movie record deleted"})
def put(self, objectId): movie = request.get_json() MoviesModel().update(objectId, movie) return http_response(202, {"status": "movie record updated"})
def get(self, objectId): movie = MoviesModel().getById(objectId) return http_response(200, movie)
def post(self): movie = request.get_json() MoviesModel().insert(movie) return http_response(201, {"status": "movie record inserted"})
def get(self): query_params = request.args.to_dict() movies = MoviesModel().get(query_params) movies_dict = [doc for doc in movies] return http_response(200, movies_dict)
def test_Movies_Get_By_Regex(self): m = MoviesModel().getMovieRegex(SAMPLE_REGEX) print(m.count()) self.assertGreaterEqual(m.count(), MOVIE_LENGTH)
def test_Movies_Get_ByIdNew(self): m = MoviesModel().getByIdNew(SAMPLE_MOVIE_ID) self.assertGreaterEqual(len(m.keys()), NUM_KEYS)
def test_Movies_Delete(self): inserted = MoviesModel().insert(MOVIE_OBJECT) inserted_id = inserted.inserted_id inserted = MoviesModel().delete(inserted_id) deleted = MoviesModel().getById(inserted_id) self.assertIsNone(deleted)
def test_Movies_Post(self): inserted = MoviesModel().insert(MOVIE_OBJECT) fetch_inserted = MoviesModel().getById(inserted.inserted_id) self.assertEqual(MOVIE_OBJECT["Title"], fetch_inserted["Title"]) inserted_id = inserted.inserted_id inserted = MoviesModel().delete(inserted_id)
def test_Movies_Get_By_Name(self): m = MoviesModel().get(SAMPLE_MOVIE_OBJECT) self.assertEqual(m.count(), MOVIE_LENGTH)
def test_Movies_Get(self): m = MoviesModel().get({}) self.assertGreaterEqual(m.count(), MOVIE_LENGTH)