diff --git a/.gitignore b/.gitignore index 2fdc256..f794d2f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,4 @@ __pycache__/ htmlcov/ dist/ *.egg-info/ -.tox/ - -tests/data/ \ No newline at end of file +.tox/ \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b3aa822..2655a35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -56,11 +56,13 @@ Additional arguments can be passed to `pytest` after the script name, e.g.: hatch run test:all -k feature ``` +Rendered HTML is tested using [pytest-regressions](https://pytest-regressions.readthedocs.io/en/latest/overview.html), which compares the current HTML output for each object to the previously recorded output. Tests will fail if the HTML output changes. If the change is correct (i.e. an update to the HTML formatting or a difference in object representations in Earth Engine), use the `--force-regen` argument to regenerate a new "reference" HTML output. + ### Building New Tests New features should have unit tests. If your test needs to use `getInfo` to retrieve data from an Earth Engine object, you'll need to use the caching system described below. -Using `getInfo` to retrieve data from an Earth Engine object can be slow and network-dependent. To speed up tests, `eerepr` uses a caching function `tests.cache.get_info` to load data. This function takes an Earth Engine object and either 1) retrieves its info from a local cache file if it has been used before, or 2) retrieves it from the server and adds it to the cache. The cache directory and file (`tests/data/data.json`) will be created automatically the first time tests are run. +Using `getInfo` to retrieve data from an Earth Engine object can be slow and network-dependent. To speed up tests, `eerepr` uses a caching function `tests.cache.get_info` to load data. This function takes an Earth Engine object and either 1) retrieves its info from a local cache file if it has been used before, or 2) retrieves it from the server and adds it to the cache. The cache directory and file (`tests/data/.cache.json`) will be created automatically the first time tests are run. To demonstrate, let's write a new dummy test that checks the properties of a custom `ee.Image`. @@ -75,6 +77,14 @@ def test_my_image(): assert "custom_property" in info["properties"] ``` -The first time the test is run, `getInfo` will be used to retrieve the image metadata and store it in `tests/data/data.json`. Subsequent runs will pull the data directly from the cache. +The first time the test is run, `getInfo` will be used to retrieve the image metadata and store it in `tests/data/.cache.json`. Subsequent runs will pull the data directly from the cache. Caches are kept locally and are not version-controlled. + +When a new object is added to regression testing, the first run will fail and generate a new reference file. Subsequent tests will pass. Output from regression testing *is* version controlled, so new outputs should be committed. + +### Previewing HTML Output -Caches are kept locally and are not version-controlled, so there's no need to commit newly added objects. \ No newline at end of file +Running the command below renders an HTML repr with a variety of different EE objects and opens it in the default web browser. Use this to visually compare results with outputs from the Code Editor. + +```bash +hatch run test:html +``` \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index e718d68..ff4bea8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,11 +38,13 @@ dependencies = ["pre-commit"] dependencies = [ "pytest", "pytest-cov", + "pytest-regressions", ] [tool.hatch.envs.test.scripts] all = "pytest . {args}" cov = "pytest . --cov=eerepr {args}" +html = "python tests/preview_html.py" [tool.ruff.lint] select = ["E", "I", "F", "B", "FA", "UP", "ISC", "PT", "Q", "RET", "SIM", "PERF"] diff --git a/tests/cache.py b/tests/cache.py index 2172564..df54d4c 100644 --- a/tests/cache.py +++ b/tests/cache.py @@ -4,7 +4,7 @@ import ee CACHE_DIR = Path(__file__).parent / "data/" -CACHE_PATH = CACHE_DIR / "data.json" +CACHE_PATH = CACHE_DIR / ".cache.json" def get_info(obj: ee.ComputedObject) -> dict: diff --git a/tests/data/.gitignore b/tests/data/.gitignore new file mode 100644 index 0000000..397fff6 --- /dev/null +++ b/tests/data/.gitignore @@ -0,0 +1,2 @@ +.cache.json +.preview.html \ No newline at end of file diff --git a/tests/data/test_regression_array_.yml b/tests/data/test_regression_array_.yml new file mode 100644 index 0000000..00c5558 --- /dev/null +++ b/tests/data/test_regression_array_.yml @@ -0,0 +1,6 @@ +'
  • ' diff --git a/tests/data/test_regression_band_dict_.yml b/tests/data/test_regression_band_dict_.yml new file mode 100644 index 0000000..2c2f5d8 --- /dev/null +++ b/tests/data/test_regression_band_dict_.yml @@ -0,0 +1,10 @@ +'
  • ' diff --git a/tests/data/test_regression_classifier_.yml b/tests/data/test_regression_classifier_.yml new file mode 100644 index 0000000..0f13815 --- /dev/null +++ b/tests/data/test_regression_classifier_.yml @@ -0,0 +1,3 @@ +
  • +... diff --git a/tests/data/test_regression_clusterer_.yml b/tests/data/test_regression_clusterer_.yml new file mode 100644 index 0000000..5d4dc76 --- /dev/null +++ b/tests/data/test_regression_clusterer_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_confusion_matrix_.yml b/tests/data/test_regression_confusion_matrix_.yml new file mode 100644 index 0000000..00c5558 --- /dev/null +++ b/tests/data/test_regression_confusion_matrix_.yml @@ -0,0 +1,6 @@ +'
  • ' diff --git a/tests/data/test_regression_constant_image_.yml b/tests/data/test_regression_constant_image_.yml new file mode 100644 index 0000000..dd036fb --- /dev/null +++ b/tests/data/test_regression_constant_image_.yml @@ -0,0 +1,16 @@ +'
  • ' diff --git a/tests/data/test_regression_date_.yml b/tests/data/test_regression_date_.yml new file mode 100644 index 0000000..5c0a907 --- /dev/null +++ b/tests/data/test_regression_date_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_daterange_.yml b/tests/data/test_regression_daterange_.yml new file mode 100644 index 0000000..bb8a44b --- /dev/null +++ b/tests/data/test_regression_daterange_.yml @@ -0,0 +1,6 @@ +'
  • ' diff --git a/tests/data/test_regression_dict_.yml b/tests/data/test_regression_dict_.yml new file mode 100644 index 0000000..fac8c43 --- /dev/null +++ b/tests/data/test_regression_dict_.yml @@ -0,0 +1,3 @@ +
  • +... diff --git a/tests/data/test_regression_feature_.yml b/tests/data/test_regression_feature_.yml new file mode 100644 index 0000000..75e43bd --- /dev/null +++ b/tests/data/test_regression_feature_.yml @@ -0,0 +1,8 @@ +'
  • ' diff --git a/tests/data/test_regression_feature_collection_.yml b/tests/data/test_regression_feature_collection_.yml new file mode 100644 index 0000000..231be8a --- /dev/null +++ b/tests/data/test_regression_feature_collection_.yml @@ -0,0 +1,15 @@ +'
  • ' diff --git a/tests/data/test_regression_filter_.yml b/tests/data/test_regression_filter_.yml new file mode 100644 index 0000000..c89e309 --- /dev/null +++ b/tests/data/test_regression_filter_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_image_collection_.yml b/tests/data/test_regression_image_collection_.yml new file mode 100644 index 0000000..580d791 --- /dev/null +++ b/tests/data/test_regression_image_collection_.yml @@ -0,0 +1,40 @@ +'
  • ' diff --git a/tests/data/test_regression_kernel_.yml b/tests/data/test_regression_kernel_.yml new file mode 100644 index 0000000..2ca6636 --- /dev/null +++ b/tests/data/test_regression_kernel_.yml @@ -0,0 +1,19 @@ +"
  • " diff --git a/tests/data/test_regression_linearring_.yml b/tests/data/test_regression_linearring_.yml new file mode 100644 index 0000000..6d2a848 --- /dev/null +++ b/tests/data/test_regression_linearring_.yml @@ -0,0 +1,13 @@ +'
  • ' diff --git a/tests/data/test_regression_linestring_.yml b/tests/data/test_regression_linestring_.yml new file mode 100644 index 0000000..839c7ad --- /dev/null +++ b/tests/data/test_regression_linestring_.yml @@ -0,0 +1,11 @@ +'
  • ' diff --git a/tests/data/test_regression_long_list_.yml b/tests/data/test_regression_long_list_.yml new file mode 100644 index 0000000..13caf4d --- /dev/null +++ b/tests/data/test_regression_long_list_.yml @@ -0,0 +1,16 @@ +
  • +... diff --git a/tests/data/test_regression_multilinestring_.yml b/tests/data/test_regression_multilinestring_.yml new file mode 100644 index 0000000..65b8f92 --- /dev/null +++ b/tests/data/test_regression_multilinestring_.yml @@ -0,0 +1,9 @@ +'
  • ' diff --git a/tests/data/test_regression_multipoint_.yml b/tests/data/test_regression_multipoint_.yml new file mode 100644 index 0000000..d856d36 --- /dev/null +++ b/tests/data/test_regression_multipoint_.yml @@ -0,0 +1,8 @@ +'
  • ' diff --git a/tests/data/test_regression_multipolygon_.yml b/tests/data/test_regression_multipolygon_.yml new file mode 100644 index 0000000..8843aa9 --- /dev/null +++ b/tests/data/test_regression_multipolygon_.yml @@ -0,0 +1,26 @@ +'
  • ' diff --git a/tests/data/test_regression_null_feature_.yml b/tests/data/test_regression_null_feature_.yml new file mode 100644 index 0000000..56a0652 --- /dev/null +++ b/tests/data/test_regression_null_feature_.yml @@ -0,0 +1,4 @@ +'
  • ' diff --git a/tests/data/test_regression_number_.yml b/tests/data/test_regression_number_.yml new file mode 100644 index 0000000..577b3cd --- /dev/null +++ b/tests/data/test_regression_number_.yml @@ -0,0 +1,2 @@ +
  • 42
  • +... diff --git a/tests/data/test_regression_pixel_custom_.yml b/tests/data/test_regression_pixel_custom_.yml new file mode 100644 index 0000000..bf1ff70 --- /dev/null +++ b/tests/data/test_regression_pixel_custom_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_double_.yml b/tests/data/test_regression_pixel_double_.yml new file mode 100644 index 0000000..d8c3140 --- /dev/null +++ b/tests/data/test_regression_pixel_double_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_float_.yml b/tests/data/test_regression_pixel_float_.yml new file mode 100644 index 0000000..8a7e393 --- /dev/null +++ b/tests/data/test_regression_pixel_float_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_int16_.yml b/tests/data/test_regression_pixel_int16_.yml new file mode 100644 index 0000000..567ad52 --- /dev/null +++ b/tests/data/test_regression_pixel_int16_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_int32_.yml b/tests/data/test_regression_pixel_int32_.yml new file mode 100644 index 0000000..3ccfd30 --- /dev/null +++ b/tests/data/test_regression_pixel_int32_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_int64_.yml b/tests/data/test_regression_pixel_int64_.yml new file mode 100644 index 0000000..13118f9 --- /dev/null +++ b/tests/data/test_regression_pixel_int64_.yml @@ -0,0 +1,6 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_int8_.yml b/tests/data/test_regression_pixel_int8_.yml new file mode 100644 index 0000000..5888a51 --- /dev/null +++ b/tests/data/test_regression_pixel_int8_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_uint16_.yml b/tests/data/test_regression_pixel_uint16_.yml new file mode 100644 index 0000000..745b190 --- /dev/null +++ b/tests/data/test_regression_pixel_uint16_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_uint32_.yml b/tests/data/test_regression_pixel_uint32_.yml new file mode 100644 index 0000000..49dca5e --- /dev/null +++ b/tests/data/test_regression_pixel_uint32_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_pixel_uint8_.yml b/tests/data/test_regression_pixel_uint8_.yml new file mode 100644 index 0000000..eece559 --- /dev/null +++ b/tests/data/test_regression_pixel_uint8_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_point_.yml b/tests/data/test_regression_point_.yml new file mode 100644 index 0000000..7fc1268 --- /dev/null +++ b/tests/data/test_regression_point_.yml @@ -0,0 +1,5 @@ +'
  • ' diff --git a/tests/data/test_regression_polygon_.yml b/tests/data/test_regression_polygon_.yml new file mode 100644 index 0000000..90b1092 --- /dev/null +++ b/tests/data/test_regression_polygon_.yml @@ -0,0 +1,14 @@ +'
  • ' diff --git a/tests/data/test_regression_projection_.yml b/tests/data/test_regression_projection_.yml new file mode 100644 index 0000000..bffbc16 --- /dev/null +++ b/tests/data/test_regression_projection_.yml @@ -0,0 +1,8 @@ +'
  • ' diff --git a/tests/data/test_regression_reducer_.yml b/tests/data/test_regression_reducer_.yml new file mode 100644 index 0000000..e87c4a1 --- /dev/null +++ b/tests/data/test_regression_reducer_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_short_list_.yml b/tests/data/test_regression_short_list_.yml new file mode 100644 index 0000000..d3ef9f7 --- /dev/null +++ b/tests/data/test_regression_short_list_.yml @@ -0,0 +1,5 @@ +
  • +... diff --git a/tests/data/test_regression_string_.yml b/tests/data/test_regression_string_.yml new file mode 100644 index 0000000..e40d816 --- /dev/null +++ b/tests/data/test_regression_string_.yml @@ -0,0 +1,2 @@ +
  • 13th Warrior is an underrated movie
  • +... diff --git a/tests/data/test_regression_type_dict_.yml b/tests/data/test_regression_type_dict_.yml new file mode 100644 index 0000000..5a6c43a --- /dev/null +++ b/tests/data/test_regression_type_dict_.yml @@ -0,0 +1,4 @@ +
  • +... diff --git a/tests/data/test_regression_unbounded_band_dict_.yml b/tests/data/test_regression_unbounded_band_dict_.yml new file mode 100644 index 0000000..c880ecf --- /dev/null +++ b/tests/data/test_regression_unbounded_band_dict_.yml @@ -0,0 +1,6 @@ +'
  • ' diff --git a/tests/preview_html.py b/tests/preview_html.py new file mode 100644 index 0000000..b78cc6e --- /dev/null +++ b/tests/preview_html.py @@ -0,0 +1,27 @@ +import webbrowser + +import ee + +from eerepr.repr import _repr_html_ +from tests.cache import CACHE_DIR + + +def preview_html_output(): + from tests.test_html import get_test_objects + + objects = get_test_objects().items() + + rendered = _repr_html_(ee.List([obj[1] for obj in objects])) + + CACHE_DIR.mkdir(parents=True, exist_ok=True) + preview_path = CACHE_DIR / ".preview.html" + with open(preview_path, "w") as f: + f.write(rendered) + + webbrowser.open(f"file://{preview_path}") + print(f"Rendered HTML output to {preview_path}") + + +if __name__ == "__main__": + ee.Initialize() + preview_html_output() diff --git a/tests/test_html.py b/tests/test_html.py index ce633de..f7e671a 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1,227 +1,100 @@ +from pathlib import Path + import ee +import pytest from eerepr.html import convert_to_html from tests.cache import get_info -def test_image(): - obj = ee.Image.constant(0).set("system:id", "foo") - info = get_info(obj) - rep = convert_to_html(info) - assert "Image foo (1 band)" in rep - assert "bands: List (1 element)" in rep - assert "crs_transform: [1, 0, 0, 0, 1, 0]" in rep - - -def test_imagecollection(): - obj = ee.ImageCollection( - [ - ee.Image.constant(0), - ee.Image.constant(1), - ] - ).set("test_prop", 42) - info = get_info(obj) - rep = convert_to_html(info) - - assert "ImageCollection (2 elements)" in rep - assert "properties: Object (1 property)" in rep - assert "features: List (2 elements)" in rep - - -def test_feature(): - obj = ee.Feature(geom=ee.Geometry.Point([0, 0]), opt_properties={"foo": "bar"}) - info = get_info(obj) - rep = convert_to_html(info) - - assert "Feature (Point, 1 property)" in rep - - -def test_empty_feature(): - obj = ee.Feature(None) - info = get_info(obj) - rep = convert_to_html(info) - - assert "Feature (0 properties)" in rep - - -def test_featurecollection(): - feat = ee.Feature(geom=ee.Geometry.Point([0, 0]), opt_properties={"foo": "bar"}) - obj = ee.FeatureCollection([feat]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "FeatureCollection (1 element, 2 columns)" in rep - - -def test_date(): - obj = ee.Date("2021-03-27T14:01:07") - info = get_info(obj) - rep = convert_to_html(info) - - assert "Date" in rep - assert "2021-03-27 14:01:07" in rep - - -def test_filter(): - obj = ee.Filter.eq("foo", "bar") - info = get_info(obj) - rep = convert_to_html(info) - - assert "Filter.eq" in rep - - -def test_dict(): - obj = ee.Dictionary({"foo": "bar"}) - info = get_info(obj) - rep = convert_to_html(info) - - assert "Object (1 property)" in rep - - -def test_list(): - short_obj = ee.List([1, 2, 3, 4]) - short_info = get_info(short_obj) - short_rep = convert_to_html(short_info) - assert "[1, 2, 3, 4]" in short_rep - - long_obj = ee.List.sequence(0, 20, 1) - long_info = get_info(long_obj) - long_rep = convert_to_html(long_info) - assert "List (21 elements)" in long_rep - - -def test_string(): - obj = ee.String("13th Warrior is an underrated movie") - info = get_info(obj) - rep = convert_to_html(info) - - assert "13th Warrior is an underrated movie" in rep - - -def test_number(): - obj = ee.Number(42) - info = get_info(obj) - rep = convert_to_html(info) - - assert "42" in rep - - -def test_point(): - obj = ee.Geometry.Point([1.112312, 2]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "Point (1.11, 2.00)" in rep - - -def test_multipoint(): - obj = ee.Geometry.MultiPoint([[1, 1], [2, 2]]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "MultiPoint (2 vertices)" in rep - - -def test_linestring(): - obj = ee.Geometry.LineString([[1, 1], [2, 2], [3, 3]]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "LineString (3 vertices)" in rep - - -def test_multilinestring(): - obj = ee.Geometry.MultiLineString([[[0, 0], [1, 1]]]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "MultiLineString" in rep - - -def test_polygon(): - obj = ee.Geometry.Polygon([[0, 0], [1, 1], [2, 2], [0, 0]]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "Polygon (4 vertices)" in rep - - -def test_multipolygon(): - obj = ee.Geometry.MultiPolygon( - [ - [[0, 0], [1, 1], [2, 2], [0, 0]], - [[4, 6], [3, 2], [1, 2], [4, 6]], - ] - ) - info = get_info(obj) - rep = convert_to_html(info) - - assert "MultiPolygon (8 vertices)" in rep - - -def test_linearring(): - obj = ee.Geometry.LinearRing([[0, 0], [1, 1], [2, 2], [0, 0]]) - info = get_info(obj) - rep = convert_to_html(info) - - assert "LinearRing (4 vertices)" in rep - - -def test_daterange(): - obj = ee.DateRange("2020-01-01T21:01:10", "2022-03-01T14:32:11") - info = get_info(obj) - rep = convert_to_html(info) - - assert "DateRange [2020-01-01 21:01:10, 2022-03-01 14:32:11]" in rep - - -def test_typed_obj(): - obj = ee.Dictionary({"type": "Foo", "id": "bar"}) - info = get_info(obj) - rep = convert_to_html(info) - - assert "Foo bar" in rep - - -def test_band(): - band_id = "B1" - data_type = {"type": "PixelType", "precision": "int", "min": 0, "max": 65535} - dimensions = [1830, 1830] - crs = "EPSG:32610" - - band1 = ee.Dictionary( - { - "id": band_id, - "data_type": data_type, - "dimensions": dimensions, - "crs": crs, - } - ) - band1_info = get_info(band1) - band1_rep = convert_to_html(band1_info) - assert '"B1", unsigned int16, EPSG:32610, 1830x1830 px' in band1_rep - - band2 = ee.Dictionary( - { - "id": band_id, - "data_type": data_type, - } - ) - band2_info = get_info(band2) - band2_rep = convert_to_html(band2_info) - assert '"B1", unsigned int16' in band2_rep - - -def test_pixel_types(): - assert "float" in convert_to_html(get_info(ee.PixelType.float())) - assert "double" in convert_to_html(get_info(ee.PixelType.double())) - assert "signed int8" in convert_to_html(get_info(ee.PixelType.int8())) - assert "unsigned int8" in convert_to_html(get_info(ee.PixelType.uint8())) - assert "signed int16" in convert_to_html(get_info(ee.PixelType.int16())) - assert "unsigned int16" in convert_to_html(get_info(ee.PixelType.uint16())) - assert "signed int32" in convert_to_html(get_info(ee.PixelType.int32())) - assert "unsigned int32" in convert_to_html(get_info(ee.PixelType.uint32())) - assert "signed int64" in convert_to_html(get_info(ee.PixelType.int64())) - - custom_type = dict(type="PixelType", min=10, max=255, precision="int") - assert "int ∈ [10, 255]" in convert_to_html(get_info(ee.Dictionary(custom_type))) +def get_test_objects() -> list: + return { + "constant_image": ee.Image.constant(0).set("system:id", "foo"), + "image_collection": ee.ImageCollection( + [ + ee.Image.constant(0), + ee.Image.constant(1), + ] + ).set("test_prop", 42), + "feature": ee.Feature( + geom=ee.Geometry.Point([0, 0]), opt_properties={"foo": "bar"} + ), + "null_feature": ee.Feature(None), + "feature_collection": ee.FeatureCollection( + [ee.Feature(geom=ee.Geometry.Point([0, 0]), opt_properties={"foo": "bar"})] + ), + "date": ee.Date("2021-03-27T14:01:07"), + "filter": ee.Filter.eq("foo", "bar"), + "dict": ee.Dictionary({"foo": "bar"}), + "short_list": ee.List([1, 2, 3, 4]), + "long_list": ee.List.sequence(0, 20, 1), + "string": ee.String("13th Warrior is an underrated movie"), + "number": ee.Number(42), + "point": ee.Geometry.Point([1.112312, 2]), + "multipoint": ee.Geometry.MultiPoint([[1, 1], [2, 2]]), + "linestring": ee.Geometry.LineString([[1, 1], [2, 2], [3, 3]]), + "multilinestring": ee.Geometry.MultiLineString([[[0, 0], [1, 1]]]), + "polygon": ee.Geometry.Polygon([[0, 0], [1, 1], [2, 2], [0, 0]]), + "multipolygon": ee.Geometry.MultiPolygon( + [ + [[0, 0], [1, 1], [2, 2], [0, 0]], + [[4, 6], [3, 2], [1, 2], [4, 6]], + ] + ), + "linearring": ee.Geometry.LinearRing([[0, 0], [1, 1], [2, 2], [0, 0]]), + "daterange": ee.DateRange("2020-01-01T21:01:10", "2022-03-01T14:32:11"), + "type_dict": ee.Dictionary({"type": "Foo", "id": "bar"}), + "band_dict": ee.Dictionary( + { + "id": "B1", + "data_type": { + "type": "PixelType", + "precision": "int", + "min": 0, + "max": 65535, + }, + "dimensions": [1830, 1830], + "crs": "EPSG:32610", + } + ), + "unbounded_band_dict": ee.Dictionary( + { + "id": "B1", + "data_type": { + "type": "PixelType", + "precision": "int", + "min": 0, + "max": 65535, + }, + } + ), + "pixel_float": ee.PixelType.float(), + "pixel_double": ee.PixelType.double(), + "pixel_int8": ee.PixelType.int8(), + "pixel_uint8": ee.PixelType.uint8(), + "pixel_int16": ee.PixelType.int16(), + "pixel_uint16": ee.PixelType.uint16(), + "pixel_int32": ee.PixelType.int32(), + "pixel_uint32": ee.PixelType.uint32(), + "pixel_int64": ee.PixelType.int64(), + "pixel_custom": ee.Dictionary( + dict(type="PixelType", min=10, max=255, precision="int") + ), + "clusterer": ee.Clusterer.wekaKMeans(2), + "classifier": ee.Classifier.smileKNN(), + "array": ee.Array([[1, 2], [3, 4]]), + "confusion_matrix": ee.ConfusionMatrix(ee.Array([[1, 2], [3, 4]])), + "kernel": ee.Kernel.gaussian(3), + "projection": ee.Projection("EPSG:5070").atScale(100), + "reducer": ee.Reducer.max(5), + } + + +@pytest.fixture(scope="session") +def original_datadir(): + return Path(__file__).parent / "data" + + +@pytest.mark.parametrize("key_val", get_test_objects().items(), ids=lambda kv: kv[0]) +def test_regression(key_val, data_regression): + data_regression.check(convert_to_html(get_info(key_val[1])))