Ejemplo n.º 1
0
 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])
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 def get(self, query):
     movies = MoviesModel().getMovieRegex(query)
     movies_dict = [doc for doc in movies]
     return http_response(200, movies_dict)
Ejemplo n.º 5
0
 def get(self, id):
     movie = MoviesModel().getByIdNew(id)
     return http_response(200, movie)
Ejemplo n.º 6
0
 def delete(self, objectId):
     MoviesModel().delete(objectId)
     return http_response(204, {"status": "movie record deleted"})
Ejemplo n.º 7
0
 def put(self, objectId):
     movie = request.get_json()
     MoviesModel().update(objectId, movie)
     return http_response(202, {"status": "movie record updated"})
Ejemplo n.º 8
0
 def get(self, objectId):
     movie = MoviesModel().getById(objectId)
     return http_response(200, movie)
Ejemplo n.º 9
0
 def post(self):
     movie = request.get_json()
     MoviesModel().insert(movie)
     return http_response(201, {"status": "movie record inserted"})
Ejemplo n.º 10
0
 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)
Ejemplo n.º 11
0
 def test_Movies_Get_By_Regex(self):
     m = MoviesModel().getMovieRegex(SAMPLE_REGEX)
     print(m.count())
     self.assertGreaterEqual(m.count(), MOVIE_LENGTH)
Ejemplo n.º 12
0
 def test_Movies_Get_ByIdNew(self):
     m = MoviesModel().getByIdNew(SAMPLE_MOVIE_ID)
     self.assertGreaterEqual(len(m.keys()), NUM_KEYS)
Ejemplo n.º 13
0
 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)
Ejemplo n.º 14
0
 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)
Ejemplo n.º 15
0
 def test_Movies_Get_By_Name(self):
     m = MoviesModel().get(SAMPLE_MOVIE_OBJECT)
     self.assertEqual(m.count(), MOVIE_LENGTH)
Ejemplo n.º 16
0
    def test_Movies_Get(self):

        m = MoviesModel().get({})
        self.assertGreaterEqual(m.count(), MOVIE_LENGTH)