Changeset View
Changeset View
Standalone View
Standalone View
swh/scheduler/tests/test_scheduler.py
Show First 20 Lines • Show All 738 Lines • ▼ Show 20 Lines | def test_grab_next_visits(self, swh_scheduler, listed_origins_by_type, policy): | ||||
swh_scheduler.record_listed_origins(origins) | swh_scheduler.record_listed_origins(origins) | ||||
before = utcnow() | before = utcnow() | ||||
ret = swh_scheduler.grab_next_visits(visit_type, NUM_RESULTS, policy=policy) | ret = swh_scheduler.grab_next_visits(visit_type, NUM_RESULTS, policy=policy) | ||||
after = utcnow() | after = utcnow() | ||||
assert len(ret) == NUM_RESULTS | assert len(ret) == NUM_RESULTS | ||||
for origin in ret: | for origin in ret: | ||||
assert before <= origin.last_scheduled <= after | visit_stats = swh_scheduler.origin_visit_stats_get( | ||||
origin.url, origin.visit_type | |||||
) | |||||
assert visit_stats is not None | |||||
assert before <= visit_stats.last_scheduled <= after | |||||
@pytest.mark.parametrize("policy", ["oldest_scheduled_first"]) | @pytest.mark.parametrize("policy", ["oldest_scheduled_first"]) | ||||
def test_grab_next_visits_underflow( | def test_grab_next_visits_underflow( | ||||
self, swh_scheduler, listed_origins_by_type, policy | self, swh_scheduler, listed_origins_by_type, policy | ||||
): | ): | ||||
NUM_RESULTS = 5 | NUM_RESULTS = 5 | ||||
visit_type = next(iter(listed_origins_by_type)) | visit_type = next(iter(listed_origins_by_type)) | ||||
assert len(listed_origins_by_type[visit_type]) > NUM_RESULTS | assert len(listed_origins_by_type[visit_type]) > NUM_RESULTS | ||||
▲ Show 20 Lines • Show All 224 Lines • Show Last 20 Lines |