diff --git a/tests/resources/test_resources.py b/tests/resources/test_resources.py index ef05ae7..3a161f3 100644 --- a/tests/resources/test_resources.py +++ b/tests/resources/test_resources.py @@ -1,12 +1,13 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2022 CERN. +# Copyright (C) 2024 Graz University of Technology. # # Invenio-Banners is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. """Banner resource tests.""" -from datetime import date, datetime +from datetime import date, datetime, timedelta import pytest from invenio_records_resources.services.errors import PermissionDeniedError @@ -19,24 +20,26 @@ "url_path": "/banner1", "category": "info", "active": True, - "start_datetime": date(2022, 7, 20), - "end_datetime": date(2023, 1, 29), + "start_datetime": date(2022, 7, 20).strftime("%Y-%m-%d %H:%M:%S"), + "end_datetime": (datetime.now() + timedelta(days=365)).strftime( + "%Y-%m-%d %H:%M:%S" + ), }, "banner2": { "message": "banner2", "url_path": "/banner2", "category": "other", "active": False, - "start_datetime": date(2022, 12, 15), - "end_datetime": date(2023, 1, 5), + "start_datetime": date(2022, 12, 15).strftime("%Y-%m-%d %H:%M:%S"), + "end_datetime": date(2023, 1, 5).strftime("%Y-%m-%d %H:%M:%S"), }, "banner3": { "message": "banner3", "url_path": "/banner3", "category": "warning", "active": True, - "start_datetime": date(2023, 1, 20), - "end_datetime": date(2023, 2, 25), + "start_datetime": date(2023, 1, 20).strftime("%Y-%m-%d %H:%M:%S"), + "end_datetime": date(2023, 2, 25).strftime("%Y-%m-%d %H:%M:%S"), }, } diff --git a/tests/services/test_services.py b/tests/services/test_services.py index ceb5e25..bb6cc1b 100644 --- a/tests/services/test_services.py +++ b/tests/services/test_services.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- # # Copyright (C) 2022 CERN. +# Copyright (C) 2024 Graz University of Technology. # # Invenio-Banners is free software; you can redistribute it and/or modify it # under the terms of the MIT License; see LICENSE file for more details. @@ -21,7 +22,10 @@ "message": "active", "url_path": "/active", "category": "info", - "end_datetime": datetime.utcnow() + timedelta(days=1), + "start_datetime": datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S"), + "end_datetime": (datetime.utcnow() + timedelta(days=1)).strftime( + "%Y-%m-%d %H:%M:%S" + ), "active": True, }, "inactive": {