| 1 |
|
|---|
| 2 | import unittest
|
|---|
| 3 | from grass.script import read_command
|
|---|
| 4 |
|
|---|
| 5 | LIST_RASTERS = """----------------------------------------------
|
|---|
| 6 |
|
|---|
| 7 | raster files available in mapset <PERMANENT>:
|
|---|
| 8 | aspect elevation_shade lsat7_2002_70
|
|---|
| 9 | basin_50K facility lsat7_2002_80
|
|---|
| 10 | boundary_county_500m geology_30m ncmask_500m
|
|---|
| 11 | cfactorbare_1m lakes ortho_2001_t792_1m
|
|---|
| 12 | cfactorgrow_1m landclass96 roadsmajor
|
|---|
| 13 | el_D782_6m landcover_1m slope
|
|---|
| 14 | el_D783_6m landuse96_28m soilsID
|
|---|
| 15 | el_D792_6m lsat7_2002_10 soils_Kfactor
|
|---|
| 16 | el_D793_6m lsat7_2002_20 streams_derived
|
|---|
| 17 | elev_lid792_1m lsat7_2002_30 towns
|
|---|
| 18 | elev_ned_30m lsat7_2002_40 urban
|
|---|
| 19 | elev_srtm_30m lsat7_2002_50 zipcodes
|
|---|
| 20 | elev_state_500m lsat7_2002_61 zipcodes_dbl
|
|---|
| 21 | elevation lsat7_2002_62
|
|---|
| 22 |
|
|---|
| 23 | raster files available in mapset <landsat>:
|
|---|
| 24 | lsat5_1987_10 lsat5_1987_40 lsat5_1987_70 lsat7_2000_30 lsat7_2000_61
|
|---|
| 25 | lsat5_1987_20 lsat5_1987_50 lsat7_2000_10 lsat7_2000_40 lsat7_2000_70
|
|---|
| 26 | lsat5_1987_30 lsat5_1987_60 lsat7_2000_20 lsat7_2000_50 lsat7_2000_80
|
|---|
| 27 |
|
|---|
| 28 | """
|
|---|
| 29 |
|
|---|
| 30 | LIST_VECTORS = """----------------------------------------------
|
|---|
| 31 |
|
|---|
| 32 | vector files available in mapset <PERMANENT>:
|
|---|
| 33 | P079214 elev_lid792_bepts poi_names_wake
|
|---|
| 34 | P079215 elev_lid792_cont1m precip_30ynormals
|
|---|
| 35 | P079218 elev_lid792_randpts precip_30ynormals_3d
|
|---|
| 36 | P079219 elev_lidrural_mrpts railroads
|
|---|
| 37 | boundary_county elev_lidrural_mrptsft roadsmajor
|
|---|
| 38 | boundary_municp elev_ned10m_cont10m schools_wake
|
|---|
| 39 | bridges firestations soils_general
|
|---|
| 40 | busroute1 geodetic_pts soils_wake
|
|---|
| 41 | busroute11 geodetic_swwake_pts streams
|
|---|
| 42 | busroute6 geology streets_wake
|
|---|
| 43 | busroute_a geonames_NC swwake_10m
|
|---|
| 44 | busroutesall geonames_wake urbanarea
|
|---|
| 45 | busstopsall hospitals usgsgages
|
|---|
| 46 | census_wake2000 lakes zipcodes_wake
|
|---|
| 47 | censusblk_swwake nc_state
|
|---|
| 48 | comm_colleges overpasses
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | """
|
|---|
| 52 |
|
|---|
| 53 | LIST_GROUPS = """----------------------------------------------
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | imagery group files available in mapset <landsat>:
|
|---|
| 57 | lsat7_2000
|
|---|
| 58 |
|
|---|
| 59 | """
|
|---|
| 60 |
|
|---|
| 61 | LIST_RASTERS_MAPSET = """----------------------------------------------
|
|---|
| 62 | raster files available in mapset <landsat>:
|
|---|
| 63 | lsat5_1987_10 lsat5_1987_40 lsat5_1987_70 lsat7_2000_30 lsat7_2000_61
|
|---|
| 64 | lsat5_1987_20 lsat5_1987_50 lsat7_2000_10 lsat7_2000_40 lsat7_2000_70
|
|---|
| 65 | lsat5_1987_30 lsat5_1987_60 lsat7_2000_20 lsat7_2000_50 lsat7_2000_80
|
|---|
| 66 |
|
|---|
| 67 | """
|
|---|
| 68 |
|
|---|
| 69 | LIST_RASTERS_TITLES = """----------------------------------------------
|
|---|
| 70 |
|
|---|
| 71 | raster files available in mapset <PERMANENT>:
|
|---|
| 72 | aspect South-West Wake county: Aspect [degrees from east]
|
|---|
| 73 | basin_50K South-West Wake county: Watersheds derived from 30m NED
|
|---|
| 74 | boundary_county_500m North Carolina county boundaries
|
|---|
| 75 | cfactorbare_1m Rural area: C-factor with fields bare
|
|---|
| 76 | cfactorgrow_1m Rural area: C-factor for growing season
|
|---|
| 77 | el_D782_6m NC Flood lidar-based 6m(20ft) DEM
|
|---|
| 78 | el_D783_6m NC Flood lidar-based 6m(20ft) DEM
|
|---|
| 79 | el_D792_6m NC Flood lidar-based 6m(20ft) DEM
|
|---|
| 80 | el_D793_6m NC Flood lidar-based 6m(20ft) DEM
|
|---|
| 81 | elev_lid792_1m Rural area: Lidar-based 1m DEM
|
|---|
| 82 | elev_ned_30m South-West Wake county: National Elevation Data 30m
|
|---|
| 83 | elev_srtm_30m South-West Wake county: SRTM-V1 30m terrain surface model
|
|---|
| 84 | elev_state_500m North Carolina DEM 500m
|
|---|
| 85 | elevation South-West Wake county: Elevation NED 10m
|
|---|
| 86 | elevation_shade South-West Wake county: Shaded relief
|
|---|
| 87 | facility Rural area: Footprint of planned facility
|
|---|
| 88 | geology_30m South-West Wake county: geology derived from vector map
|
|---|
| 89 | lakes South-West Wake county: Wake county lakes
|
|---|
| 90 | landclass96 South-West Wake county: Simplified landuse classes
|
|---|
| 91 | landcover_1m Rural area: Landcover
|
|---|
| 92 | landuse96_28m South-West Wake county: NC Land Use 1996 clipped
|
|---|
| 93 | lsat7_2002_10 LANDSAT-TM7 Band 1 Visible (0.45-0.52um) 30m
|
|---|
| 94 | lsat7_2002_20 LANDSAT-TM7 Band 2 Visible (0.52-0.60um) 30m
|
|---|
| 95 | lsat7_2002_30 LANDSAT-TM7 Band 3 Visible (0.63-0.69um) 30m
|
|---|
| 96 | lsat7_2002_40 LANDSAT-TM7 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
|
|---|
| 97 | lsat7_2002_50 LANDSAT-TM7 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
|
|---|
| 98 | lsat7_2002_61 LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m Low Gain
|
|---|
| 99 | lsat7_2002_62 LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m High Gain
|
|---|
| 100 | lsat7_2002_70 LANDSAT-TM7 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
|
|---|
| 101 | lsat7_2002_80 LANDSAT-TM7 Band 8 Panchromatic (PAN) (0.52-0.90um (15m)
|
|---|
| 102 | ncmask_500m North Carolina boundary MASK
|
|---|
| 103 | ortho_2001_t792_1m Rural area (792 tile) NC Flood Orthophoto 2001
|
|---|
| 104 | roadsmajor South-West Wake county: roadsmajor
|
|---|
| 105 | slope South-West Wake county: slope in degrees
|
|---|
| 106 | soilsID South-West Wake county: Soils: ID
|
|---|
| 107 | soils_Kfactor Rural area: Soils: K-factor
|
|---|
| 108 | streams_derived South-West Wake county: Streams derived from 10m DEM
|
|---|
| 109 | towns South West Wake: Cities and towns derived from zipcodes
|
|---|
| 110 | urban South West Wake: Urban areas derived from vector map
|
|---|
| 111 | zipcodes South West Wake: Zipcode areas derived from vector map
|
|---|
| 112 | zipcodes_dbl South West Wake: Zipcode areas from vector map, fp
|
|---|
| 113 |
|
|---|
| 114 | raster files available in mapset <landsat>:
|
|---|
| 115 | lsat5_1987_10 LANDSAT-TM5 Band 1 Visible (0.45-0.52um) 30m
|
|---|
| 116 | lsat5_1987_20 LANDSAT-TM5 Band 2 Visible (0.52-0.60um) 30m
|
|---|
| 117 | lsat5_1987_30 LANDSAT-TM5 Band 3 Visible (0.63-0.69um) 30m
|
|---|
| 118 | lsat5_1987_40 LANDSAT-TM5 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
|
|---|
| 119 | lsat5_1987_50 LANDSAT-TM5 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
|
|---|
| 120 | lsat5_1987_60 LANDSAT-TM5 Band 6 Thermal (10.40-12.50um) 120m
|
|---|
| 121 | lsat5_1987_70 LANDSAT-TM5 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
|
|---|
| 122 | lsat7_2000_10 LANDSAT-TM7 Band 1 Visible (0.45-0.52um) 30m
|
|---|
| 123 | lsat7_2000_20 LANDSAT-TM7 Band 2 Visible (0.52-0.60um) 30m
|
|---|
| 124 | lsat7_2000_30 LANDSAT-TM7 Band 3 Visible (0.63-0.69um) 30m
|
|---|
| 125 | lsat7_2000_40 LANDSAT-TM7 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
|
|---|
| 126 | lsat7_2000_50 LANDSAT-TM7 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
|
|---|
| 127 | lsat7_2000_61 LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m Low Gain
|
|---|
| 128 | lsat7_2000_70 LANDSAT-TM7 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
|
|---|
| 129 | lsat7_2000_80 LANDSAT-TM7 Band 8 Panchromatic (PAN) (0.52-0.90um (15m)
|
|---|
| 130 |
|
|---|
| 131 | """
|
|---|
| 132 |
|
|---|
| 133 | LIST_RASTERS_TITLES_MAPSET = """----------------------------------------------
|
|---|
| 134 | raster files available in mapset <landsat>:
|
|---|
| 135 | lsat5_1987_10 LANDSAT-TM5 Band 1 Visible (0.45-0.52um) 30m
|
|---|
| 136 | lsat5_1987_20 LANDSAT-TM5 Band 2 Visible (0.52-0.60um) 30m
|
|---|
| 137 | lsat5_1987_30 LANDSAT-TM5 Band 3 Visible (0.63-0.69um) 30m
|
|---|
| 138 | lsat5_1987_40 LANDSAT-TM5 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
|
|---|
| 139 | lsat5_1987_50 LANDSAT-TM5 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
|
|---|
| 140 | lsat5_1987_60 LANDSAT-TM5 Band 6 Thermal (10.40-12.50um) 120m
|
|---|
| 141 | lsat5_1987_70 LANDSAT-TM5 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
|
|---|
| 142 | lsat7_2000_10 LANDSAT-TM7 Band 1 Visible (0.45-0.52um) 30m
|
|---|
| 143 | lsat7_2000_20 LANDSAT-TM7 Band 2 Visible (0.52-0.60um) 30m
|
|---|
| 144 | lsat7_2000_30 LANDSAT-TM7 Band 3 Visible (0.63-0.69um) 30m
|
|---|
| 145 | lsat7_2000_40 LANDSAT-TM7 Band 4 Near Infrared (NIR) (0.76-0.90um) 30m
|
|---|
| 146 | lsat7_2000_50 LANDSAT-TM7 Band 5 Near Infrared (NIR) (1.55-1.75um) 30m
|
|---|
| 147 | lsat7_2000_61 LANDSAT-TM7 Band 6 Thermal (10.40-12.50um) 60m Low Gain
|
|---|
| 148 | lsat7_2000_70 LANDSAT-TM7 Band 7 Mid Infrared (MIR) (2.08-2.35um) 30m
|
|---|
| 149 | lsat7_2000_80 LANDSAT-TM7 Band 8 Panchromatic (PAN) (0.52-0.90um (15m)
|
|---|
| 150 |
|
|---|
| 151 | """
|
|---|
| 152 |
|
|---|
| 153 |
|
|---|
| 154 | class GListTest(unittest.TestCase):
|
|---|
| 155 |
|
|---|
| 156 | def setUp(self):
|
|---|
| 157 | pass
|
|---|
| 158 |
|
|---|
| 159 | def test_list_rasters(self):
|
|---|
| 160 | """Test human readable list of rasters.
|
|---|
| 161 |
|
|---|
| 162 | Supposing we are in user1 of NC and have access
|
|---|
| 163 | to landsat (besides PERMANENT).
|
|---|
| 164 | """
|
|---|
| 165 | self.maxDiff = None
|
|---|
| 166 | stdout = read_command('g.list', type='rast')
|
|---|
| 167 | self.assertMultiLineEqual(stdout, LIST_RASTERS)
|
|---|
| 168 |
|
|---|
| 169 | def test_list_vectors(self):
|
|---|
| 170 | """Test human readable list of vectors.
|
|---|
| 171 |
|
|---|
| 172 | Supposing we are in user1 of NC and have access
|
|---|
| 173 | to landsat (besides PERMANENT).
|
|---|
| 174 | """
|
|---|
| 175 | self.maxDiff = None
|
|---|
| 176 | stdout = read_command('g.list', type='vect')
|
|---|
| 177 | self.assertMultiLineEqual(stdout, LIST_VECTORS)
|
|---|
| 178 |
|
|---|
| 179 | def test_list_groups(self):
|
|---|
| 180 | """Test human readable list of imagery groups.
|
|---|
| 181 |
|
|---|
| 182 | Supposing we are in user1 of NC and have access
|
|---|
| 183 | to landsat (besides PERMANENT).
|
|---|
| 184 | """
|
|---|
| 185 | self.maxDiff = None
|
|---|
| 186 | stdout = read_command('g.list', type='group')
|
|---|
| 187 | self.assertMultiLineEqual(stdout, LIST_GROUPS)
|
|---|
| 188 |
|
|---|
| 189 | def test_list_rasters_in_mapset(self):
|
|---|
| 190 | """Test human readable list of rasters in a specific mapset.
|
|---|
| 191 |
|
|---|
| 192 | Supposing we are in user1 of NC and have access
|
|---|
| 193 | to landsat (besides PERMANENT).
|
|---|
| 194 | """
|
|---|
| 195 | self.maxDiff = None
|
|---|
| 196 | stdout = read_command('g.list', type='rast', mapset='landsat')
|
|---|
| 197 | self.assertMultiLineEqual(stdout, LIST_RASTERS_MAPSET)
|
|---|
| 198 |
|
|---|
| 199 | def test_list_rasters_titles(self):
|
|---|
| 200 | """Test human readable list of rasters with titles.
|
|---|
| 201 |
|
|---|
| 202 | Supposing we are in user1 of NC and have access
|
|---|
| 203 | to landsat (besides PERMANENT).
|
|---|
| 204 | """
|
|---|
| 205 | self.maxDiff = None
|
|---|
| 206 | stdout = read_command('g.list', flags='f', type='rast')
|
|---|
| 207 | self.assertMultiLineEqual(stdout, LIST_RASTERS_TITLES)
|
|---|
| 208 |
|
|---|
| 209 | def test_list_rasters_titles_in_mapset(self):
|
|---|
| 210 | """Test human readable list of rasters with titles
|
|---|
| 211 | in a specific mapset.
|
|---|
| 212 |
|
|---|
| 213 | Supposing we are in user1 of NC and have access
|
|---|
| 214 | to landsat (besides PERMANENT).
|
|---|
| 215 | """
|
|---|
| 216 | self.maxDiff = None
|
|---|
| 217 | stdout = read_command('g.list', flags='f', type='rast',
|
|---|
| 218 | mapset='landsat')
|
|---|
| 219 | self.assertMultiLineEqual(stdout, LIST_RASTERS_TITLES_MAPSET)
|
|---|
| 220 |
|
|---|
| 221 | def tearDown(self):
|
|---|
| 222 | pass
|
|---|
| 223 |
|
|---|
| 224 | if __name__ == '__main__':
|
|---|
| 225 | unittest.main()
|
|---|