-
-
Notifications
You must be signed in to change notification settings - Fork 295
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
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
vector/v.db.select/testsuite/test_v_db_select_reserved_db_keyword_col_name.py
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,65 @@ | ||
############################################################################ | ||
# | ||
# MODULE: Test of v.db.select | ||
# AUTHOR(S): Tomas Zigo <tomas zigo slovanet sk> | ||
# PURPOSE: Test query with defined columns (column name is reserved DB | ||
# keyword) | ||
# COPYRIGHT: (C) 2021-2024 by Tomas Zigo the GRASS Development Team | ||
# | ||
# This program is free software under the GNU General Public | ||
# License (>=v2). Read the file COPYING that comes with GRASS | ||
# for details. | ||
# | ||
############################################################################# | ||
|
||
"""Test query with defined columns (column name is reserved DB keyword)""" | ||
|
||
import grass.script as gs | ||
|
||
from grass.gunittest.case import TestCase | ||
from grass.gunittest.main import test | ||
|
||
POINTS = """\ | ||
17.46938776,18.67346939,1 | ||
20.93877551,17.44897959,2 | ||
""" | ||
|
||
|
||
class QueryWithDefinedColumnsTest(TestCase): | ||
"""Test case for query with defined columns (column name is reserved | ||
DB keyword) | ||
""" | ||
|
||
# Setup variables to be used for outputs | ||
vector_points = "points" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
"""Create points with reserved DB keyword column name""" | ||
cls.runModule( | ||
"v.in.ascii", | ||
input="-", | ||
stdin_=POINTS, | ||
cat=0, | ||
separator="comma", | ||
output=cls.vector_points, | ||
columns='x double precision, y double precision, "order" integer', | ||
) | ||
|
||
@classmethod | ||
def tearDownClass(cls): | ||
"""Remove the test data""" | ||
cls.runModule("g.remove", flags="f", type="vector", name=cls.vector_points) | ||
|
||
def test_query_with_defined_columns(self): | ||
"""Test query with defined columns param arg""" | ||
data = gs.read_command( | ||
"v.db.select", | ||
map=self.vector_points, | ||
columns="cat,order", | ||
) | ||
self.assertEqual(data, "cat|order\n1|1\n2|2\n") | ||
|
||
|
||
if __name__ == "__main__": | ||
test() |