def test_hashable(self): s1 = RecordingSchedule({'recordid' : 1}, Mock()) s2 = RecordingSchedule({'recordid' : 2}, Mock()) d = {s1:'schedule1',} self.assertIn(s1, d) self.assertEqual('schedule1', d[s1]) self.assertNotIn(s2, d)
def test_starttime_DataFromNativeMySQL(self): data = { 'starttime': datetime.timedelta(seconds=(1 * 60 * 60) + (2 * 60) + 3) } schedule = RecordingSchedule(data, Mock()) self.assertEqual('010203', schedule.starttime())
def test_saveSchedule_NewSchedule(self): now = datetime.datetime.now() programs = self.db.getTVGuideDataFlattened(now, now, self.db.getChannels()) if len(programs) == 0: log.warn("Cannot run unit tests without program listings in the database") return schedule = RecordingSchedule.fromProgram(programs[0], self.translator) log.debug("Test schedule = %s" % schedule) result = self.db.saveSchedule(schedule) log.debug("Save schedule result = %s" % result)
def test_saveSchedule_NewSchedule(self): now = datetime.datetime.now() programs = self.db.getTVGuideDataFlattened(now, now, self.db.getChannels()) if len(programs) == 0: log.warn( 'Cannot run unit tests without program listings in the database' ) return schedule = RecordingSchedule.fromProgram(programs[0], self.translator) log.debug('Test schedule = %s' % schedule) result = self.db.saveSchedule(schedule) log.debug('Save schedule result = %s' % result)
def onControlHook(self, control): actionConsumed = True id = control.getId() program = None for c in self.gridCells: if c.control == control: program = c.program break if program: if program.isShowing(): log.debug('launching livetv') self.watchLiveTv(program) else: log.debug('launching edit schedule dialog') # scheduled recording if c.scheduleId: schedule = self.db().getRecordingSchedules( scheduleId=c.scheduleId).pop() # not scheduled but happens to have an existing recording schedule schedule = self.scheduleForTitle(program) # new recording schedule if schedule is None: schedule = RecordingSchedule.fromProgram( program, self.translator) d = ScheduleDialog( 'mythbox_schedule_dialog.xml', self.platform.getScriptDir(), forceFallback=True, schedule=schedule, translator=self.translator, platform=self.platform, settings=self.settings, mythChannelIconCache=self.mythChannelIconCache) d.doModal() return actionConsumed
def onControlHook(self, control): actionConsumed = True id = control.getId() program = None for c in self.gridCells: if c.control == control: program = c.program break if program: if program.isShowing(): log.debug('launching livetv') self.watchLiveTv(program) else: log.debug('launching edit schedule dialog') # scheduled recording if c.scheduleId: schedule = self.db().getRecordingSchedules(scheduleId=c.scheduleId).pop() # not scheduled but happens to have an existing recording schedule schedule = self.scheduleForTitle(program) # new recording schedule if schedule is None: schedule = RecordingSchedule.fromProgram(program, self.translator) d = ScheduleDialog( 'mythbox_schedule_dialog.xml', self.platform.getScriptDir(), forceFallback=True, schedule=schedule, translator=self.translator, platform=self.platform, settings=self.settings, mythChannelIconCache=self.mythChannelIconCache) d.doModal() return actionConsumed
def test_episodeFilter_and_checkForDupesIn_read_from_and_written_to_dupin_field_correctly(self): data = {'dupin': CheckForDupesIn.ALL_RECORDINGS | EpisodeFilter.EXCLUDE_REPEATS_AND_GENERICS} schedule = RecordingSchedule(data, Mock()) self.assertEqual(EpisodeFilter.EXCLUDE_REPEATS_AND_GENERICS, schedule.getEpisodeFilter()) schedule.setEpisodeFilter(EpisodeFilter.NEW_EPISODES_ONLY) self.assertEqual(EpisodeFilter.NEW_EPISODES_ONLY, schedule.getEpisodeFilter()) self.assertEqual(CheckForDupesIn.ALL_RECORDINGS, schedule.getCheckForDupesIn()) schedule.setCheckForDupesIn(CheckForDupesIn.PREVIOUS_RECORDINGS) self.assertEqual(EpisodeFilter.NEW_EPISODES_ONLY, schedule.getEpisodeFilter()) self.assertEqual(CheckForDupesIn.PREVIOUS_RECORDINGS, schedule.getCheckForDupesIn()) schedule.setEpisodeFilter(EpisodeFilter.NONE) self.assertEqual(EpisodeFilter.NONE, schedule.getEpisodeFilter()) self.assertEqual(CheckForDupesIn.PREVIOUS_RECORDINGS, schedule.getCheckForDupesIn())
def test_enddate_DataFromNativeMySQL(self): data = {'enddate': datetime.date(2008, 11, 12)} schedule = RecordingSchedule(data, Mock()) self.assertEqual('20081112', schedule.enddate())
def test_endtime_DataFromNativeMySQL(self): data = {'endtime': datetime.timedelta(seconds=(1 * 60 * 60) + (2 * 60) + 3)} schedule = RecordingSchedule(data, Mock()) self.assertEqual('010203', schedule.endtime())
def getRecordingSchedules(self, chanId='', scheduleId=-1): """ @return: All recording schedules unless a specific channel or schedule id is given. @rtype: RecordingSchedule[] """ sql = """ SELECT r.recordid, r.type, r.chanid, r.starttime, r.startdate, r.endtime, r.enddate, r.title, r.subtitle, r.description, r.category, r.profile, r.recpriority, r.autoexpire, r.maxepisodes, r.maxnewest, r.startoffset, r.endoffset, r.recgroup, r.dupmethod, r.dupin, r.station, r.seriesid, r.programid, r.search, r.autotranscode, r.autocommflag, r.autouserjob1, r.autouserjob2, r.autouserjob3, r.autouserjob4, r.findday, r.findtime, r.findid, r.inactive, r.parentid, c.channum, c.callsign, c.name as channame, c.icon, (select count(*) from oldrecorded where oldrecorded.title=r.title and oldrecorded.recstatus = %d) as numRecorded FROM record r LEFT JOIN channel c ON r.chanid = c.chanid """ % RecordingStatus.RECORDED if chanId != "": sql += "WHERE r.chanid = '%s' "%chanId if scheduleId != -1: if chanId == "": sql+="WHERE " else: sql +="AND " sql += "r.recordid = %d "%scheduleId sql += """ ORDER BY r.recordid DESC """ schedules = [] self.cursor.execute(sql) rows = self.cursor.fetchall() from mythbox.mythtv.domain import RecordingSchedule for row in rows: row = self.toDict(self.cursor, row) schedules.append(RecordingSchedule(row, self.translator)) return schedules