Skip to content

Commit

Permalink
Add test case for plot chronological sort #153
Browse files Browse the repository at this point in the history
  • Loading branch information
tpaviot committed Dec 17, 2024
1 parent 72838b4 commit fdc244d
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,24 @@ def test_gantt_matplotlib_wrong_render_mode():
ps.render_gantt_matplotlib(solution, render_mode="foo", show_plot=False)


def test_gantt_matplotlib_sort_task_chronologically():
pb = ps.SchedulingProblem(name="SortTaskChronologically", horizon=20)
task_1 = ps.FixedDurationTask(name="task1", duration=3)
task_2 = ps.FixedDurationTask(name="task2", duration=4)
task_3 = ps.FixedDurationTask(name="task3", duration=5)
worker_1 = ps.Worker(name="Worker1")
task_1.add_required_resource(worker_1)
task_2.add_required_resource(worker_1)
task_3.add_required_resource(worker_1)
solver = ps.SchedulingSolver(problem=pb)
solution = solver.solve()
assert solution
with pytest.raises(ValueError):
ps.render_gantt_matplotlib(
solution, render_mode="foo", show_plot=False, sort_by_start=True
)


def test_gantt_plotly_base():
"""take the single task/single resource and display output"""
problem = ps.SchedulingProblem(name="RenderSolutionPlotly", horizon=7)
Expand Down Expand Up @@ -238,6 +256,24 @@ def test_gantt_plotly_raise_wrong_type():
ps.render_gantt_plotly(solution, render_mode="foo")


def test_gantt_plotly_sort_task_chronologically():
pb = ps.SchedulingProblem(name="PlotlySortTaskChronologically", horizon=20)
task_1 = ps.FixedDurationTask(name="task1", duration=3)
task_2 = ps.FixedDurationTask(name="task2", duration=4)
task_3 = ps.FixedDurationTask(name="task3", duration=5)
worker_1 = ps.Worker(name="Worker1")
task_1.add_required_resource(worker_1)
task_2.add_required_resource(worker_1)
task_3.add_required_resource(worker_1)
solver = ps.SchedulingSolver(problem=pb)
solution = solver.solve()
assert solution
with pytest.raises(ValueError):
ps.render_gantt_plotly(
solution, render_mode="foo", show_plot=False, sort_by_start=True
)


def test_gantt_with_buffers() -> None:
# one task that consumes and feed two different buffers
pb = ps.SchedulingProblem(name="PlotlyWithBuffers")
Expand Down

0 comments on commit fdc244d

Please sign in to comment.