Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove obsolete tests #122

Merged
merged 3 commits into from
Feb 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 0 additions & 97 deletions test/instance_validity_test.rb

This file was deleted.

60 changes: 34 additions & 26 deletions test/models/vrp_consistency_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -153,32 +153,6 @@ def test_point_id_not_defined
assert_equal('Couldn\'t find Models::Point with ID=missing_point_id', exception.message)
end

def test_same_point_day_authorized
vrp = VRP.scheduling
reference_point = vrp[:services].first[:activity][:point_id]
vrp[:services].first[:visits_number] = 3
vrp[:services].first[:minimum_lapse] = 3
vrp[:services].first[:maximum_lapse] = 3
vrp[:services] << {
id: 'last_service',
visits_number: 2,
minimum_lapse: 6,
maximum_lapse: 6,
activity: {
point_id: reference_point
}
}
vrp[:configuration][:resolution][:same_point_day] = true
vrp[:configuration][:schedule][:range_indices][:end] = 10
result = OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:demo] }}, TestHelper.create(vrp), nil)
assert result # there exist a common_divisor

vrp[:services].last[:minimum_lapse] = vrp[:services].last[:maximum_lapse] = 7
assert_raises OptimizerWrapper::UnsupportedProblemError do
OptimizerWrapper.wrapper_vrp('demo', { services: { vrp: [:demo] }}, TestHelper.create(vrp), nil)
end
end

def test_reject_if_shipments_and_periodic_heuristic
vrp = VRP.pud
vrp[:configuration][:preprocessing][:first_solution_strategy] = 'periodic'
Expand Down Expand Up @@ -216,5 +190,39 @@ def test_assert_missions_in_route_exist
TestHelper.create(problem)
end
end

def test_reject_if_several_visits_but_no_schedule_provided
# If this test fail then it probably returns 'Wrong number of visits returned in result'
# This makes sense, since we do not expand the problem if no schedule is provided,
# therefore there is a gap between expected and returned number of visits
vrp = VRP.toy
vrp[:services][0][:visits_number] = 10

assert_raises OptimizerWrapper::DiscordantProblemError do
TestHelper.create(vrp)
end

vrp[:configuration][:schedule] = { range_indices: { start: 0, end: 10 } }
assert TestHelper.create(vrp) # no raise when schedule is provided

vrp = VRP.pud
vrp[:shipments][0][:visits_number] = 10

assert_raises OptimizerWrapper::DiscordantProblemError do
TestHelper.create(vrp)
end

vrp[:configuration][:schedule] = { range_indices: { start: 0, end: 10 } }
assert TestHelper.create(vrp) # no raise when no schedule is provided
end

def test_incorrect_matrix_indices
problem = VRP.basic
problem[:points] << { id: 'point_4', matrix_index: 4 }

assert_raises OptimizerWrapper::DiscordantProblemError do
TestHelper.create(problem)
end
end
end
end
25 changes: 0 additions & 25 deletions test/models/vrp_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,30 +261,5 @@ def test_transform_route_indice_into_index
assert vrp.routes.first.day_index
assert_equal 10, vrp.routes.first.day_index
end

def test_reject_if_several_visits_but_no_schedule_provided
# If this test fail then it probably returns 'Wrong number of visits returned in result'
# This makes sense, since we do not expand the problem if no schedule is provided,
# therefore there is a gap between expected and returned number of visits
vrp = VRP.toy
vrp[:services][0][:visits_number] = 10

assert_raises OptimizerWrapper::DiscordantProblemError do
TestHelper.create(vrp)
end

vrp[:configuration][:schedule] = { range_indices: { start: 0, end: 10 } }
assert TestHelper.create(vrp) # no raise when schedule is provided

vrp = VRP.pud
vrp[:shipments][0][:visits_number] = 10

assert_raises OptimizerWrapper::DiscordantProblemError do
TestHelper.create(vrp)
end

vrp[:configuration][:schedule] = { range_indices: { start: 0, end: 10 } }
assert TestHelper.create(vrp) # no raise when no schedule is provided
end
end
end
84 changes: 68 additions & 16 deletions test/wrapper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2976,22 +2976,6 @@ def test_impossible_minimum_lapse_opened_days
assert_equal(2, result.count{ |un| un[:reason] == 'Unconsistency between visit number and minimum lapse' })
end

def test_impossible_lapse_advanced
vrp = VRP.scheduling
vrp[:services].first[:visits_number] = 2
vrp[:services].first[:minimum_lapse] = 1
vrp[:vehicles].first[:timewindow][:day_index] = 0
vrp[:vehicles] << {
id: 'fake vehicle',
timewindow: { day_index: 1 }
}
vrp[:configuration][:preprocessing][:partitions] = TestHelper.vehicle_and_days_partitions

# we split by work_day, each vehicle will only drive one day in the schedule so it is not possible to affect service with two visits
assert_equal 2, OptimizerWrapper.config[:services][:ortools].detect_unfeasible_services(TestHelper.create(vrp)).size
assert_equal 1, OptimizerWrapper.config[:services][:ortools].detect_unfeasible_services(TestHelper.create(vrp)).uniq{ |un| un[:original_service_id] }.size
end

def test_impossible_minimum_lapse_opened_days_real_case
vrp = TestHelper.load_vrp(self, fixture_file: 'real_case_impossible_visits_because_lapse')
result = OptimizerWrapper.config[:services][:demo].detect_unfeasible_services(vrp)
Expand Down Expand Up @@ -3204,4 +3188,72 @@ def test_empty_result_when_no_mission

assert_equal 2, result[:routes].size
end

def test_assert_inapplicable_for_vroom_if_vehicle_distance
fonsecadeline marked this conversation as resolved.
Show resolved Hide resolved
problem = VRP.basic
problem[:vehicles].first[:distance] = 10

vrp = TestHelper.create(problem)
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_no_distance_limitation
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_no_distance_limitation
end

def test_assert_inapplicable_vroom_with_periodic_heuristic
problem = VRP.scheduling
problem[:services].first[:visits_number] = 2

assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(TestHelper.create(problem)), :assert_only_one_visit
end

def test_assert_applicable_for_vroom_if_initial_routes
braktar marked this conversation as resolved.
Show resolved Hide resolved
problem = VRP.basic
problem[:routes] = [{
mission_ids: ['service_1']
}]
vrp = TestHelper.create(problem)
assert_empty OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp)
end

def test_assert_inapplicable_relations
problem = VRP.basic
problem[:relations] = [{
type: 'vehicle_group_duration',
linked_ids: [],
linked_vehicle_ids: [],
lapse: nil
}]

vrp = TestHelper.create(problem)
refute_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_no_relations
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_no_relations
fonsecadeline marked this conversation as resolved.
Show resolved Hide resolved

problem[:relations] = [{
type: 'vehicle_group_duration',
linked_ids: ['vehicle_0'],
linked_vehicle_ids: [],
lapse: nil
}]

vrp = TestHelper.create(problem)
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_no_relations
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_no_relations
end

def test_solver_needed
problem = VRP.basic
problem[:configuration][:resolution][:solver] = false

vrp = TestHelper.create(problem)
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_solver
assert_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_solver_if_not_periodic
end

def test_first_solution_acceptance_with_solvers
problem = VRP.basic
problem[:configuration][:preprocessing][:first_solution_strategy] = [1]

vrp = TestHelper.create(problem)
assert_includes OptimizerWrapper.config[:services][:vroom].inapplicable_solve?(vrp), :assert_no_first_solution_strategy
refute_includes OptimizerWrapper.config[:services][:ortools].inapplicable_solve?(vrp), :assert_no_first_solution_strategy
end
end