def test_parse_datetime_explicit_format():
    # Given format
    assert parse_datetime("2020-01-16 19:00",
                          "%Y-%m-%d %H:%M") == datetime.strptime(
                              "2020-01-16 19:00", "%Y-%m-%d %H:%M")

    with pytest.raises(ValueError):
        parse_datetime("2020-01-16 19:00", "%Y%m%d%H%M")
Beispiel #2
0
def CalculateDueDate(turnaround: str, start_date_time: str = None, start_date_time_format: str = None):
    if start_date_time is None:
        start = parse_datetime()
    elif start_date_time_format is None:
        start = parse_datetime(start_date_time)
    else:
        start = parse_datetime(start_date_time, start_date_time_format)

    return datetime.strftime(add_turnaround(start, turnaround), "%Y-%m-%d %H:%M")
def test_parse_datetime_no_param():
    # No params mean now
    assert parse_datetime() == datetime(2020, 1, 16, 19, 0, 0)
def test_wrong_common_format():
    # Invalid
    with pytest.raises(ValueError):
        parse_datetime('something_weird')
def test_parse_datetime_common_format(input_datetime, expected):
    assert parse_datetime(input_datetime) == expected