Exemplo n.º 1
0
def test_parse_start_and_end_raises_when_start_after_end(
        timestamp, mock_str_to_timestamp):
    minus_one_day = timestamp - pd.Timedelta(days=1)

    start_str = timestamp.isoformat()
    end_str = minus_one_day.isoformat()

    with pytest.raises(ValueError):
        parse_start_and_end(start_str, end_str)
Exemplo n.º 2
0
def test_parse_start_and_end_two_arguments(timestamp, mock_str_to_timestamp):
    start_str = timestamp.isoformat()

    plus_day = timestamp + pd.Timedelta(days=1)
    end_str = plus_day.isoformat()

    start, end = parse_start_and_end(start_str, end_str)
    assert (start, end) == (timestamp, plus_day)
Exemplo n.º 3
0
def test_parse_start_end_end_before_earliest(timestamp, mock_str_to_timestamp):
    minus_two_days = timestamp - pd.Timedelta(days=2)
    minus_one_day = timestamp - pd.Timedelta(days=1)

    start_str = minus_two_days.isoformat()
    end_str = minus_one_day.isoformat()
    earliest_str = timestamp.isoformat()

    start, end = parse_start_and_end(start_str, end_str, earliest_str)
    assert (start, end) == (timestamp, timestamp)
Exemplo n.º 4
0
def test_parse_start_and_end_no_arguments(monkeypatch, timestamp,
                                          mock_str_to_timestamp):
    def mock_utcnow():
        return timestamp

    monkeypatch.setattr(pd.Timestamp, 'utcnow', mock_utcnow)

    yesterday = timestamp - pd.Timedelta(days=1)

    start, end = parse_start_and_end(None, None)
    assert (start, end) == (yesterday, yesterday)
Exemplo n.º 5
0
def test_parse_start_and_end_one_argument(timestamp, mock_str_to_timestamp):
    as_str = timestamp.isoformat()
    start, end = parse_start_and_end(as_str, None)
    assert (start, end) == (timestamp, timestamp)