def create_bay(self, values): # ensure defaults are present for new bays if not values.get('uuid'): values['uuid'] = utils.generate_uuid() bay = models.Bay() bay.update(values) try: bay.save() except db_exc.DBDuplicateEntry: raise exception.BayAlreadyExists(uuid=values['uuid']) return bay
def test_BayAlreadyExists(self): self.assertRaises(exception.BayAlreadyExists, lambda: self.raise_(exception.BayAlreadyExists()))