def test_manual_ps_ranges(self): first_manual_ps = ps_data.get_manual_ps_events( start=utc_datetime(2006, 9, 25)).next() self.assertStartsAt(first_manual_ps, utc_datetime(2006, 9, 25, 17, 0)) second_manual_ps = ps_data.get_manual_ps_events( start=utc_datetime(2006, 9, 26)).next() self.assertStartsAt(second_manual_ps, utc_datetime(2007, 2, 1, 18, 0))
def test_merged_ranges_manual(self): first_manual_ps = ps_data.events(start=utc_datetime(2006, 9, 24)).next() self.assertStartsAt(first_manual_ps, utc_datetime(2006, 9, 25, 17, 0)) first_manual_ps = ps_data.events(start=utc_datetime(2006, 9, 25)).next() self.assertStartsAt(first_manual_ps, utc_datetime(2006, 9, 25, 17, 0)) first_post_manual_ps = ps_data.events(start=utc_datetime(2006, 9, 26)).next() self.assertStartsAt(first_post_manual_ps, utc_datetime(2006, 10, 12, 17, 0))
def test_merged_ranges_manual(self): first_manual_ps = ps_data.events( start=utc_datetime(2006, 9, 24)).next() self.assertStartsAt(first_manual_ps, utc_datetime(2006, 9, 25, 17, 0)) first_manual_ps = ps_data.events( start=utc_datetime(2006, 9, 25)).next() self.assertStartsAt(first_manual_ps, utc_datetime(2006, 9, 25, 17, 0)) first_post_manual_ps = ps_data.events( start=utc_datetime(2006, 9, 26)).next() self.assertStartsAt(first_post_manual_ps, utc_datetime(2006, 10, 12, 17, 0))
def test_around_dst(self): def get_ev_data(ev): return ( ev.start_dt, ev.end_dt, ev.slug, ev.pretty_date, ev.pretty_time_period, ) def check_events_for_starts(ev_getter, starts): ev_gens = map(ev_getter, starts) ev_lists = map(list, ev_gens) self.assertAllEqual(len(l) for l in ev_lists) for evs in zip(*ev_lists): ev_datas = map(get_ev_data, evs) self.assertAllEqual(ev_datas) def check_event_queries_for_starts(starts): # NB we don't test the_algorithm.next_ps_date, but # everything else about it should be deterministic def get_all_evs(start): future = start + timedelta(weeks=52) return ps_data.events(end=future) def get_next_evs(start): future = start + timedelta(weeks=52) return ps_data.events(start=start, end=future) def get_prev_evs(start): return ps_data.events(end=start) check_events_for_starts(get_all_evs, starts) check_events_for_starts(get_next_evs, starts) check_events_for_starts(get_prev_evs, starts) begin_dst = [ utc_datetime(2014, 3, 30, 0, 30), utc_datetime(2014, 3, 30, 1, 30), utc_datetime(2014, 3, 30, 2, 30), ] end_dst = [ utc_datetime(2014, 10, 26, 0, 30), utc_datetime(2014, 10, 26, 1, 30), utc_datetime(2014, 10, 26, 2, 30), ] check_event_queries_for_starts(begin_dst) check_event_queries_for_starts(end_dst)
def test_around_dst(self): def get_ev_data(ev): return (ev.start_dt, ev.end_dt, ev.slug, ev.pretty_date, ev.pretty_time_period, ) def check_events_for_starts(ev_getter, starts): ev_gens = map(ev_getter, starts) ev_lists = map(list, ev_gens) self.assertAllEqual(len(l) for l in ev_lists) for evs in zip(*ev_lists): ev_datas = map(get_ev_data, evs) self.assertAllEqual(ev_datas) def check_event_queries_for_starts(starts): # NB we don't test the_algorithm.next_ps_date, but # everything else about it should be deterministic def get_all_evs(start): future = start + timedelta(weeks=52) return ps_data.events(end=future) def get_next_evs(start): future = start + timedelta(weeks=52) return ps_data.events(start=start, end=future) def get_prev_evs(start): return ps_data.events(end=start) check_events_for_starts(get_all_evs, starts) check_events_for_starts(get_next_evs, starts) check_events_for_starts(get_prev_evs, starts) begin_dst = [ utc_datetime(2014, 3, 30, 0, 30), utc_datetime(2014, 3, 30, 1, 30), utc_datetime(2014, 3, 30, 2, 30), ] end_dst = [ utc_datetime(2014, 10, 26, 0, 30), utc_datetime(2014, 10, 26, 1, 30), utc_datetime(2014, 10, 26, 2, 30), ] check_event_queries_for_starts(begin_dst) check_event_queries_for_starts(end_dst)
def test_substandards_slug(self): ss_pista = ps_data.get_ps_event_by_slug('substandards-pista') self.assertStartsAt(ss_pista, utc_datetime(2007, 2, 1, 18, 0)) assert ps_data.get_ps_event_by_slug('substandards-Pista') is None, 'Invalid slug matched'
def test_substandards_slug_with_hyphens(self): first_ss = ps_data.get_ps_event_by_slug('mid-pub-standards-non-pub-standards-pub-standards') self.assertStartsAt(first_ss, utc_datetime(2006, 9, 25, 17, 0))
def test_merged_ranges_algorithmic_same_day(self): first_ps = ps_data.events(start=utc_datetime(2005, 12, 15)).next() self.assertStartsAt(first_ps, utc_datetime(2005, 12, 15, 18, 0))
def test_merged_ranges_algorithmic(self): first_ps = ps_data.events(start=utc_datetime(2005, 12, 14)).next() self.assertStartsAt(first_ps, utc_datetime(2005, 12, 15, 18, 0)) second_ps = ps_data.events(start=utc_datetime(2005, 12, 16)).next() self.assertStartsAt(second_ps, utc_datetime(2006, 1, 12, 18, 0))
def test_manual_ps_ranges(self): first_manual_ps = ps_data.get_manual_ps_events(start=utc_datetime(2006, 9, 25)).next() self.assertStartsAt(first_manual_ps, utc_datetime(2006, 9, 25, 17, 0)) second_manual_ps = ps_data.get_manual_ps_events(start=utc_datetime(2006, 9, 26)).next() self.assertStartsAt(second_manual_ps, utc_datetime(2007, 2, 1, 18, 0))
def test_ps_ranges_same_day(self): first_ps = ps_data.gen_events(start=utc_datetime(2005, 12, 15)).next() self.assertStartsAt(first_ps, utc_datetime(2005, 12, 15, 18, 0))
def test_manual_ps_slugs(self): ps_65 = ps_data.get_ps_event_by_slug('pubstandards-lxv') self.assertStartsAt(ps_65, utc_datetime(2005, 12, 14, 18, 0)) ps_100 = ps_data.get_ps_event_by_slug('pubstandards-c') self.assertStartsAt(ps_100, utc_datetime(2014, 3, 13, 18, 0))
def test_substandards_slug_with_hyphens(self): first_ss = ps_data.get_ps_event_by_slug( 'mid-pub-standards-non-pub-standards-pub-standards') self.assertStartsAt(first_ss, utc_datetime(2006, 9, 25, 17, 0))
def test_substandards_slug(self): ss_pista = ps_data.get_ps_event_by_slug('substandards-pista') self.assertStartsAt(ss_pista, utc_datetime(2007, 2, 1, 18, 0)) assert ps_data.get_ps_event_by_slug( 'substandards-Pista') is None, 'Invalid slug matched'
def test_ps_ranges(self): first_ps = ps_data.gen_events(start=utc_datetime(2005, 12, 14)).next() self.assertStartsAt(first_ps, utc_datetime(2005, 12, 15, 18, 0)) second_ps = ps_data.gen_events(start=utc_datetime(2005, 12, 16)).next() self.assertStartsAt(second_ps, utc_datetime(2006, 1, 12, 18, 0))