Example #1
0
from moviedataAPI import MoviesNowPlaying, MovieDirectors
from moviedataDB import MovieDatabase

db = MovieDatabase()
if db.Connect():
    movies = MoviesNowPlaying("GR")
    if movies:  # if API returned movies list
        for movie in movies:
            if db.InsertMovie(movie['id'], movie['overview'], movie['title'],
                              movie['original_title']):
                directors = MovieDirectors(movie['id'])

                if directors:  # if API returned directors list
                    for director in directors:
                        if db.InsertDirector(director['person_id'],
                                             director['full_name'],
                                             director['imdb_id']):
                            db.InsertMovieDirector(director['person_id'],
                                                   movie['id'])
        db.CleanTables()
    else:
        print "ERROR! It was impossible to obtain movies"

    db.DisConnect()
Example #2
0
 def testInsertDirectorRightInput(self):
     db = MovieDatabase()
     db.Connect()
     self.assertTrue(db.InsertDirector(1564, "Nikos Tsentis", "nm12344"),
                     msg="testInsertDirectorRightInput")
     db.DisConnect()
Example #3
0
 def testInsertDirectorWrongImdbId(self):
     db = MovieDatabase()
     db.Connect()
     self.assertFalse(db.InsertDirector("1245", "Name", None),
                      msg="testInsertDirectorWrongDescription")
     db.DisConnect()
Example #4
0
 def testInsertDirectorNoneDirectorId(self):
     db = MovieDatabase()
     db.Connect()
     self.assertFalse(db.InsertDirector(None, "Name", "IMDB"),
                      msg="testInsertDirectorNoneDirectorId")
     db.DisConnect()
Example #5
0
 def testInsertDirectorAllNull(self):
     db = MovieDatabase()
     db.Connect()
     self.assertFalse(db.InsertDirector(None, None, None),
                      msg="testInsertDirectorAllNull")
     db.DisConnect()
Example #6
0
 def testInsertDirectorWithoutName(self):
     db = MovieDatabase()
     db.Connect()
     self.assertTrue(db.InsertDirector(15632, None, "nm12344321"),
                     msg="testInsertDirectorRightInput")
     db.DisConnect()