Ejemplo n.º 1
0
def test_hours_listing():
    hours_listing = read_hours_listing()

    today = date.today()

    # Make sure that calling functions doesn't cause exceptions, now or in the
    # future
    for i in range(100):
        hours_listing.hours_on_date(today + timedelta(days=i))
        hours_listing.hours_on_date(today - timedelta(days=i + 1))

        # Try every 10 minute interval on each day
        for j in range(timedelta(days=1) // timedelta(minutes=10)):
            fake_now = datetime.combine(
                today + timedelta(days=i),
                time(),
            ) + j * timedelta(minutes=10)

            hours_listing.is_open(when=fake_now)
            hours_listing.time_to_open(when=fake_now)
            hours_listing.time_to_close(when=fake_now)
Ejemplo n.º 2
0
def get_hours_listing() -> HoursListing:
    return read_hours_listing()
Ejemplo n.º 3
0
def test_is_open(now, expected_open, mock_hours_yaml, mock_now):
    assert read_hours_listing().is_open(now) == expected_open
Ejemplo n.º 4
0
def test_hours_on_date(now, expected_hours, mock_hours_yaml, mock_now):
    assert read_hours_listing().hours_on_date(now) == expected_hours
Ejemplo n.º 5
0
def test_idempotence(mock_hours_yaml):
    hours_listing = read_hours_listing()
    assert hours_listing == HoursListing(**vars(hours_listing))
Ejemplo n.º 6
0
def test_time_to_close_now(mock_hours_yaml, mock_now):
    hours_listing = read_hours_listing()
    assert hours_listing.time_to_open() == timedelta()
    assert hours_listing.time_to_close() == datetime(2015, 8, 22,
                                                     18) - FAKE_NOW
Ejemplo n.º 7
0
def test_time_to_close(now, expected_next_close, mock_hours_yaml):
    hours_listing = read_hours_listing()
    assert hours_listing.time_to_close(now) == expected_next_close - now
    assert hours_listing.time_to_open(now) == timedelta()
Ejemplo n.º 8
0
def get_hours_listing():
    return read_hours_listing()