Exemplo n.º 1
0
 def test_aggregate_metadata_add(self):
     """Ensure we can add metadata for the aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     metadata = _get_fake_aggr_metadata()
     db.aggregate_metadata_add(ctxt, result.id, metadata)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     self.assertDictMatch(metadata, expected)
Exemplo n.º 2
0
 def test_aggregate_update_with_metadata(self):
     """Ensure an aggregate can be updated with metadata."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     values = _get_fake_aggr_values()
     values['metadata'] = _get_fake_aggr_metadata()
     db.aggregate_update(ctxt, 1, values)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     self.assertDictMatch(_get_fake_aggr_metadata(), expected)
Exemplo n.º 3
0
 def test_aggregate_update_with_existing_metadata(self):
     """Ensure an aggregate can be updated with existing metadata."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     values = _get_fake_aggr_values()
     values['metadata'] = _get_fake_aggr_metadata()
     values['metadata']['fake_key1'] = 'foo'
     db.aggregate_update(ctxt, 1, values)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     self.assertDictMatch(values['metadata'], expected)
Exemplo n.º 4
0
 def test_aggregate_metadata_update(self):
     """Ensure we can update metadata for the aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     metadata = _get_fake_aggr_metadata()
     key = metadata.keys()[0]
     db.aggregate_metadata_delete(ctxt, result.id, key)
     new_metadata = {key: 'foo'}
     db.aggregate_metadata_add(ctxt, result.id, new_metadata)
     expected = db.aggregate_metadata_get(ctxt, result.id)
     metadata[key] = 'foo'
     self.assertDictMatch(metadata, expected)
Exemplo n.º 5
0
 def test_aggregate_create_with_metadata(self):
     """Ensure aggregate can be created with metadata."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt)
     expected_metadata = db.aggregate_metadata_get(ctxt, result['id'])
     self.assertDictMatch(expected_metadata, _get_fake_aggr_metadata())