def test_delete_with_non_exist_object(ormapper, valid_object, valid_bucket):
    with ormapper.create_session() as session:
        delete_record_from_database(session)
        object_repository = ObjectRepository(session)
        # save data
        bucket = object_repository.save_bucket(valid_bucket)
        obj = valid_object.copy()
        obj.bucket = bucket
        # call method to test
        expect = f'Cannot delete object because it was not found: {obj.name}'
        actual = object_repository.delete(obj)
        assert expect == str(actual)
def test_delete(ormapper, valid_object, valid_bucket):
    with ormapper.create_session() as session:
        delete_record_from_database(session)
        object_repository = ObjectRepository(session)
        # save data
        bucket = object_repository.save_bucket(valid_bucket)
        obj = valid_object.copy()
        obj.bucket = bucket
        expect = object_repository.save(obj)
        # call method to test
        actual = object_repository.delete(expect)
        object_assertions(expect, actual)