Adding a testcase

Hello developers,
I need some advise about adding a unittest.

I browsed through the docs but have not been able to find out how I can solve the following workflow.

I have a mini dataset (~40x60) and a set of input maps to the model. My idea would be to import these from the testcase folder then run the module and compare the resulting map with the one of the expected result.

Does this sound ok?
If yes, is there a module that does something similar to copy the workflow from?

Thanks,
Andrea

Yes, see e.g. grass/raster/r.sim/r.sim.sediment/testsuite at main · OSGeo/grass · GitHub

Let me know if you have more questions.

1 Like

Thanks a lot Anna, that made it really simple :slight_smile:

Is there a simple way to run the testcase locally or on the github fork?

Also, is it ok to start opening a PR, even if a few things are missing (ex a decent documentation page), maybe signalling it?

Cheers,
Andrea

You should be able to run it locally from the testsuite folder in active GRASS session, just by executing the python test file. Note that the unittests in CI run in EPSG 3358 (the NC state plane meters). If your data is in a different CRS, you treat it as XY data.
GitHub allows you to open the PR as a draft, that seems the best in your case.

You should be able to run it locally from the testsuite folder in active GRASS session, just by executing the python test file.

In that case it runs in the local mapset, right?

Note that the unittests in CI run in EPSG 3358 (the NC state plane meters). If your data is in a different CRS, you treat it as XY data.

Oh, what does “you treat it as XY data” mean? That I import the packs anyways and ignore the CRS? It would work for my case, just to be sure.

GitHub allows you to open the PR as a draft, that seems the best in your case.

Yes, true.
Thank you
Andrea

Yes, local mapset. On CI, each test file runs in a new mapset.

Yes, I basically meant ignoring CRS. If your data have projection info, you need to use e.g. -o flag to override the projection.

1 Like