def test_intervals(self): self.section['timeIncrement'] = 3 self.section['indicatorOfUnitForTimeIncrement'] = 1 cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method.method, 'mean') self.assertEqual(cell_method.coord_names, ('time',)) self.assertEqual(cell_method.intervals, ('3 hours',))
def test_intervals(self): self.section['timeIncrement'] = 3 self.section['indicatorOfUnitForTimeIncrement'] = 1 cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method.method, 'mean') self.assertEqual(cell_method.coord_names, ('time', )) self.assertEqual(cell_method.intervals, ('3 hours', ))
def test_pdt_15(self): # Encoded slightly differently to PDT 4.8. self.section['productDefinitionTemplateNumber'] = 15 test_code = self.section['typeOfStatisticalProcessing'] del self.section['typeOfStatisticalProcessing'] self.section['statisticalProcess'] = test_code cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method, self.expected_cell_method())
def test_fail_multiple_ranges(self): self.section['numberOfTimeRange'] = 2 with self.assertRaisesRegexp(TranslationError, 'multiple time ranges \[2\]'): statistical_cell_method(self.section)
def test_fail_bad_ranges(self): self.section['numberOfTimeRange'] = 0 with self.assertRaisesRegexp(TranslationError, 'aggregation over "0 time ranges"'): statistical_cell_method(self.section)
def test_basic(self): cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method.method, 'mean') self.assertEqual(cell_method.coord_names, ('time',)) self.assertEqual(cell_method.intervals, ())
def test_fail_bad_increment_type(self): self.section['typeOfTimeIncrement'] = 7 with self.assertRaisesRegexp( TranslationError, 'time-increment type \[7\] is not supported'): statistical_cell_method(self.section)
def test_fail_unknown_statistic(self): self.section['typeOfStatisticalProcessing'] = 17 with self.assertRaisesRegexp( TranslationError, 'statistical process type \[17\] is not supported'): statistical_cell_method(self.section)
def test_fail_unsupported_pdt(self): # Rejects PDTs other than the ones tested above. self.section['productDefinitionTemplateNumber'] = 101 msg = "can't get statistical method for unsupported pdt : 4.101" with self.assertRaisesRegexp(ValueError, msg): statistical_cell_method(self.section)
def test_basic(self): cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method.method, 'mean') self.assertEqual(cell_method.coord_names, ('time', )) self.assertEqual(cell_method.intervals, ())
def test_pdt_10(self): # Should behave the same as PDT 4.8. self.section['productDefinitionTemplateNumber'] = 10 cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method, self.expected_cell_method())
def test_different_statistic(self): self.section['typeOfStatisticalProcessing'] = 6 cell_method = statistical_cell_method(self.section) self.assertEqual( cell_method, self.expected_cell_method(method='standard_deviation'))
def test_intervals(self): self.section['timeIncrement'] = 3 self.section['indicatorOfUnitForTimeIncrement'] = 1 cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method, self.expected_cell_method(intervals=('3 hours',)))
def test_basic(self): cell_method = statistical_cell_method(self.section) self.assertEqual(cell_method, self.expected_cell_method())