

@mock.patch('nova.objects.Aggregate.save')
@mock.patch('nova.db.aggregate_get')
def test_load_allocates_uuid(self, mock_get, mock_save):
    fake_agg = dict(fake_aggregate)
    del fake_agg['uuid']
    mock_get.return_value = fake_agg
    uuid = uuidsentinel.aggregate
    with mock.patch('oslo_utils.uuidutils.generate_uuid') as mock_g:
        mock_g.return_value = uuid
        obj = aggregate.Aggregate.get_by_id(self.context, 123)
        mock_g.assert_called_once_with()
        self.assertEqual(uuid, obj.uuid)
        mock_save.assert_called_once_with()

dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/tests/unit/objects/test_aggregate.py _TestAggregateObject.test_load_allocates_uuid/original