-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16 from harisankar95/14-implement-visualization-f…
…or-path-plotting-with-grid-and-obstacles 14 implement visualization for path plotting with grid and obstacles
- Loading branch information
Showing
8 changed files
with
296 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import warnings | ||
|
||
import plotly | ||
import pytest | ||
|
||
from pathfinding3d.core.grid import Grid | ||
|
||
|
||
def test_visualize_without_plotly(mocker): | ||
""" | ||
Test visualize method when plotly is not installed | ||
""" | ||
mocker.patch("pathfinding3d.core.grid.USE_PLOTLY", False) | ||
mocker.patch("warnings.warn") | ||
|
||
grid = Grid(width=3, height=3, depth=3) | ||
grid.visualize() | ||
|
||
warnings.warn.assert_called_once_with("Plotly is not installed. Please install it to use this feature.") | ||
|
||
|
||
def test_visualize_with_plotly(mocker): | ||
""" | ||
Test visualize method when plotly is installed | ||
""" | ||
mocker.patch("pathfinding3d.core.grid.USE_PLOTLY", True) | ||
mocker.patch("plotly.graph_objects.Volume") | ||
mocker.patch("plotly.graph_objects.Scatter3d") | ||
mocker.patch("plotly.graph_objects.Layout") | ||
mocker.patch("plotly.graph_objects.Figure") | ||
mocker.patch("plotly.offline.plot") | ||
|
||
grid = Grid(width=3, height=3, depth=3) | ||
grid.visualize() | ||
|
||
plotly.graph_objects.Volume.assert_called() | ||
plotly.graph_objects.Figure.assert_called() | ||
|
||
|
||
def test_visualize_with_path(mocker): | ||
""" | ||
Test visualize method with a path | ||
""" | ||
mocker.patch("pathfinding3d.core.grid.USE_PLOTLY", True) | ||
mocker.patch("plotly.graph_objects.Volume") | ||
mocker.patch("plotly.graph_objects.Scatter3d") | ||
mocker.patch("plotly.graph_objects.Layout") | ||
mocker.patch("plotly.graph_objects.Figure") | ||
mocker.patch("plotly.offline.plot") | ||
|
||
grid = Grid(width=3, height=3, depth=3) | ||
path = [grid.node(0, 0, 0), grid.node(1, 1, 1), grid.node(2, 2, 2)] | ||
grid.visualize(path=path) | ||
|
||
plotly.graph_objects.Scatter3d.assert_called() | ||
plotly.graph_objects.Figure.assert_called() |