-
-
Notifications
You must be signed in to change notification settings - Fork 307
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
Shreshth-Malik
wants to merge
15
commits into
OSGeo:main
Choose a base branch
from
Shreshth-Malik:r.circle-test
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+68
−0
Open
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
f8d7256
Added test script for r.buffer
Shreshth-Malik 7c35d81
Corrected input map and added tearDown method to delete temp maps
Shreshth-Malik cb4368f
Added pre commit fixes
Shreshth-Malik 78e090a
Merging r.buffer-test to main after passing pr tests
Shreshth-Malik 3757d4c
Merge pull request #1 from Shreshth-Malik/r.buffer-test
Shreshth-Malik 5f17994
Merge branch 'OSGeo:main' into main
Shreshth-Malik f782be7
Merge branch 'OSGeo:main' into r.buffer-test
Shreshth-Malik b231515
Added resolution for feedback
Shreshth-Malik 2d7c4ca
Added tests for r.circle tool
Shreshth-Malik 6086f56
Delete raster/r.buffer/testsuite directory
Shreshth-Malik 25bd2d9
Added test file for r.circle tool
Shreshth-Malik 49f43e4
Merge branch 'r.circle-test' of https://github.com/Shreshth-Malik/gra…
Shreshth-Malik 2784a5c
Reduced the region size
Shreshth-Malik 6574ae1
Reduced region size
Shreshth-Malik cca1407
Delete raster/r.buffer/testsuite directory
Shreshth-Malik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
@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() |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.