| 1 |
""" |
| 2 |
Name: r.in.ascii test |
| 3 |
Purpose: Tests r.in.ascii and its flags/options. |
| 4 |
|
| 5 |
Author: Sunveer Singh, Google Code-in 2017 |
| 6 |
Copyright: (C) 2017 by Sunveer Singh and the GRASS Development Team |
| 7 |
Licence: This program is free software under the GNU General Public |
| 8 |
License (>=v2). Read the file COPYING that comes with GRASS |
| 9 |
for details. |
| 10 |
""" |
| 11 |
|
| 12 |
from grass.gunittest.case import TestCase |
| 13 |
from grass.gunittest.main import test |
| 14 |
|
| 15 |
INPUT_NOQUOTES = """north: 4299000.00 |
| 16 |
south: 4247000.00 |
| 17 |
east: 528000.00 |
| 18 |
west: 500000.00 |
| 19 |
rows: 10 |
| 20 |
cols: 15 |
| 21 |
null: -9999 |
| 22 |
|
| 23 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 24 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 25 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 26 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 27 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 28 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 29 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 30 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 31 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
| 32 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 """ |
| 33 |
|
| 34 |
|
| 35 |
class SimpleCsvTestCase(TestCase): |
| 36 |
ascii_test = "ascii" |
| 37 |
|
| 38 |
@classmethod |
| 39 |
def setUpClass(cls): |
| 40 |
"""Use temporary region settings""" |
| 41 |
cls.use_temp_region() |
| 42 |
cls.runModule("g.region", n=4299000.00, s=4247000.00, e=528000.00, w=500000.00) |
| 43 |
|
| 44 |
@classmethod |
| 45 |
def tearDownClass(cls): |
| 46 |
cls.del_temp_region() |
| 47 |
|
| 48 |
def tearDown(self): |
| 49 |
"""Remove the raster map after each test method""" |
| 50 |
self.runModule("g.remove", flags="f", type="raster", pattern=self.ascii_test) |
| 51 |
|
| 52 |
def test_no_text_delimeter(self): |
| 53 |
"""Test loading no quotes""" |
| 54 |
self.assertModule( |
| 55 |
"r.in.ascii", |
| 56 |
input="-", |
| 57 |
output=self.ascii_test, |
| 58 |
type="CELL", |
| 59 |
stdin_=INPUT_NOQUOTES, |
| 60 |
) |
| 61 |
self.assertRasterMinMax( |
| 62 |
map=self.ascii_test, |
| 63 |
refmin=1, |
| 64 |
refmax=15, |
| 65 |
msg="ascii_test in degrees must be between 1 and 15", |
| 66 |
) |
| 67 |
|
| 68 |
def test_text_delimeter(self): |
| 69 |
"""Testing with external file""" |
| 70 |
self.assertModule( |
| 71 |
"r.in.ascii", |
| 72 |
input="data/input_ascii.txt", |
| 73 |
output=self.ascii_test, |
| 74 |
type="CELL", |
| 75 |
) |
| 76 |
self.assertRasterMinMax( |
| 77 |
map=self.ascii_test, |
| 78 |
refmin=1, |
| 79 |
refmax=5, |
| 80 |
msg="ascii_test in degrees must be between 1 and 5", |
| 81 |
) |
| 82 |
|
| 83 |
|
| 84 |
if __name__ == "__main__": |
| 85 |
test() |