|
2 | 2 | from odc.stats.plugins._utils import generate_numexpr_expressions
|
3 | 3 |
|
4 | 4 | import re
|
| 5 | +import os |
5 | 6 | import numpy as np
|
6 | 7 | import pandas as pd
|
7 | 8 | import xarray as xr
|
8 | 9 | import dask.array as da
|
9 | 10 | from datacube.utils.geometry import GeoBox
|
10 | 11 | from affine import Affine
|
| 12 | +from unittest.mock import patch |
| 13 | + |
11 | 14 |
|
12 | 15 | import pytest
|
13 | 16 |
|
@@ -178,27 +181,35 @@ def test_l4_classes(image_groups, urban_shape):
|
178 | 181 | expected_l3 = [[216, 216, 215], [216, 216, 216], [220, 215, 215], [220, 220, 220]]
|
179 | 182 |
|
180 | 183 | expected_l4 = [[95, 97, 93], [97, 96, 96], [100, 93, 93], [101, 101, 101]]
|
181 |
| - stats_l4 = StatsLccsLevel4( |
182 |
| - measurements=["level3", "level4"], |
183 |
| - class_def_path="s3://dea-public-data-dev/lccs_validation/c3/data_to_plot/" |
184 |
| - "lccs_colour_scheme_golden_dark_au_c3.csv", |
185 |
| - class_condition={ |
186 |
| - "level3": ["level1", "artificial_surface", "cultivated"], |
187 |
| - "level4": [ |
188 |
| - "level1", |
189 |
| - "level3", |
190 |
| - "woody", |
191 |
| - "water_season", |
192 |
| - "water_frequency", |
193 |
| - "pv_pc_50", |
194 |
| - "bs_pc_50", |
195 |
| - ], |
| 184 | + with patch.dict( |
| 185 | + os.environ, |
| 186 | + { |
| 187 | + "AWS_ACCESS_KEY_ID": "fake-access-key", |
| 188 | + "AWS_SECRET_ACCESS_KEY": "fake-secret-key", |
| 189 | + "AWS_SESSION_TOKEN": "fake-session-token", # Optional |
196 | 190 | },
|
197 |
| - data_var_condition={"level1": "level_3_4"}, |
198 |
| - urban_mask=urban_shape, |
199 |
| - filter_expression="mock > 9", |
200 |
| - mask_threshold=0.3, |
201 |
| - ) |
| 191 | + ): |
| 192 | + stats_l4 = StatsLccsLevel4( |
| 193 | + measurements=["level3", "level4"], |
| 194 | + class_def_path="s3://dea-public-data-dev/lccs_validation/c3/data_to_plot/" |
| 195 | + "lccs_colour_scheme_golden_dark_au_c3.csv", |
| 196 | + class_condition={ |
| 197 | + "level3": ["level1", "artificial_surface", "cultivated"], |
| 198 | + "level4": [ |
| 199 | + "level1", |
| 200 | + "level3", |
| 201 | + "woody", |
| 202 | + "water_season", |
| 203 | + "water_frequency", |
| 204 | + "pv_pc_50", |
| 205 | + "bs_pc_50", |
| 206 | + ], |
| 207 | + }, |
| 208 | + data_var_condition={"level1": "level_3_4"}, |
| 209 | + urban_mask=urban_shape, |
| 210 | + filter_expression="mock > 9", |
| 211 | + mask_threshold=0.3, |
| 212 | + ) |
202 | 213 | ds = stats_l4.reduce(image_groups)
|
203 | 214 |
|
204 | 215 | assert (ds.level3.compute() == expected_l3).all()
|
|
0 commit comments