Exemplo n.º 1
0
def test_complete_info(session_date, default_time, default_timezone):
    """With complete session_times, other info is ignored"""
    session_times = {
        'start': datetime.datetime(2020, 12, 24, 18, tzinfo=CHRISTMAS_TZ),
        'end': datetime.datetime(2020, 12, 28, 18, tzinfo=PRAGUE_TZ),
    }
    result = fix_session_time(dict(session_times), None, None, None, 'test')
    assert result == session_times
Exemplo n.º 2
0
 def _fix_time(self, context):
     self.time = fix_session_time(
         self.time,
         self.date,
         self.course.default_time,
         self.course.timezone,
         self.slug,
     )
Exemplo n.º 3
0
def test_error_missing_timezone():
    with pytest.raises(ValueError) as err:
        result = fix_session_time(
            None,
            datetime.date(2020, 12, 28),
            {
                'start': datetime.time(18, 0),
                'end': datetime.time(19, 10, tzinfo=CHRISTMAS_TZ),
            },
            None,
            '_test_session_name_',
        )
    assert '_test_session_name_' in str(err)
Exemplo n.º 4
0
def test_add_date_and_tz(default_time):
    result = fix_session_time(
        {
            'start': datetime.time(18, 0),
            'end': datetime.time(19, 10)
        },
        datetime.date(2020, 12, 28),
        default_time,  # ignored
        PRAGUE_TZ,
        'test',
    )
    assert result == {
        'start': datetime.datetime(2020, 12, 28, 18, tzinfo=PRAGUE_TZ),
        'end': datetime.datetime(2020, 12, 28, 19, 10, tzinfo=PRAGUE_TZ),
    }
Exemplo n.º 5
0
def test_add_date(default_time):
    result = fix_session_time(
        {
            'start': datetime.time(18, tzinfo=EASTER_TZ),
            'end': datetime.time(19, 10, tzinfo=CHRISTMAS_TZ),
        },
        datetime.date(2020, 12, 28),
        default_time,  # ignored
        PRAGUE_TZ,
        'test',
    )
    assert result == {
        'start': datetime.datetime(2020, 12, 28, 18, tzinfo=EASTER_TZ),
        'end': datetime.datetime(2020, 12, 28, 19, 10, tzinfo=CHRISTMAS_TZ),
    }
Exemplo n.º 6
0
def test_add_date():
    result = fix_session_time(
        {
            'start': datetime.time(18, 0),
            'end': datetime.time(19, 10)
        },
        datetime.date(2020, 12, 28),
        None,
        PRAGUE_TZ,
        'test',
    )
    assert result == {
        'start': datetime.datetime(2020, 12, 28, 18, tzinfo=PRAGUE_TZ),
        'end': datetime.datetime(2020, 12, 28, 19, 10, tzinfo=PRAGUE_TZ),
    }
Exemplo n.º 7
0
def test_all_none():
    result = fix_session_time(None, None, None, None, 'test')
    assert result == None