Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
14 changes: 7 additions & 7 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,32 +139,32 @@ jobs:
id: cached-data
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: sample-data/nc_spm_full_v2alpha2.tar.gz
key: nc_spm_full_v2alpha2.tar.gz
path: sample-data/nc_spm_full_v2beta1.tar.gz
key: nc_spm_full_v2beta1.tar.gz
enableCrossOsArchive: true

- name: Download GRASS Sample Dataset
if: steps.cached-data.outputs.cache-hit != 'true'
run: |
mkdir -p sample-data
curl -L "$SAMPLE_DATA" -o sample-data/nc_spm_full_v2alpha2.tar.gz
curl -L "$SAMPLE_DATA" -o sample-data/nc_spm_full_v2beta1.tar.gz
env:
SAMPLE_DATA: "https://grass.osgeo.org/sampledata/north_carolina/\
nc_spm_full_v2alpha2.tar.gz"
nc_spm_full_v2beta1.tar.gz"

- name: Save GRASS Sample Dataset to cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
if: steps.cached-data.outputs.cache-hit != 'true'
with:
path: sample-data/nc_spm_full_v2alpha2.tar.gz
key: nc_spm_full_v2alpha2.tar.gz
path: sample-data/nc_spm_full_v2beta1.tar.gz
key: nc_spm_full_v2beta1.tar.gz

- name: Run gunittest tests
shell: micromamba-shell {0}
run: .github/workflows/test_thorough.sh --config .github/workflows/macos_gunittest.cfg
env:
SAMPLE_DATA_URL: "file://${{ github.workspace }}/sample-data/\
nc_spm_full_v2alpha2.tar.gz"
nc_spm_full_v2beta1.tar.gz"

- name: Make HTML test report available
if: ${{ !cancelled() }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_thorough.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
set grass=%1
set python=%2

call %grass% --tmp-project XY --exec g.download.project url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=%USERPROFILE%
call %grass% --tmp-project XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2alpha2 --location-type nc --min-success 97.3 --config .github\workflows\osgeo4w_gunittest.cfg
call %grass% --tmp-project XY --exec g.download.project url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2beta1.tar.gz path=%USERPROFILE%
call %grass% --tmp-project XY --exec %python% -m grass.gunittest.main --grassdata %USERPROFILE% --location nc_spm_full_v2beta1 --location-type nc --min-success 97.3 --config .github\workflows\osgeo4w_gunittest.cfg
4 changes: 2 additions & 2 deletions .github/workflows/test_thorough.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# fail on non-zero return code from a subprocess
set -e

SAMPLE_DATA_URL=${SAMPLE_DATA_URL:-"https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz"}
SAMPLE_DATA_URL=${SAMPLE_DATA_URL:-"https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2beta1.tar.gz"}

grass --tmp-project XY --exec \
g.download.project url=$SAMPLE_DATA_URL path=$HOME

grass --tmp-project XY --exec \
python3 -m grass.gunittest.main \
--grassdata $HOME --location nc_spm_full_v2alpha2 --location-type nc \
--grassdata $HOME --location nc_spm_full_v2beta1 --location-type nc \
--min-success 100 $@
14 changes: 7 additions & 7 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,31 +157,31 @@ jobs:
id: cached-data
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
with:
path: sample-data/nc_spm_full_v2alpha2.tar.gz
key: nc_spm_full_v2alpha2.tar.gz
path: sample-data/nc_spm_full_v2beta1.tar.gz
key: nc_spm_full_v2beta1.tar.gz
enableCrossOsArchive: true

- name: Download GRASS Sample Dataset
if: steps.cached-data.outputs.cache-hit != 'true'
run: |
mkdir -p sample-data
curl -L "${SAMPLE_DATA}" -o sample-data/nc_spm_full_v2alpha2.tar.gz
curl -L "${SAMPLE_DATA}" -o sample-data/nc_spm_full_v2beta1.tar.gz
env:
SAMPLE_DATA: "https://grass.osgeo.org/sampledata/north_carolina/\
nc_spm_full_v2alpha2.tar.gz"
nc_spm_full_v2beta1.tar.gz"

- name: Save GRASS Sample Dataset to cache
uses: actions/cache/save@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
if: steps.cached-data.outputs.cache-hit != 'true'
with:
path: sample-data/nc_spm_full_v2alpha2.tar.gz
key: nc_spm_full_v2alpha2.tar.gz
path: sample-data/nc_spm_full_v2beta1.tar.gz
key: nc_spm_full_v2beta1.tar.gz

- name: Run tests
run: .github/workflows/test_thorough.sh --config .gunittest.extra.cfg
env:
SAMPLE_DATA_URL: "file://${{ github.workspace }}/sample-data/\
nc_spm_full_v2alpha2.tar.gz"
nc_spm_full_v2beta1.tar.gz"

- name: Make HTML test report available
if: ${{ always() }}
Expand Down
1 change: 1 addition & 0 deletions general/g.proj/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,7 @@ static int check_xy(enum OutputFormat format)
return 0;
}

/* TODO: use proj_as_projjson() from proj */
void print_json(G_JSON_Value *value)
{
char *serialized_string = G_json_serialize_to_string_pretty(value);
Expand Down
48 changes: 38 additions & 10 deletions general/g.proj/testsuite/test_g_proj.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,29 @@ class GProjTestCase(TestCase):
"""Test cases for g.proj module."""

# Expected projection keys for different outputs
reference = [
# note that proj lib definition is used for all
# coordinate operations if available

# since PROJ6, projection info is no longer consistent
# between GRASS native info and info derived directly from
# PROJ lib using SRID or WKT because GRASS native info is
# incomplete with regard to datum

# reference for output generated with proj lib: wkt, proj4
reference_proj = [
"proj",
"ellps",
"lat_1",
"lat_2",
"lat_0",
"lon_0",
"x_0",
"y_0",
"no_defs",
]

# reference for output generated from old GRASS projinfo: shell, json
reference_grass = [
"proj",
"a",
"lat_1",
Expand All @@ -31,13 +53,18 @@ class GProjTestCase(TestCase):
"no_defs",
]

def assert_keys_in_output(self, output, prefix=""):
def assert_keys_in_proj_output(self, output, prefix=""):
"""Helper method to assert that each key (optionally prefixed) exists in the given output string."""
for key in self.reference_proj:
self.assertIn(prefix + key, output)

def assert_keys_in_grass_output(self, output, prefix=""):
"""Helper method to assert that each key (optionally prefixed) exists in the given output string."""
for key in self.reference:
for key in self.reference_grass:
self.assertIn(prefix + key, output)

def test_wkt_output(self):
"""Test if g.proj returns WKT"""
"""Test if g.proj returns WKT2, WKT1 is not accepted"""
module_flag = SimpleModule("g.proj", flags="p", format="wkt")
self.assertModule(module_flag)
result_flag = module_flag.outputs.stdout
Expand All @@ -56,19 +83,19 @@ def test_proj_info_output(self):
self.assertModule(module)
result = module.outputs.stdout
self.assertIn("PROJ_INFO", result)
self.assert_keys_in_output(result)
self.assert_keys_in_grass_output(result)

def test_proj4_output(self):
"""Test if g.proj returns consistent PROJ4 output."""
module_flag = SimpleModule("g.proj", flags="p", format="proj4")
self.assertModule(module_flag)
result_flag = module_flag.outputs.stdout
self.assert_keys_in_output(result_flag, "+")
self.assert_keys_in_proj_output(result_flag, "+")

module_format = SimpleModule("g.proj", flags="p", format="proj4")
self.assertModule(module_format)
result_format = module_format.outputs.stdout
self.assert_keys_in_output(result_format, "+")
self.assert_keys_in_proj_output(result_format, "+")

self.assertEqual(result_flag, result_format)

Expand All @@ -77,21 +104,22 @@ def test_shell_output(self):
module_flag = SimpleModule("g.proj", flags="p", format="shell")
self.assertModule(module_flag)
result_flag = module_flag.outputs.stdout
self.assert_keys_in_output(result_flag)
self.assert_keys_in_grass_output(result_flag)

module_format = SimpleModule("g.proj", flags="p", format="shell")
self.assertModule(module_format)
result_format = module_format.outputs.stdout
self.assert_keys_in_output(result_format)
self.assert_keys_in_grass_output(result_format)

self.assertEqual(result_flag, result_format)

def test_proj_info_output_json(self):
"""Test if g.proj returns consistent projection info in JSON format."""
# proj has its own PROJJSON format, use this?
module = SimpleModule("g.proj", flags="p", format="json")
self.assertModule(module)
result = json.loads(module.outputs.stdout)
self.assert_keys_in_output(result)
self.assert_keys_in_grass_output(result)


if __name__ == "__main__":
Expand Down
2 changes: 1 addition & 1 deletion python/grass/docs/src/gunittest_testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -721,4 +721,4 @@ Further reading
.. _1038: https://scan.coverity.com/projects/1038
.. _Cppcheck: http://cppcheck.sourceforge.net/
.. _sandbox: https://svn.osgeo.org/grass/sandbox/wenzeslaus/grass_py_static_check.py
.. _GRASS sample data: https://grass.osgeo.org/download/data/ and http://fatra.cnr.ncsu.edu/data/ (nc_spm_full_v2alpha)
.. _GRASS sample data: https://grass.osgeo.org/download/data/ and http://fatra.cnr.ncsu.edu/data/ (nc_spm_full_v2beta1)
2 changes: 1 addition & 1 deletion python/grass/pygrass/modules/grid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def copy_mapset(mapset, path):
>>> sorted(os.listdir(path)) # doctest: +ELLIPSIS
[...'PERMANENT'...]
>>> sorted(os.listdir(os.path.join(path, "PERMANENT")))
['DEFAULT_WIND', 'PROJ_INFO', 'PROJ_UNITS', 'VAR', 'WIND']
['DEFAULT_WIND', 'PROJ_INFO', 'PROJ_SRID', 'PROJ_UNITS', 'PROJ_WKT', 'VAR', 'WIND']
>>> sorted(os.listdir(os.path.join(path, mname))) # doctest: +ELLIPSIS
[...'WIND'...]
>>> import shutil
Expand Down
1 change: 1 addition & 0 deletions python/grass/pygrass/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ def get_raster_for_points(poi_vector, raster, column=None, region=None):
(10.0, 1.0)
>>> r[1] # doctest: +ELLIPSIS
(12.0, 1.0)
>>> vect.close()
>>> remove("test_vect_2", "vect")

:param poi_vector: A VectorTopo object that contains points
Expand Down
2 changes: 1 addition & 1 deletion raster/r.mfilter/testsuite/test_r_mfilter.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class TestNeighbors(TestCase):
"""

Used dataset: nc_spm_full_v2alphav2
Used dataset: nc_spm_full_v2beta1

Test cases:
test_sequential: Test output with sequential filter type
Expand Down
2 changes: 1 addition & 1 deletion raster/r.proj/r.proj.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ import grass.script as gs
# projection using JSON output format
bounds = gs.parse_command(
"r.proj",
project="nc_spm_full_v2alpha2",
project="nc_spm_full_v2beta1",
mapset="PERMANENT",
input="elevation",
flags="p",
Expand Down
Loading
Loading