def test_kickoff_date(self):
     # 2011 - Saturday the 8th (https://en.wikipedia.org/wiki/Logo_Motion)
     kickoff_2011 = date(2011, 1, 8)
     self.assertEqual(SeasonHelper.kickoff_date(year=2011), kickoff_2011)
     # 2010 - Saturday the 9th (https://en.wikipedia.org/wiki/Breakaway_(FIRST))
     kickoff_2010 = date(2010, 1, 9)
     self.assertEqual(SeasonHelper.kickoff_date(year=2010), kickoff_2010)
     # 2009 - Saturday the 3rd (https://en.wikipedia.org/wiki/Lunacy_(FIRST)
     kickoff_2009 = date(2009, 1, 3)
     self.assertEqual(SeasonHelper.kickoff_date(year=2009), kickoff_2009)
Exemplo n.º 2
0
 def test_kickoff_date(self):
     # 2011 - Saturday the 8th (https://en.wikipedia.org/wiki/Logo_Motion)
     kickoff_2011 = date(2011, 1, 8)
     self.assertEqual(SeasonHelper.kickoff_date(year=2011), kickoff_2011)
     # 2010 - Saturday the 9th (https://en.wikipedia.org/wiki/Breakaway_(FIRST))
     kickoff_2010 = date(2010, 1, 9)
     self.assertEqual(SeasonHelper.kickoff_date(year=2010), kickoff_2010)
     # 2009 - Saturday the 3rd (https://en.wikipedia.org/wiki/Lunacy_(FIRST)
     kickoff_2009 = date(2009, 1, 3)
     self.assertEqual(SeasonHelper.kickoff_date(year=2009), kickoff_2009)
Exemplo n.º 3
0
    def _render(self, *args, **kw):
        self.template_values.update({
            'endbuild_datetime_est':
            SeasonHelper.stop_build_datetime_est(),
            'endbuild_datetime_utc':
            SeasonHelper.stop_build_datetime_utc(),
            'events':
            EventHelper.getWeekEvents(),
        })

        return jinja2_engine.render('index/index_buildseason.html',
                                    self.template_values)
 def test_stop_build_date(self):
     # 2019 - Feb 19th, 2019
     stop_build_2019 = datetime(2019, 2, 19, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2019), stop_build_2019)
     # 2018 - Feb 20th, 2018
     stop_build_2018 = datetime(2018, 2, 20, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2018), stop_build_2018)
     # 2017 - Feb 21th, 2017
     stop_build_2017 = datetime(2017, 2, 21, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2017), stop_build_2017)
     # 2016 - Feb 23th, 2016
     stop_build_2016 = datetime(2016, 2, 23, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2016), stop_build_2016)
Exemplo n.º 5
0
 def test_effective_season_year_next_year_ignore_non_official(self):
     # Effective season should be next year
     today = datetime.today()
     # Insert an event that has already happened - otherwise we'll default to the current season
     # This is to simulate offseason
     Event(
         id="{}testended".format(today.year),
         end_date=today - timedelta(days=1),
         event_short="testended",
         event_type_enum=EventType.REGIONAL,
         first_eid="5561",
         name="Test Event (Ends Tomorrow)",
         start_date=today - timedelta(days=2),
         year=today.year,
         venue_address="123 Fake Street, Anytown, MI, USA",
         website="http://www.google.com"
     ).put()
     Event(
         id="{}testendstomorrow".format(today.year),
         end_date=today + timedelta(days=1),
         event_short="testendstomorrow",
         event_type_enum=EventType.OFFSEASON,
         first_eid="5561",
         name="Test Event (Ends Tomorrow)",
         start_date=today,
         year=today.year,
         venue_address="123 Fake Street, Anytown, MI, USA",
         website="http://www.google.com"
     ).put()
     self.assertEqual(SeasonHelper.effective_season_year(), today.year + 1)
Exemplo n.º 6
0
    def _render(self, *args, **kw):
        special_webcasts = FirebasePusher.get_special_webcasts()
        effective_season_year = SeasonHelper.effective_season_year()

        self.template_values.update({
            "events":
            EventHelper.getWeekEvents(),
            'kickoff_datetime_utc':
            SeasonHelper.kickoff_datetime_utc(effective_season_year),
            "any_webcast_online":
            any(w.get('status') == 'online' for w in special_webcasts),
            "special_webcasts":
            special_webcasts,
        })

        return jinja2_engine.render('index/index_offseason.html',
                                    self.template_values)
Exemplo n.º 7
0
 def test_stop_build_date(self):
     # 2019 - Feb 19th, 2019
     stop_build_2019 = datetime(2019, 2, 19, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2019),
                      stop_build_2019)
     # 2018 - Feb 20th, 2018
     stop_build_2018 = datetime(2018, 2, 20, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2018),
                      stop_build_2018)
     # 2017 - Feb 21th, 2017
     stop_build_2017 = datetime(2017, 2, 21, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2017),
                      stop_build_2017)
     # 2016 - Feb 23th, 2016
     stop_build_2016 = datetime(2016, 2, 23, 23, 59, 59)
     self.assertEqual(SeasonHelper.stop_build_date(year=2016),
                      stop_build_2016)
Exemplo n.º 8
0
    def test_is_kickoff_at_least_one_day_away(self):
        a = datetime(2020, 1, 3, 14, 30, 00, tzinfo=UTC)  # False - over one day
        b = datetime(2020, 1, 3, 15, 30, 00, tzinfo=UTC)  # True - exactly one day
        c = datetime(2020, 1, 4, 15, 30, 00, tzinfo=UTC)  # True - same time
        d = datetime(2020, 2, 4, 15, 30, 00, tzinfo=UTC)  # True - very far away in the future
        expected_results = [False, True, True, True]

        for (date, result) in zip([a, b, c, d], expected_results):
            at_least_one_day_away = SeasonHelper.is_kickoff_at_least_one_day_away(date, 2020)
            self.assertEqual(at_least_one_day_away, result)
Exemplo n.º 9
0
 def test_stop_build_date(self):
     # 2019 - Feb 19th, 2019
     stop_build_2019 = datetime(2019,
                                2,
                                19,
                                23,
                                59,
                                59,
                                tzinfo=timezone('EST'))
     stop_build_2019_utc = stop_build_2019.astimezone(UTC)
     self.assertEqual(SeasonHelper.stop_build_datetime_est(year=2019),
                      stop_build_2019)
     self.assertEqual(SeasonHelper.stop_build_datetime_utc(year=2019),
                      stop_build_2019_utc)
     # 2018 - Feb 20th, 2018
     stop_build_2018 = datetime(2018,
                                2,
                                20,
                                23,
                                59,
                                59,
                                tzinfo=timezone('EST'))
     stop_build_2018_utc = stop_build_2018.astimezone(UTC)
     self.assertEqual(SeasonHelper.stop_build_datetime_est(year=2018),
                      stop_build_2018)
     self.assertEqual(SeasonHelper.stop_build_datetime_utc(year=2018),
                      stop_build_2018_utc)
     # 2017 - Feb 21th, 2017
     stop_build_2017 = datetime(2017,
                                2,
                                21,
                                23,
                                59,
                                59,
                                tzinfo=timezone('EST'))
     stop_build_2017_utc = stop_build_2017.astimezone(UTC)
     self.assertEqual(SeasonHelper.stop_build_datetime_est(year=2017),
                      stop_build_2017)
     self.assertEqual(SeasonHelper.stop_build_datetime_utc(year=2017),
                      stop_build_2017_utc)
     # 2016 - Feb 23th, 2016
     stop_build_2016 = datetime(2016,
                                2,
                                23,
                                23,
                                59,
                                59,
                                tzinfo=timezone('EST'))
     stop_build_2016_utc = stop_build_2016.astimezone(UTC)
     self.assertEqual(SeasonHelper.stop_build_datetime_est(year=2016),
                      stop_build_2016)
     self.assertEqual(SeasonHelper.stop_build_datetime_utc(year=2016),
                      stop_build_2016_utc)
Exemplo n.º 10
0
    def _render(self, *args, **kw):
        special_webcasts = FirebasePusher.get_special_webcasts()

        self.template_values.update({
            'events':
            EventHelper.getWeekEvents(),
            'is_kickoff':
            SeasonHelper.is_kickoff_at_least_one_day_away(),
            'kickoff_datetime_est':
            SeasonHelper.kickoff_datetime_est(),
            'kickoff_datetime_utc':
            SeasonHelper.kickoff_datetime_utc(),
            "any_webcast_online":
            any(w.get('status') == 'online' for w in special_webcasts),
            "special_webcasts":
            special_webcasts,
        })

        return jinja2_engine.render('index/index_kickoff.html',
                                    self.template_values)
Exemplo n.º 11
0
    def _render(self, *args, **kw):
        endbuild_datetime_est = datetime.datetime.strptime(
            self.template_values['build_season_end'], "%Y-%m-%dT%H:%M:%S"
        ) if 'build_season_end' in self.template_values else SeasonHelper.stop_build_date()
        endbuild_datetime_utc = pytz.utc.localize(
            endbuild_datetime_est + datetime.timedelta(hours=5))
        week_events = EventHelper.getWeekEvents()

        self.template_values.update({
            'endbuild_datetime_est': endbuild_datetime_est,
            'endbuild_datetime_utc': endbuild_datetime_utc,
            'events': week_events,
        })

        path = os.path.join(os.path.dirname(__file__), "../templates/index_buildseason.html")
        return template.render(path, self.template_values)
Exemplo n.º 12
0
 def test_effective_season_year_next_year(self):
     # Effective season should be next year
     today = datetime.today()
     Event(
         id="{}testended".format(today.year),
         end_date=today - timedelta(days=1),
         event_short="testended",
         event_type_enum=EventType.REGIONAL,
         first_eid="5561",
         name="Test Event (Ends Tomorrow)",
         start_date=today - timedelta(days=2),
         year=today.year,
         venue_address="123 Fake Street, Anytown, MI, USA",
         website="http://www.google.com"
     ).put()
     self.assertEqual(SeasonHelper.effective_season_year(), today.year + 1)
Exemplo n.º 13
0
    def _render(self, *args, **kw):
        endbuild_datetime_est = datetime.datetime.strptime(
            self.template_values['build_season_end'], "%Y-%m-%dT%H:%M:%S"
        ) if 'build_season_end' in self.template_values else SeasonHelper.stop_build_date()
        endbuild_datetime_utc = pytz.utc.localize(
            endbuild_datetime_est + datetime.timedelta(hours=5))
        week_events = EventHelper.getWeekEvents()

        self.template_values.update({
            'endbuild_datetime_est': endbuild_datetime_est,
            'endbuild_datetime_utc': endbuild_datetime_utc,
            'events': week_events,
        })

        path = os.path.join(os.path.dirname(__file__), "../templates/index_buildseason.html")
        return template.render(path, self.template_values)
Exemplo n.º 14
0
 def test_kickoff_datetime(self):
     # 2011 - Saturday the 8th (https://en.wikipedia.org/wiki/Logo_Motion)
     kickoff_2011 = datetime(2011, 1, 8, 10, 30, 00, tzinfo=timezone('EST'))
     kickoff_2011_utc = kickoff_2011.astimezone(UTC)
     self.assertEqual(SeasonHelper.kickoff_datetime_est(year=2011), kickoff_2011)
     self.assertEqual(SeasonHelper.kickoff_datetime_utc(year=2011), kickoff_2011_utc)
     # 2010 - Saturday the 9th (https://en.wikipedia.org/wiki/Breakaway_(FIRST))
     kickoff_2010 = datetime(2010, 1, 9, 10, 30, 00, tzinfo=timezone('EST'))
     kickoff_2010_utc = kickoff_2010.astimezone(UTC)
     self.assertEqual(SeasonHelper.kickoff_datetime_est(year=2010), kickoff_2010)
     self.assertEqual(SeasonHelper.kickoff_datetime_utc(year=2010), kickoff_2010_utc)
     # 2009 - Saturday the 3rd (https://en.wikipedia.org/wiki/Lunacy_(FIRST)
     kickoff_2009 = datetime(2009, 1, 3, 10, 30, 00, tzinfo=timezone('EST'))
     kickoff_2009_utc = kickoff_2009.astimezone(UTC)
     self.assertEqual(SeasonHelper.kickoff_datetime_est(year=2009), kickoff_2009)
     self.assertEqual(SeasonHelper.kickoff_datetime_utc(year=2009), kickoff_2009_utc)
Exemplo n.º 15
0
 def test_effective_season_year_no_events(self):
     now = datetime.now()
     self.assertEqual(SeasonHelper.effective_season_year(), now.year)