Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

r.circle: Add tests for raster circle tool #4598

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions raster/r.circle/testsuite/test_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
from grass.gunittest.case import TestCase
from grass.gunittest.main import test
import grass.script as gs
from grass.gunittest.gmodules import SimpleModule


class TestRCircle(TestCase):

@classmethod
def setUpClass(cls):
"""Set up a temporary region for testing."""
cls.use_temp_region()
cls.runModule("g.region", n=1000, s=0, e=1000, w=0, res=10)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is 100x100 the smallest needed to be able to test correctly this module?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have reduced the region size to a smaller size. Please let me know if there is some other feedback.


@classmethod
def tearDownClass(cls):
"""Clean up after tests."""
cls.del_temp_region()

def tearDown(self):
gs.run_command(
"g.remove",
type="raster",
name="test_circle_binary,test_circle_distance",
flags="f",
)

def test_create_circle_with_b_flag(self):
"""Test creating a binary circle with r.circle using -b flag."""
output = "test_circle_binary"

module = SimpleModule(
"r.circle", output=output, coordinates=(500, 500), max=100, flags="b"
)

self.assertModule(module)

self.assertRasterExists(output)

self.assertRasterMinMax(
map=output,
refmin=1,
refmax=1,
msg="Binary circle should have category value of 1",
)

def test_create_circle_without_b_flag(self):
"""Test creating a circle with r.circle without -b flag."""
output = "test_circle_distance"

module = SimpleModule(
"r.circle", output=output, coordinates=(500, 500), max=100
)

self.assertModule(module)

self.assertRasterExists(output)

self.assertRasterMinMax(
map=output,
refmin=0,
refmax=100,
msg="Circle should have distance values from 0 to 100",
)


if __name__ == "__main__":
test()
Loading