Skip to content

Commit 746c89f

Browse files
committed
tests: update visualization tests
1 parent 02f9969 commit 746c89f

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
"""Pytest configuration file."""
1919

20+
import webbrowser
21+
2022
import matplotlib
2123

2224
#
@@ -37,3 +39,12 @@ def no_plot_window(monkeypatch):
3739
monkeypatch.setattr(plt, "show", lambda: None)
3840
yield
3941
plt.close("all")
42+
43+
44+
@pytest.fixture
45+
def no_browser(monkeypatch):
46+
"""Fixture to prevent webbrowser from opening during tests."""
47+
monkeypatch.setattr(webbrowser, "open", lambda x: None)
48+
monkeypatch.setattr(webbrowser, "open_new", lambda x: None)
49+
monkeypatch.setattr(webbrowser, "open_new_tab", lambda x: None)
50+
yield

tests/test_visualization.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from pysits.sits.ml import sits_rfor, sits_train
2323
from pysits.sits.ts import sits_patterns, sits_som_map
2424
from pysits.sits.utils import r_package_dir
25-
from pysits.sits.visualization import sits_plot
25+
from pysits.sits.visualization import sits_plot, sits_view
2626

2727

2828
def test_sits_visualization(no_plot_window):
@@ -87,3 +87,21 @@ def test_classified_cube_visualization(no_plot_window):
8787

8888
# Plot the result
8989
sits_plot(cube)
90+
91+
92+
def test_sits_visualization_leaflet(no_browser):
93+
"""Test sits visualization."""
94+
sits_view(samples_l8_rondonia_2bands)
95+
96+
97+
def test_cube_visualization_leaflet(no_browser):
98+
"""Test cube visualization."""
99+
# Create a cube
100+
cube = sits_cube(
101+
source="BDC",
102+
collection="MOD13Q1-6.1",
103+
data_dir=r_package_dir("extdata/raster/mod13q1", package="sits"),
104+
)
105+
106+
# Plot the cube
107+
sits_view(cube)

0 commit comments

Comments
 (0)