Exemple #1
0
    def test_datetime_berlin(self):
        timezone = pytz.timezone('Europe/Berlin')
        dt_in = datetime.datetime(2000, 1, 1, tzinfo=timezone)
        dt_out = date_time.ensure_utc_aware(dt_in)

        self.assertIs(dt_in, dt_out)
        self.assertEqual(dt_out.tzinfo, timezone)
Exemple #2
0
def get_control_info(db_conn, prohibit_changes=False):
    """
    Returns a dictionary contatining relevant information about the competion, as stored in the database.
    """

    with transaction_cursor(db_conn, prohibit_changes) as cursor:
        cursor.execute('SELECT start, "end", tick_duration, current_tick FROM scoring_gamecontrol')
        result = cursor.fetchone()

    if result is None:
        raise DBDataError('Game control information has not been configured')
    start, end, duration, tick = result

    return {
        'start': ensure_utc_aware(start),
        'end': ensure_utc_aware(end),
        'tick_duration': duration,
        'current_tick': tick
    }
Exemple #3
0
    def test_time_unaware(self):
        t_in = datetime.time()
        t_out = date_time.ensure_utc_aware(t_in)

        self.assertIsNotNone(t_out.tzinfo)
        self.assertEqual(t_out.utcoffset().total_seconds(), 0)
Exemple #4
0
    def test_time_utc(self):
        t_in = datetime.time(tzinfo=datetime.timezone.utc)
        t_out = date_time.ensure_utc_aware(t_in)

        self.assertIs(t_in, t_out)
        self.assertEqual(t_out.utcoffset().total_seconds(), 0)
Exemple #5
0
    def test_datetime_unaware(self):
        dt_in = datetime.datetime(2000, 1, 1)
        dt_out = date_time.ensure_utc_aware(dt_in)

        self.assertIsNotNone(dt_out.tzinfo)
        self.assertEqual(dt_out.utcoffset().total_seconds(), 0)
Exemple #6
0
    def test_datetime_utc(self):
        dt_in = datetime.datetime(2000, 1, 1, tzinfo=datetime.timezone.utc)
        dt_out = date_time.ensure_utc_aware(dt_in)

        self.assertIs(dt_in, dt_out)
        self.assertEqual(dt_out.utcoffset().total_seconds(), 0)
Exemple #7
0
 def test_none(self):
     self.assertIsNone(date_time.ensure_utc_aware(None))