def create_container(self, values): # ensure defaults are present for new containers if not values.get('uuid'): values['uuid'] = utils.generate_uuid() container = models.Container() container.update(values) try: container.save() except db_exc.DBDuplicateEntry: raise exception.ContainerAlreadyExists(uuid=values['uuid']) return container
def test_ContainerAlreadyExists(self): self.assertRaises( exception.ContainerAlreadyExists, lambda: self.raise_(exception.ContainerAlreadyExists()))