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

Merged
merged 20 commits into from
Nov 8, 2024
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
f8d7256
Added test script for r.buffer
Shreshth-Malik Oct 5, 2024
7c35d81
Corrected input map and added tearDown method to delete temp maps
Shreshth-Malik Oct 8, 2024
cb4368f
Added pre commit fixes
Shreshth-Malik Oct 9, 2024
78e090a
Merging r.buffer-test to main after passing pr tests
Shreshth-Malik Oct 9, 2024
3757d4c
Merge pull request #1 from Shreshth-Malik/r.buffer-test
Shreshth-Malik Oct 10, 2024
5f17994
Merge branch 'OSGeo:main' into main
Shreshth-Malik Oct 22, 2024
f782be7
Merge branch 'OSGeo:main' into r.buffer-test
Shreshth-Malik Oct 22, 2024
b231515
Added resolution for feedback
Shreshth-Malik Oct 23, 2024
2d7c4ca
Added tests for r.circle tool
Shreshth-Malik Oct 26, 2024
6086f56
Delete raster/r.buffer/testsuite directory
Shreshth-Malik Oct 26, 2024
25bd2d9
Added test file for r.circle tool
Shreshth-Malik Oct 26, 2024
49f43e4
Merge branch 'r.circle-test' of https://github.com/Shreshth-Malik/gra…
Shreshth-Malik Oct 26, 2024
2784a5c
Reduced the region size
Shreshth-Malik Nov 1, 2024
6574ae1
Reduced region size
Shreshth-Malik Nov 1, 2024
cca1407
Delete raster/r.buffer/testsuite directory
Shreshth-Malik Nov 1, 2024
73576c7
Update raster/r.circle/testsuite/test_circle.py
Shreshth-Malik Nov 2, 2024
da1452f
Merge branch 'main' into r.circle-test
echoix Nov 5, 2024
4d5f93b
Added test for multiplier
Shreshth-Malik Nov 6, 2024
b519b76
Merge branch 'r.circle-test' of https://github.com/Shreshth-Malik/gra…
Shreshth-Malik Nov 6, 2024
57fb1ef
Streamlined output map initialization
Shreshth-Malik Nov 7, 2024
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
85 changes: 85 additions & 0 deletions raster/r.circle/testsuite/test_circle.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
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):

petrasovaa marked this conversation as resolved.
Show resolved Hide resolved
@classmethod
def setUpClass(cls):
"""Set up a temporary region for testing."""
cls.output = "test_circle"
cls.use_temp_region()
cls.runModule("g.region", n=30, s=0, e=30, w=0, res=10)

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

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

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

module = SimpleModule(
"r.circle", output=self.output, coordinates=(15, 15), max=10, flags="b"
)

self.assertModule(module)

self.assertRasterExists(self.output)

self.assertRasterMinMax(
map=self.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."""

module = SimpleModule(
"r.circle", output=self.output, coordinates=(15, 15), max=10
)

self.assertModule(module)

self.assertRasterExists(self.output)

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

def test_create_circle_with_multiplier(self):
"""Test creating a circle with r.circle with a multiplier."""

module = SimpleModule(
"r.circle", output=self.output, coordinates=(15, 15), max=10, multiplier=2
)

self.assertModule(module)

self.assertRasterExists(self.output)

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


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