def test_2_progs_1_clash(self): p1 = Programme(title="prog1", channel="c1", start=self.london.localize( datetime(hour=21, day=19, month=4, year=2017)), stop=self.london.localize( datetime(hour=22, minute=40, day=19, month=4, year=2017))) p2 = Programme(title="prog2", channel="c2", start=self.london.localize( datetime(hour=21, minute=30, day=19, month=4, year=2017)), stop=self.london.localize( datetime(hour=23, minute=40, day=19, month=4, year=2017))) self.assertEqual([(p1, p2)], get_time_clashes([p1, p2]))
def test_2_progs_no_clash(self): self.assertEqual([], get_time_clashes([ Programme(title="prog1", channel="c1", start=self.london.localize( datetime(hour=21, day=19, month=4, year=2017)), stop=self.london.localize( datetime(hour=22, minute=40, day=19, month=4, year=2017))), Programme(title="prog2", channel="c2", start=self.london.localize( datetime(hour=9, day=21, month=4, year=2017)), stop=self.london.localize( datetime(hour=10, minute=40, day=21, month=4, year=2017))) ]))
def test_filter_passed_all_passed(self, mock_dt): mock_dt.now.return_value = datetime(hour=17, day=17, month=9, year=2017) self.assertEqual([], filter_passed([ Programme(title="prog1", channel="c1", start=self.london.localize( datetime(hour=21, day=19, month=4, year=2017)), stop=self.london.localize( datetime(hour=22, minute=40, day=19, month=4, year=2017))), Programme(title="prog2", channel="c2", start=self.london.localize( datetime(hour=9, day=19, month=4, year=2017)), stop=self.london.localize( datetime(hour=10, minute=40, day=19, month=4, year=2017))) ]))
def test_clash_p2_first(self): p1 = Programme(title="prog1", channel="c1", start=self.london.localize( datetime(hour=21, day=19, month=4, year=2016)), stop=self.london.localize( datetime(hour=22, minute=40, day=19, month=4, year=2016))) p2 = Programme(title="prog2", channel="c2", start=self.london.localize( datetime(hour=20, minute=15, day=19, month=4, year=2016)), stop=self.london.localize( datetime(hour=22, minute=20, day=19, month=4, year=2016))) self.assertTrue(is_clashing(p1, p2))
def test_programme_from_JSON(self): prog_json=\ '{\ "start": 1461096000,\ "stop": 1461102000,\ "channel": "f01fa94c246c4b49492f5f3e0f9150dd",\ "channelname": "Film4",\ "title": {\ "eng": "Locke"\ }\ }' london = timezone('Europe/London') self.assertEqual( Programme(title="Locke", channel="f01fa94c246c4b49492f5f3e0f9150dd", start=london.localize( datetime(hour=21, day=19, month=4, year=2016)), stop=london.localize( datetime(hour=22, minute=40, day=19, month=4, year=2016))), programme_from_JSON(prog_json))
def tes_mo_clash_different_times(self): p1 = Programme(title="prog1", channel="c1", start=self.london.localize( datetime(hour=21, day=19, month=4, year=2016)), stop=self.london.localize( datetime(hour=22, minute=40, day=19, month=4, year=2016))) p2 = Programme(title="prog2", channel="c2", start=self.london.localize( datetime(hour=9, day=19, month=4, year=2016)), stop=self.london.localize( datetime(hour=10, minute=40, day=19, month=4, year=2016))) self.assertFalse(is_clashing(p1, p2))
def test_different_multiplex(self): p1 = Programme(title='prog1', channel='s1', start=None, stop=None) p2 = Programme(title='prog2', channel='s3', start=None, stop=None) self.assertEqual([(p1, p2)], get_multiplex_clashes([(p1, p2)], self.services_by_id))