def test_time_as_number(self): # Make sure Coord.cell() normally returns the values straight # out of the Coord's points/bounds arrays. coord = self._mock_coord() cell = Coord.cell(coord, 0) self.assertIs(cell.point, mock.sentinel.time) self.assertEqual(cell.bound, (mock.sentinel.lower, mock.sentinel.upper))
def test_time_as_number(self): # Make sure Coord.cell() normally returns the values straight # out of the Coord's points/bounds arrays. coord = self._mock_coord() cell = Coord.cell(coord, 0) self.assertIs(cell.point, mock.sentinel.time) self.assertEquals(cell.bound, (mock.sentinel.lower, mock.sentinel.upper))
def test_time_as_object(self): # Ensure Coord.cell() converts the point/bound values to # "datetime" objects. coord = self._mock_coord() coord.units.num2date = mock.Mock(side_effect=[ mock.sentinel.datetime, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper) ]) cell = Coord.cell(coord, 0) self.assertIs(cell.point, mock.sentinel.datetime) self.assertEqual( cell.bound, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper)) self.assertEqual(coord.units.num2date.call_args_list, [ mock.call((mock.sentinel.time, )), mock.call((mock.sentinel.lower, mock.sentinel.upper)) ])
def test_time_as_object(self): # Ensure Coord.cell() converts the point/bound values to # "datetime" objects. coord = self._mock_coord() coord.units.num2date = mock.Mock( side_effect=[mock.sentinel.datetime, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper)]) cell = Coord.cell(coord, 0) self.assertIs(cell.point, mock.sentinel.datetime) self.assertEqual(cell.bound, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper)) self.assertEqual(coord.units.num2date.call_args_list, [mock.call((mock.sentinel.time,)), mock.call((mock.sentinel.lower, mock.sentinel.upper))])
def test_time_as_object(self): # When iris.FUTURE.cell_datetime_objects is True, ensure # Coord.cell() converts the point/bound values to "datetime" # objects. coord = self._mock_coord() coord.units.num2date = mock.Mock( side_effect=[mock.sentinel.datetime, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper)]) with mock.patch('iris.FUTURE', cell_datetime_objects=True): cell = Coord.cell(coord, 0) self.assertIs(cell.point, mock.sentinel.datetime) self.assertEqual(cell.bound, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper)) self.assertEqual(coord.units.num2date.call_args_list, [mock.call((mock.sentinel.time,)), mock.call((mock.sentinel.lower, mock.sentinel.upper))])
def test_time_as_object(self): # When iris.FUTURE.cell_datetime_objects is True, ensure # Coord.cell() converts the point/bound values to "datetime" # objects. coord = self._mock_coord() coord.units.num2date = mock.Mock(side_effect=[ mock.sentinel.datetime, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper) ]) with mock.patch('iris.FUTURE', cell_datetime_objects=True): cell = Coord.cell(coord, 0) self.assertIs(cell.point, mock.sentinel.datetime) self.assertEquals( cell.bound, (mock.sentinel.datetime_lower, mock.sentinel.datetime_upper)) self.assertEqual(coord.units.num2date.call_args_list, [ mock.call((mock.sentinel.time, )), mock.call((mock.sentinel.lower, mock.sentinel.upper)) ])