def test_filter_on_scheduling_horizon_no_horizon_applied_to_and(self): start = datetime(2011, 11, 1, 6, 0, 0) end = datetime(2011, 12, 1, 6, 0, 0) request1 = self.make_constrained_request(start=start, end=end) request2 = self.make_constrained_request(start=start, end=end) operator = 'and' requests = [request1, request2] request_group = self.make_request_group(requests, operator) request_groups = [request_group] scheduling_horizon = datetime(2011, 11, 15, 6, 0, 0) filtered_rgs = filter_on_scheduling_horizon(request_groups, scheduling_horizon) expected_window_start = start expected_window_end = end assert_equal(1, len(filtered_rgs)) output_ur = filtered_rgs[0] assert_equal(2, len(output_ur.requests)) bpl_1m0a_doma_windows1 = output_ur.requests[0].windows.at( '1m0a.doma.bpl') bpl_1m0a_doma_windows2 = output_ur.requests[0].windows.at( '1m0a.doma.bpl') assert_equal(1, len(bpl_1m0a_doma_windows1)) assert_equal(1, len(bpl_1m0a_doma_windows2)) assert_equal(bpl_1m0a_doma_windows1[0].start, expected_window_start) assert_equal(bpl_1m0a_doma_windows1[0].end, expected_window_end) assert_equal(bpl_1m0a_doma_windows2[0].start, expected_window_start) assert_equal(bpl_1m0a_doma_windows2[0].end, expected_window_end)
def test_filter_on_scheduling_horizon_applies_horizon_to_singles(self): start = datetime(2011, 11, 1, 6, 0, 0) end = datetime(2011, 12, 1, 6, 0, 0) request = self.make_constrained_request(start=start, end=end) operator = 'single' requests = [request] request_group = self.make_request_group(requests, operator) request_groups = [request_group] scheduling_horizon = datetime(2011, 11, 15, 6, 0, 0) filtered_rgs = filter_on_scheduling_horizon(request_groups, scheduling_horizon) expected_window_start = start expected_window_end = scheduling_horizon assert_equal(1, len(filtered_rgs)) output_ur = filtered_rgs[0] assert_equal(1, len(output_ur.requests)) bpl_1m0a_doma_windows = output_ur.requests[0].windows.at( '1m0a.doma.bpl') assert_equal(1, len(bpl_1m0a_doma_windows)) assert_equal(bpl_1m0a_doma_windows[0].start, expected_window_start) assert_equal(bpl_1m0a_doma_windows[0].end, expected_window_end)