def test_deleteChannel(self): program = self._createProgram(EpgProgram, 1) program.genres = [self._createProgramGenre(EpgProgramGenre, 1)] program.actors = [self._createProgramPerson(EpgProgramActor, 1)] program.directors = [self._createProgramPerson(EpgProgramDirector, 1)] program.presenters = [ self._createProgramPerson(EpgProgramPresenter, 1) ] program.addToDb(self.db) program = EpgProgram.getFromDb(self.db, program.id) program.deleteFromDb(self.db) getProgram = EpgProgram.getFromDb(self.db, program.id) self.assertIsNone(getProgram, "Program still in database") genres = EpgProgramGenre.getAllFromDb(self.db, program.id) self.assertEqual(genres, [], "Program genres still in database") actors = EpgProgramActor.getAllFromDb(self.db, program.id) self.assertEqual(actors, [], "Program actors still in database") directors = EpgProgramDirector.getAllFromDb(self.db, program.id) self.assertEqual(directors, [], "Program directors still in database") presenters = EpgProgramPresenter.getAllFromDb(self.db, program.id) self.assertEqual(presenters, [], "Program presenters still in database")
def test_deletePerson(self): actors = [ self._createProgramPerson(EpgProgramActor, x) for x in range(2) ] program = self._createProgram(EpgProgram, 1) program.actors = [actor for actor in actors] program.addToDb(self.db) program = EpgProgram.getFromDb(self.db, program.id) program.actors.remove(actors[0]) program.addToDb(self.db) program = EpgProgram.getFromDb(self.db, program.id) self.assertNotIn(actors[0], program.actors, "Program person still in program")
def test_deleteGenre(self): genres = [ self._createProgramGenre(EpgProgramGenre, x) for x in range(2) ] program = self._createProgram(EpgProgram, 1) program.genres = [genre for genre in genres] program.addToDb(self.db) program = EpgProgram.getFromDb(self.db, program.id) program.genres.remove(genres[0]) program.addToDb(self.db) program = EpgProgram.getFromDb(self.db, program.id) self.assertNotIn(genres[0], program.genres, "Program genre still in program")
def testNowNextPrograms(self): now = getTimestamp() program11 = self._createProgram(EpgProgram, 1, epgId="test_1", startTime=now - 600, endTime=now - 300) # before now program12 = self._createProgram(EpgProgram, 2, epgId="test_1", startTime=now - 300, endTime=now + 300) # now program13 = self._createProgram(EpgProgram, 3, epgId="test_1", startTime=now + 300, endTime=now + 600) # next program14 = self._createProgram(EpgProgram, 4, epgId="test_1", startTime=now + 600, endTime=now + 900) # after next program21 = self._createProgram(EpgProgram, 5, epgId="test_2", startTime=now - 600, endTime=now - 300) # before now program22 = self._createProgram(EpgProgram, 6, epgId="test_2", startTime=now - 300, endTime=now + 300) # now program23 = self._createProgram(EpgProgram, 7, epgId="test_2", startTime=now + 300, endTime=now + 600) # next program24 = self._createProgram(EpgProgram, 8, epgId="test_2", startTime=now + 600, endTime=now + 900) # after next program11.addToDb(self.db) program12.addToDb(self.db) program13.addToDb(self.db) program14.addToDb(self.db) program21.addToDb(self.db) program22.addToDb(self.db) program23.addToDb(self.db) program24.addToDb(self.db) nowNextPrograms = EpgProgram.getNowNextFromDb(self.db) nowNextProgramsSet = set([program12, program13, program22, program23]) nowNextProgramsDbSet = set(nowNextPrograms) self.assertSetEqual(nowNextProgramsSet, nowNextProgramsDbSet, "Now/next incorrect")
def test_addGenre(self): program = self._createProgram(EpgProgram, 1) program.addToDb(self.db) program.genres.append(self._createProgramGenre(EpgProgramGenre, 1)) program.addToDb(self.db) getProgram = EpgProgram.getFromDb(self.db, program.id) self.assertSetEqual( set(getProgram.genres), set(program.genres), "Added program genre not equal to program genre in database")
def test_addPerson(self): program = self._createProgram(EpgProgram, 1) program.addToDb(self.db) programPerson = self._createProgramPerson(EpgProgramActor, 1) program.actors.append(programPerson) program.addToDb(self.db) getProgram = EpgProgram.getFromDb(self.db, program.id) self.assertSetEqual( set(getProgram.actors), set(program.actors), "Added program person not equal to program person in database")
def test_getChannel(self): program = self._createProgram(EpgProgram, 1) program.genres = [self._createProgramGenre(EpgProgramGenre, 1)] program.actors = [self._createProgramPerson(EpgProgramActor, 1)] program.directors = [self._createProgramPerson(EpgProgramDirector, 1)] program.presenters = [ self._createProgramPerson(EpgProgramPresenter, 1) ] program.addToDb(self.db) getProgram = EpgProgram.getFromDb(self.db, program.id) self.assertIsNotNone(getProgram, "Program does not exist in database") self.assertEqual(program, getProgram, "Added program not equal to program in database")