From 8f1c7618b64009860ba5e01ee61aab2670234e09 Mon Sep 17 00:00:00 2001 From: Christoph Ladurner Date: Fri, 6 Dec 2024 14:15:00 +0100 Subject: [PATCH] tests: apply changes for sqlalchemy>=2.0 --- tests/conftest.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index d6593ff..e040fa6 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -2,6 +2,7 @@ # # This file is part of Invenio. # Copyright (C) 2015-2018 CERN. +# Copyright (C) 2024 Graz University of Technology. # # Invenio is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -75,10 +76,12 @@ def app(): app.register_blueprint(blueprint) with app.app_context(): - if str(db.engine.url) != "sqlite://" and not database_exists( - str(db.engine.url) + if str( + db.engine.url.render_as_string(hide_password=False) + ) != "sqlite://" and not database_exists( + str(db.engine.url.render_as_string(hide_password=False)) ): - create_database(str(db.engine.url)) + create_database(str(db.engine.url.render_as_string(hide_password=False))) db.create_all() list(search.delete(ignore=[404])) list(search.create()) @@ -89,8 +92,8 @@ def app(): with app.app_context(): db.session.close() - if str(db.engine.url) != "sqlite://": - drop_database(str(db.engine.url)) + if str(db.engine.url.render_as_string(hide_password=False)) != "sqlite://": + drop_database(str(db.engine.url.render_as_string(hide_password=False))) list(search.delete(ignore=[404])) search.client.indices.delete("*-percolators") shutil.rmtree(instance_path)