@@ -87,7 +87,20 @@ class BasetForTests(TestCase):
87
87
'suffix' : 'testing' ,
88
88
'units' : 'testing' ,
89
89
'wkv' : 'testing' },
90
-
90
+ 5 : {'colormap' : 'gray' ,
91
+ 'dataType' : '6' ,
92
+ 'long_name' : 'Normalized Radar Cross Section' ,
93
+ 'minmax' : '0 0.1' ,
94
+ 'name' : 'gamma0_HH' ,
95
+ 'PixelFunctionType' : 'Sentinel1Calibration' ,
96
+ 'polarization' : 'HH' ,
97
+ 'short_name' : 'gamma0' ,
98
+ 'SourceBand' : '1' ,
99
+ 'SourceFilename' : '/vsimem/0BSD1QSPFL.vrt' ,
100
+ 'standard_name' : 'surface_backwards_scattering_coefficient_of_radar_wave' ,
101
+ 'suffix' : 'HH' ,
102
+ 'units' : 'm/m' ,
103
+ 'wkv' : 'surface_backwards_scattering_coefficient_of_radar_wave' },
91
104
}
92
105
93
106
def setUp (self ):
@@ -167,25 +180,31 @@ def test_fail_invalid_uri(self):
167
180
ds , created = Dataset .objects .get_or_create (uri )
168
181
169
182
@patch ('os.path.isfile' )
170
- def test_exception_of_parameter_handling_for_longitude_and_latitude (self , mock_isfile ):
171
- '''shall return standard all specified parameter
172
- without the parameter for latitude and longitude'''
183
+ def test_dont_add_longitude_latitude (self , mock_isfile ):
184
+ """ shall not add latitude and longitude into DatasetParameter table """
173
185
mock_isfile .return_value = True
174
186
uri = 'file://localhost/some/folder/filename.ext'
175
187
ds0 , cr0 = Dataset .objects .get_or_create (uri )
188
+ ds_params_standard_names = ds0 .parameters .values_list ('standard_name' , flat = True )
176
189
# longitude should not be one of the parameters
177
- self .assertNotIn (
178
- self .predefined_band_metadata_dict [3 ]['standard_name' ],
179
- list (ds0 .parameters .all ().values ('standard_name' ))[0 ].values ())
190
+ self .assertNotIn ('longitude' , ds_params_standard_names )
180
191
# latitude should not be one of the parameters
181
- self .assertNotIn (
182
- self .predefined_band_metadata_dict [4 ]['standard_name' ],
183
- list (ds0 .parameters .all ().values ('standard_name' ))[0 ].values ())
184
- # other parameters must be in the parameters
185
- self .assertIn (
186
- self .predefined_band_metadata_dict [2 ]['standard_name' ],
187
- list (ds0 .parameters .all ().values ('standard_name' ))[0 ].values ())
192
+ self .assertNotIn ('latidtude' , ds_params_standard_names )
188
193
194
+ @patch ('os.path.isfile' )
195
+ def test_add_sigma0_gamma0 (self , mock_isfile ):
196
+ """ shall add both sigma0 and gamma0 with same standard name into DatasetParameter table """
197
+ mock_isfile .return_value = True
198
+ uri = 'file://localhost/some/folder/filename.ext'
199
+ ds0 , cr0 = Dataset .objects .get_or_create (uri )
200
+ ds_params_standard_names = ds0 .parameters .values_list ('standard_name' , flat = True )
201
+ ds_params_short_names = ds0 .parameters .values_list ('short_name' , flat = True )
202
+ self .assertEqual (len (ds_params_standard_names ), 2 )
203
+ self .assertEqual (len (ds_params_short_names ), 2 )
204
+ self .assertIn ('surface_backwards_scattering_coefficient_of_radar_wave' ,
205
+ ds_params_standard_names )
206
+ self .assertIn ('sigma0' , ds_params_short_names )
207
+ self .assertIn ('gamma0' , ds_params_short_names )
189
208
190
209
class TestDatasetURI (BasetForTests ):
191
210
@patch ('os.path.isfile' )
0 commit comments