def test_no_units_change(self): # If the Aggregator has no units_func then the units should be # left unchanged. aggregator = Aggregator('', None) cube = Mock(units=sentinel.units) aggregator.update_metadata(cube, []) self.assertIs(cube.units, sentinel.units)
def test_no_units_change(self): # If the Aggregator has no units_func then the units should be # left unchanged. aggregator = Aggregator("", None) cube = mock.Mock(units=mock.sentinel.units) aggregator.update_metadata(cube, []) self.assertIs(cube.units, mock.sentinel.units)
def test_units_change(self): # If the Aggregator has a units_func then the new units should # be defined by its return value. units_func = Mock(return_value=sentinel.new_units) aggregator = Aggregator('', None, units_func) cube = Mock(units=sentinel.units) aggregator.update_metadata(cube, []) units_func.assert_called_once_with(sentinel.units) self.assertEqual(cube.units, sentinel.new_units)
def test_units_change(self): # If the Aggregator has a units_func then the new units should # be defined by its return value. units_func = mock.Mock(return_value=mock.sentinel.new_units) aggregator = Aggregator("", None, units_func) cube = mock.Mock(units=mock.sentinel.units) aggregator.update_metadata(cube, []) units_func.assert_called_once_with(mock.sentinel.units) self.assertEqual(cube.units, mock.sentinel.new_units)