Exemplo n.º 1
0
 def test_aggregate_delete(self):
     """Ensure we can delete an aggregate."""
     ctxt = context.get_admin_context()
     result = _create_aggregate(context=ctxt, metadata=None)
     db.aggregate_delete(ctxt, result['id'])
     expected = db.aggregate_get_all(ctxt)
     self.assertEqual(0, len(expected))
     aggregate = db.aggregate_get(ctxt.elevated(read_deleted='yes'),
                                  result['id'])
     self.assertEqual(aggregate["operational_state"], "dismissed")
Exemplo n.º 2
0
 def test_aggregate_get_all(self):
     """Ensure we can get all aggregates."""
     ctxt = context.get_admin_context()
     counter = 3
     for c in xrange(counter):
         _create_aggregate(context=ctxt,
                           values={'name': 'fake_aggregate_%d' % c,
                                   'availability_zone': 'fake_avail_zone'},
                           metadata=None)
     results = db.aggregate_get_all(ctxt)
     self.assertEqual(len(results), counter)
Exemplo n.º 3
0
 def test_aggregate_get_all_non_deleted(self):
     """Ensure we get only non-deleted aggregates."""
     ctxt = context.get_admin_context()
     add_counter = 5
     remove_counter = 2
     aggregates = []
     for c in xrange(1, add_counter):
         values = {'name': 'fake_aggregate_%d' % c,
                   'availability_zone': 'fake_avail_zone'}
         aggregates.append(_create_aggregate(context=ctxt,
                                             values=values, metadata=None))
     for c in xrange(1, remove_counter):
         db.aggregate_delete(ctxt, aggregates[c - 1].id)
     results = db.aggregate_get_all(ctxt)
     self.assertEqual(len(results), add_counter - remove_counter)