def test_time_filtering(operator, staff_api_client, parking_factory, name):
p1 = parking_factory(
registration_number='ABC-123',
time_start=datetime(2012, 1, 1, 12, 0, 0, tzinfo=utc),
time_end=datetime(2014, 1, 1, 12, 0, 0, tzinfo=utc),
operator=operator)
p2 = parking_factory(
registration_number='ABC-123',
time_start=datetime(2014, 1, 1, 12, 0, 0, tzinfo=utc),
time_end=datetime(2016, 1, 1, 12, 0, 0, tzinfo=utc),
operator=operator)
p3 = parking_factory(registration_number='ABC-123')
(time, expected_parkings) = {
'before_all': ('2000-01-01T12:00:00Z', []),
'at_start_of_1st': ('2012-01-01T12:00:00Z', [p1]),
'after_start_of_1st': ('2012-01-01T12:00:01Z', [p1]),
'before_end_of_1st': ('2014-01-01T11:59:59Z', [p1]),
'between_1st_and_2nd': ('2014-01-01T12:00:00Z', [p1, p2]),
'after_start_of_2nd': ('2014-01-01T12:00:01Z', [p2]),
'before_end_of_2nd': ('2016-01-01T11:59:59Z', [p2]),
'at_end_of_2nd': ('2016-01-01T12:00:00Z', [p2]),
'less_than_15min_after_2nd': ('2016-01-01T12:14:59Z', [p2]),
'more_than_15min_after_2nd': ('2016-01-02T12:15:01Z', []),
'less_than_day_after_2nd': ('2016-01-01T22:00:00Z', []),
'more_than_day_after_2nd': ('2016-01-02T13:00:00Z', []),
'now': ('', [p3]),
}[name]
filtering = '&time={}'.format(time) if time else ''
response = get(staff_api_client, list_url_for_abc + filtering)
check_response_objects(response, expected_parkings)
评论列表
文章目录