-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 5f4ab02
Showing
9 changed files
with
226 additions
and
0 deletions.
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,11 @@ | ||
[flake8] | ||
|
||
# E501 line too long (83 > 79 characters) | ||
# F821 undefined name '_' | ||
|
||
exclude = .git | ||
|
||
per-file-ignores = | ||
./g.message.stdout.py: F821 | ||
|
||
max-line-length = 88 |
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,13 @@ | ||
FROM mundialis/grass-py3-pdal:latest-alpine | ||
|
||
WORKDIR /src | ||
COPY . /src | ||
COPY .github/workflows/test.sh /src | ||
RUN apk add gcc make | ||
RUN test -e requirements.txt && pip3 install -r requirements.txt || echo "No requirements.txt" | ||
|
||
# # run tests with downloaded NC test loaction | ||
# RUN grass -c epsg:3358 /grassdb/nc_spm_empty --exec bash test.sh NC | ||
|
||
# run tests in empty location | ||
RUN grass -c epsg:3358 /grassdb/nc_spm_empty --exec bash test.sh |
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,25 @@ | ||
name: Python Flake8 Code Quality | ||
|
||
on: | ||
- push | ||
- pull_request | ||
|
||
jobs: | ||
flake8: | ||
runs-on: ubuntu-20.04 | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.8 | ||
|
||
- name: Install | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install flake8==3.8.4 | ||
- name: Run Flake8 | ||
run: | | ||
flake8 --config=.flake8 --count --statistics --show-source --jobs=$(nproc) . |
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,27 @@ | ||
#!/usr/bin/env bash | ||
|
||
# fail on non-zero return code from a subprocess | ||
set -e | ||
|
||
# download NC test loaction if the test needs the data and run tests | ||
if [ $1 == "NC" ] | ||
then | ||
g.extension g.download.location | ||
g.download.location url=https://grass.osgeo.org/sampledata/north_carolina/nc_spm_full_v2alpha2.tar.gz path=/grassdb | ||
g.mapset mapset=PERMANENT location=nc_spm_full_v2alpha2 -c | ||
g.list all | ||
fi | ||
|
||
# run all tests in folder | ||
FILENAME=$(basename "$(find . -name *.html -maxdepth 1)") | ||
ADDON="${FILENAME%%.html}" | ||
|
||
CURRENTDIR=$(pwd) | ||
g.extension extension=${ADDON} url=. && \ | ||
for file in $(find . -type f -name test*.py) ; \ | ||
do \ | ||
echo ${file} | ||
BASENAME=$(basename "${file}") ; \ | ||
DIR=$(dirname "${file}") ; \ | ||
cd ${CURRENTDIR}/${DIR} && python3 -m unittest ${BASENAME} | ||
done |
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,28 @@ | ||
name: Run tests for GRASS GIS addons | ||
on: | ||
push: | ||
branches: [ main ] | ||
pull_request: | ||
# The branches below must be a subset of the branches above | ||
branches: [ main ] | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
# with: | ||
# path: "." | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Test of GRASS GIS addon | ||
id: docker_build | ||
uses: docker/build-push-action@v2 | ||
with: | ||
push: false | ||
tags: addon-tests:alpine | ||
context: . | ||
file: .github/workflows/Dockerfile | ||
no-cache: true | ||
# pull: true |
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,7 @@ | ||
MODULE_TOPDIR = ../.. | ||
|
||
PGM = g.message.stdout | ||
|
||
include $(MODULE_TOPDIR)/include/Make/Script.make | ||
|
||
default: script |
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,20 @@ | ||
<h2>DESCRIPTION</h2> | ||
|
||
<em>g.message.stdout</em> is a module which writes a message to stdout. | ||
|
||
<h2>EXAMPLES</h2> | ||
|
||
<h3>Write message to stdout</h3> | ||
|
||
<div class="code"><pre> | ||
g.message.stdout message="Hello World" | ||
</pre></div> | ||
|
||
<h2>AUTHORS</h2> | ||
|
||
Anika Weinmann, mundialis<br> | ||
|
||
<!-- | ||
<p> | ||
<i>Last changed: $Date$</i> | ||
--> |
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,52 @@ | ||
#!/usr/bin/env python3 | ||
|
||
############################################################################ | ||
# | ||
# MODULE: g.message.stdout | ||
# AUTHOR(S): Anika Weinmann | ||
# PURPOSE: This module writes a message to stdout | ||
# | ||
# COPYRIGHT: (C) 2021-2022 by mundialis GmbH & Co. KG and the GRASS Development Team | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
############################################################################# | ||
|
||
# %module | ||
# % label: Prints a message to stdout | ||
# % description: This module writes a message to stdout. | ||
# % keyword: general | ||
# % keyword: support | ||
# % keyword: scripts | ||
# %end | ||
|
||
# %option | ||
# % key: message | ||
# % type: string | ||
# % required: yes | ||
# % multiple: no | ||
# % key_desc: string | ||
# % label: Text of the message to be printed | ||
# % description: Message is printed on GRASS_VERBOSE>=2 | ||
# %end | ||
|
||
|
||
import sys | ||
import grass.script as grass | ||
|
||
|
||
def main(): | ||
print(options["message"]) | ||
|
||
|
||
if __name__ == "__main__": | ||
options, flags = grass.parser() | ||
sys.exit(main()) |
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,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
############################################################################ | ||
# | ||
# MODULE: g.message.stdout | ||
# AUTHOR(S): Anika Weinmann | ||
# PURPOSE: Tests g.message.stdout GRASS module | ||
# | ||
# COPYRIGHT: (C) 2021-2022 mundialis GmbH & Co. KG and the GRASS Development Team | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation; either version 2 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# This program is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
############################################################################# | ||
|
||
from grass.gunittest.case import TestCase | ||
from grass.gunittest.main import test | ||
from grass.gunittest.gmodules import SimpleModule | ||
|
||
|
||
class TestGMessageStdout(TestCase): | ||
msg = "Hello World" | ||
|
||
def test_message(self): | ||
"""Test if message is written to stdout""" | ||
g_message_stdout = SimpleModule("g.message.stdout", message=self.msg) | ||
self.assertModule(g_message_stdout) | ||
stdout = g_message_stdout.outputs.stdout | ||
stderr = g_message_stdout.outputs.stderr | ||
self.assertTrue(stdout) | ||
self.assertEqual(self.msg, stdout.strip()) | ||
self.assertEqual("", stderr) | ||
|
||
|
||
if __name__ == "__main__": | ||
test() |