Mock DEM retieval tests#223
Conversation
fnattino
left a comment
There was a problem hiding this comment.
Great! This would solve any problem with accessing the AWS data. I only wonder whether the first test is still meaningful after the mocking is introduced, I think we can remove it, see comment.
| with_mocked_bindings( | ||
| load_raster = function(...) { | ||
| bucharest_dem |> | ||
| terra::project("EPSG:4326") | ||
| }, | ||
| { | ||
| dem <- load_dem(bb, asset_urls, force_download = TRUE) | ||
|
|
||
| expect_equal(terra::crs(dem), terra::crs("EPSG:4326")) | ||
| expect_equal(as.vector(terra::ext(dem)), | ||
| as.vector(terra::ext(sf::st_bbox(bb))), | ||
| tolerance = 1.e-2) | ||
| } | ||
| ) |
There was a problem hiding this comment.
With mocking, I wonder whether this test is still meaningful - I think we could remove it.
Ultimately, load_dem here returns the raster we are passing in via the mocked binding, and then we verify properties of that same raster. In addition, due to the transformation from projected to geographic CRS you add some extra pixels at the edges, so you have to add quite a large tolerance to get this pass..
There was a problem hiding this comment.
I see, indeed, both the logic of mocking and the issue of tolerance due to the transformation make this useless. I will remove it.
There was a problem hiding this comment.
Feel free to merge afterwards!
There was a problem hiding this comment.
I also suppressed a couple of warnings and updated the release information. I know those are outside the scope of this PR, but I pushed them already. Let me know if this is okay now.
fnattino
left a comment
There was a problem hiding this comment.
Great! This would solve any problem with accessing the AWS data. I only wonder whether the first test is still meaningful after the mocking is introduced, I think we can remove it, see comment.
@fnattino, I mocked the two tests. Please have a look if this is what we need. Note that I had to decrease the precision in the
toleranceparameter in the first test to make it pass.