From da81f83269d5bebf647bc20f6dc63178dcea0aec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Fri, 17 Apr 2026 10:34:35 +0200 Subject: [PATCH 1/5] Bump GH actions --- .github/workflows/build-release.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index badcf170..8169d1df 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -16,8 +16,8 @@ jobs: - {name: '3.12', python: '3.12', tox: py312} - {name: 'min', python: '3.9', tox: min} steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: ${{ matrix.python }} allow-prereleases: true @@ -33,8 +33,8 @@ jobs: name: Build package runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: "3.12" - name: Install pypa/build @@ -46,7 +46,7 @@ jobs: - name: Check build run: python -m twine check --strict dist/* - name: Store the distribution packages - uses: actions/upload-artifact@v4 + uses: actions/upload-artifact@v7 with: name: python-package-distributions path: dist/ @@ -57,8 +57,8 @@ jobs: if: startsWith(github.ref, 'refs/tags') runs-on: ubuntu-latest steps: - - uses: actions/checkout@v4 - - uses: actions/setup-python@v5 + - uses: actions/checkout@v6 + - uses: actions/setup-python@v6 with: python-version: 3.12 - run: python -m pip install tox @@ -75,7 +75,7 @@ jobs: id-token: write steps: - name: Download all the dists - uses: actions/download-artifact@v4 + uses: actions/download-artifact@v7 with: name: python-package-distributions path: dist/ From e3a23220bd1bfddfcce3c02cd921291282afede0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Thu, 4 Dec 2025 15:25:09 +0100 Subject: [PATCH 2/5] Support Python 3.13 and 3.14 --- .github/workflows/build-release.yaml | 6 +++--- pyproject.toml | 2 ++ tox.ini | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 8169d1df..636cd638 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -13,7 +13,7 @@ jobs: matrix: include: - {name: '3.9', python: '3.9', tox: py39} - - {name: '3.12', python: '3.12', tox: py312} + - {name: '3.14', python: '3.14', tox: py314} - {name: 'min', python: '3.9', tox: min} steps: - uses: actions/checkout@v6 @@ -36,7 +36,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: - python-version: "3.12" + python-version: "3.14" - name: Install pypa/build run: python -m pip install build - name: Build a binary wheel and a source tarball @@ -60,7 +60,7 @@ jobs: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 with: - python-version: 3.12 + python-version: 3.14 - run: python -m pip install tox - run: python -m tox -elint publish-to-pypi: diff --git a/pyproject.toml b/pyproject.toml index d269a9db..705d2e23 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -22,6 +22,8 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14", ] requires-python = ">=3.9" dependencies = [ diff --git a/tox.ini b/tox.ini index c6a6e927..fec719a2 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint,py39,py310,py311,py312,min +envlist = lint,py39,py310,py311,py312,py313,py314,min skip_missing_interpreters = True [testenv] From 148dfb6d15570f6640312f2700f72e6d1cbc8266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Fri, 17 Apr 2026 10:53:36 +0200 Subject: [PATCH 3/5] Bump requirements --- requirements/dev.txt | 62 ++++++++++++++++++++--------------- requirements/install-min.txt | 44 +++++++++++++------------ requirements/install.txt | 63 +++++++++++++++++++----------------- requirements/tests.txt | 34 ++++++++++--------- 4 files changed, 111 insertions(+), 92 deletions(-) diff --git a/requirements/dev.txt b/requirements/dev.txt index 69c3aa82..2cb345af 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -4,50 +4,60 @@ # # pip-compile --unsafe-package=psycopg requirements/dev.in # -cfgv==3.4.0 +cfgv==3.5.0 # via pre-commit -coverage[toml]==7.6.10 +coverage[toml]==7.13.5 # via pytest-cov -distlib==0.3.9 +distlib==0.4.0 # via virtualenv -filelock==3.16.1 - # via virtualenv -identify==2.6.5 +filelock==3.28.0 + # via + # python-discovery + # virtualenv +identify==2.6.18 # via pre-commit -iniconfig==2.0.0 +iniconfig==2.3.0 # via pytest -mirakuru==2.5.3 +mirakuru==3.0.2 # via pytest-postgresql -nodeenv==1.9.1 +nodeenv==1.10.0 # via pre-commit -packaging==24.2 - # via pytest -platformdirs==4.3.6 - # via virtualenv -pluggy==1.5.0 - # via pytest -port-for==0.7.4 +packaging==26.1 + # via + # pytest + # pytest-postgresql +platformdirs==4.9.6 + # via + # python-discovery + # virtualenv +pluggy==1.6.0 + # via + # pytest + # pytest-cov +port-for==1.0.0 # via pytest-postgresql -pre-commit==4.0.1 +pre-commit==4.5.1 # via -r requirements/dev.in -psutil==6.1.1 +psutil==7.2.2 # via mirakuru -pytest==8.3.4 +pygments==2.20.0 + # via pytest +pytest==9.0.3 # via # -r requirements/tests.in # pytest-cov # pytest-postgresql -pytest-cov==6.0.0 +pytest-cov==7.1.0 # via -r requirements/tests.in -pytest-postgresql==6.1.1 +pytest-postgresql==8.0.0 # via -r requirements/tests.in -pyyaml==6.0.2 +python-discovery==1.2.2 + # via virtualenv +pyyaml==6.0.3 # via pre-commit -setuptools==75.7.0 - # via pytest-postgresql -typing-extensions==4.12.2 +typing-extensions==4.15.0 # via psycopg -virtualenv==20.28.1 +virtualenv==21.2.4 # via pre-commit # The following packages are considered to be unsafe in a requirements file: diff --git a/requirements/install-min.txt b/requirements/install-min.txt index eb9aa53b..0e274b9a 100644 --- a/requirements/install-min.txt +++ b/requirements/install-min.txt @@ -10,19 +10,19 @@ amqp==5.3.1 # via kombu argon2-cffi==23.1.0 # via -r requirements/install-min.in -argon2-cffi-bindings==21.2.0 +argon2-cffi-bindings==25.1.0 # via argon2-cffi async-timeout==5.0.1 # via redis -billiard==4.2.1 +billiard==4.2.4 # via celery celery==5.3.1 # via -r requirements/install-min.in -certifi==2024.12.14 +certifi==2026.2.25 # via requests -cffi==1.17.1 +cffi==2.0.0 # via argon2-cffi-bindings -charset-normalizer==3.4.1 +charset-normalizer==3.4.7 # via requests click==8.1.3 # via @@ -33,41 +33,43 @@ click==8.1.3 # click-repl click-didyoumean==0.3.1 # via celery -click-plugins==1.1.1 +click-plugins==1.1.1.2 # via celery click-repl==0.3.0 # via celery -deprecated==1.2.15 +deprecated==1.3.1 # via redis -greenlet==3.1.1 +greenlet==3.4.0 # via sqlalchemy -idna==3.10 +idna==3.11 # via requests -kombu==5.4.2 +kombu==5.6.2 # via celery -mako==1.3.8 +mako==1.3.11 # via alembic -markupsafe==3.0.2 +markupsafe==3.0.3 # via mako numpy==1.26.4 # via pandas -packaging==24.2 - # via redis +packaging==26.1 + # via + # kombu + # redis pandas==2.2.0 # via -r requirements/install-min.in pint==0.23 # via -r requirements/install-min.in -prompt-toolkit==3.0.48 +prompt-toolkit==3.0.52 # via click-repl psycopg==3.1.10 # via -r requirements/install-min.in -pycparser==2.22 +pycparser==3.0 # via cffi python-dateutil==2.9.0.post0 # via # celery # pandas -pytz==2024.2 +pytz==2026.1.post1 # via pandas redis==4.3.4 # via -r requirements/install-min.in @@ -79,12 +81,12 @@ sqlalchemy==2.0.8 # via # -r requirements/install-min.in # alembic -typing-extensions==4.12.2 +typing-extensions==4.15.0 # via # pint # psycopg # sqlalchemy -tzdata==2024.2 +tzdata==2026.1 # via # celery # kombu @@ -96,7 +98,7 @@ vine==5.1.0 # amqp # celery # kombu -wcwidth==0.2.13 +wcwidth==0.6.0 # via prompt-toolkit -wrapt==1.17.0 +wrapt==2.1.2 # via deprecated diff --git a/requirements/install.txt b/requirements/install.txt index 11292211..fc3c7356 100644 --- a/requirements/install.txt +++ b/requirements/install.txt @@ -4,27 +4,27 @@ # # pip-compile --output-file=requirements/install.txt pyproject.toml # -alembic==1.14.0 +alembic==1.18.4 # via bemserver-core (pyproject.toml) amqp==5.3.1 # via kombu -argon2-cffi==23.1.0 +argon2-cffi==25.1.0 # via bemserver-core (pyproject.toml) -argon2-cffi-bindings==21.2.0 +argon2-cffi-bindings==25.1.0 # via argon2-cffi async-timeout==5.0.1 # via redis -billiard==4.2.1 +billiard==4.2.4 # via celery -celery==5.4.0 +celery==5.6.3 # via bemserver-core (pyproject.toml) -certifi==2024.12.14 +certifi==2026.2.25 # via requests -cffi==1.17.1 +cffi==2.0.0 # via argon2-cffi-bindings -charset-normalizer==3.4.1 +charset-normalizer==3.4.7 # via requests -click==8.1.8 +click==8.3.2 # via # bemserver-core (pyproject.toml) # celery @@ -33,7 +33,7 @@ click==8.1.8 # click-repl click-didyoumean==0.3.1 # via celery -click-plugins==1.1.1 +click-plugins==1.1.1.2 # via celery click-repl==0.3.0 # via celery @@ -41,47 +41,49 @@ flexcache==0.3 # via pint flexparser==0.4 # via pint -greenlet==3.1.1 +greenlet==3.4.0 # via sqlalchemy -idna==3.10 +idna==3.11 # via requests -kombu==5.4.2 +kombu==5.6.2 # via celery -mako==1.3.8 +mako==1.3.11 # via alembic -markupsafe==3.0.2 +markupsafe==3.0.3 # via mako -numpy==2.0.2 +numpy==2.4.4 # via pandas -pandas==2.2.3 +packaging==26.1 + # via kombu +pandas==2.3.3 # via bemserver-core (pyproject.toml) -pint==0.24.4 +pint==0.25.3 # via bemserver-core (pyproject.toml) -platformdirs==4.3.6 +platformdirs==4.9.6 # via pint -prompt-toolkit==3.0.48 +prompt-toolkit==3.0.52 # via click-repl -psycopg==3.2.3 +psycopg==3.3.3 # via bemserver-core (pyproject.toml) -pycparser==2.22 +pycparser==3.0 # via cffi python-dateutil==2.9.0.post0 # via # celery # pandas -pytz==2024.2 +pytz==2026.1.post1 # via pandas redis==4.6.0 # via bemserver-core (pyproject.toml) -requests==2.32.3 +requests==2.33.1 # via bemserver-core (pyproject.toml) six==1.17.0 # via python-dateutil -sqlalchemy==2.0.36 +sqlalchemy==2.0.49 # via # alembic # bemserver-core (pyproject.toml) -typing-extensions==4.12.2 +typing-extensions==4.15.0 # via # alembic # flexcache @@ -89,17 +91,18 @@ typing-extensions==4.12.2 # pint # psycopg # sqlalchemy -tzdata==2024.2 +tzdata==2026.1 # via - # celery # kombu # pandas -urllib3==2.3.0 +tzlocal==5.3.1 + # via celery +urllib3==2.6.3 # via requests vine==5.1.0 # via # amqp # celery # kombu -wcwidth==0.2.13 +wcwidth==0.6.0 # via prompt-toolkit diff --git a/requirements/tests.txt b/requirements/tests.txt index 8b1aafbd..9d3e57b0 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -4,32 +4,36 @@ # # pip-compile --unsafe-package=psycopg requirements/tests.in # -coverage[toml]==7.6.10 +coverage[toml]==7.13.5 # via pytest-cov -iniconfig==2.0.0 +iniconfig==2.3.0 # via pytest -mirakuru==2.5.3 +mirakuru==3.0.2 # via pytest-postgresql -packaging==24.2 - # via pytest -pluggy==1.5.0 - # via pytest -port-for==0.7.4 +packaging==26.1 + # via + # pytest + # pytest-postgresql +pluggy==1.6.0 + # via + # pytest + # pytest-cov +port-for==1.0.0 # via pytest-postgresql -psutil==6.1.1 +psutil==7.2.2 # via mirakuru -pytest==8.3.4 +pygments==2.20.0 + # via pytest +pytest==9.0.3 # via # -r requirements/tests.in # pytest-cov # pytest-postgresql -pytest-cov==6.0.0 +pytest-cov==7.1.0 # via -r requirements/tests.in -pytest-postgresql==6.1.1 +pytest-postgresql==8.0.0 # via -r requirements/tests.in -setuptools==75.7.0 - # via pytest-postgresql -typing-extensions==4.12.2 +typing-extensions==4.15.0 # via psycopg # The following packages are considered to be unsafe in a requirements file: From a570c4a8f62897035ea954075d4ccd5c026a3b7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Fri, 17 Apr 2026 10:58:13 +0200 Subject: [PATCH 4/5] Require Python 3.11 --- .github/workflows/build-release.yaml | 4 ++-- pyproject.toml | 4 +--- tox.ini | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-release.yaml b/.github/workflows/build-release.yaml index 636cd638..b2641b48 100644 --- a/.github/workflows/build-release.yaml +++ b/.github/workflows/build-release.yaml @@ -12,9 +12,9 @@ jobs: fail-fast: false matrix: include: - - {name: '3.9', python: '3.9', tox: py39} + - {name: '3.11', python: '3.11', tox: py311} - {name: '3.14', python: '3.14', tox: py314} - - {name: 'min', python: '3.9', tox: min} + - {name: 'min', python: '3.11', tox: min} steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 diff --git a/pyproject.toml b/pyproject.toml index 705d2e23..910fddd7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,14 +18,12 @@ classifiers = [ "Topic :: Scientific/Engineering", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: 3.14", ] -requires-python = ">=3.9" +requires-python = ">=3.11" dependencies = [ "psycopg>=3.1.10,<4.0", "sqlalchemy>=2.0.8,<3.0", diff --git a/tox.ini b/tox.ini index fec719a2..dbfc8ebf 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = lint,py39,py310,py311,py312,py313,py314,min +envlist = lint,py311,py312,py313,py314,min skip_missing_interpreters = True [testenv] From 05c206f50b88c68dfe127fcb36a367acae837708 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lafr=C3=A9choux?= Date: Fri, 17 Apr 2026 11:03:44 +0200 Subject: [PATCH 5/5] Run pre-commit --- .../input_output/timeseries_data_io.py | 2 +- src/bemserver_core/model/events.py | 6 +- src/bemserver_core/process/cleanup.py | 2 +- src/bemserver_core/process/completeness.py | 2 +- src/bemserver_core/process/weather.py | 2 +- tests/conftest.py | 12 +- tests/input_output/test_timeseries_data_io.py | 76 +++++------ tests/model/test_events.py | 26 ++-- tests/model/test_notifications.py | 16 +-- tests/model/test_tasks.py | 4 +- tests/model/test_timeseries.py | 6 +- tests/process/test_cleanup.py | 4 +- tests/process/test_completeness.py | 46 +++---- tests/process/test_degree_days.py | 2 +- tests/process/test_energy_consumption.py | 4 +- tests/process/test_energy_power.py | 122 ++++++++---------- tests/process/test_forward_fill.py | 14 +- tests/process/test_weather.py | 48 +++---- tests/scheduled_tasks/test_check_missing.py | 6 +- tests/scheduled_tasks/test_check_outliers.py | 4 +- tests/scheduled_tasks/test_cleanup.py | 4 +- .../test_download_weather_data.py | 6 +- tests/test_authorization.py | 10 +- tests/test_database.py | 22 ++-- tests/test_time_utils.py | 8 +- 25 files changed, 207 insertions(+), 247 deletions(-) diff --git a/src/bemserver_core/input_output/timeseries_data_io.py b/src/bemserver_core/input_output/timeseries_data_io.py index bea6278e..63cca72a 100644 --- a/src/bemserver_core/input_output/timeseries_data_io.py +++ b/src/bemserver_core/input_output/timeseries_data_io.py @@ -665,7 +665,7 @@ def to_utc_index(index): # We can't just use tz_convert because it would silently swallow naive datetimes try: - index = index.apply(lambda x: x.astimezone(dt.timezone.utc)) + index = index.apply(lambda x: x.astimezone(dt.UTC)) except TypeError as exc: raise TimeseriesDataIODatetimeError("Invalid or TZ-naive timestamp") from exc diff --git a/src/bemserver_core/model/events.py b/src/bemserver_core/model/events.py index 99e22353..506a6645 100644 --- a/src/bemserver_core/model/events.py +++ b/src/bemserver_core/model/events.py @@ -129,7 +129,7 @@ def get( .filter(ubug.user_id == user_id) ) if timeseries_id is not None: - from .timeseries import Timeseries # noqa: avoid cyclic import + from .timeseries import Timeseries # noqa: E402 Timeseries.get_by_id(timeseries_id) query = query.join(TimeseriesByEvent).filter( @@ -316,7 +316,7 @@ def event_after_insert(_mapper, _connection, target): https://stackoverflow.com/questions/25078815/ """ - timestamp = dt.datetime.now(tz=dt.timezone.utc) + timestamp = dt.datetime.now(tz=dt.UTC) @sqla.event.listens_for(db.session, "after_commit", once=True) def event_after_commit_after_insert(_session): @@ -398,7 +398,7 @@ class TimeseriesByEvent(AuthMgrMixin, Base): def _before_flush(self): # Ensure TS and Event are in same Campaign scope if self.timeseries_id and self.event_id: - from .timeseries import Timeseries # noqa: avoid cyclic import + from .timeseries import Timeseries # noqa: E402 timeseries = Timeseries.get_by_id(self.timeseries_id) event = Event.get_by_id(self.event_id) diff --git a/src/bemserver_core/process/cleanup.py b/src/bemserver_core/process/cleanup.py index f2c61725..cde25162 100644 --- a/src/bemserver_core/process/cleanup.py +++ b/src/bemserver_core/process/cleanup.py @@ -37,7 +37,7 @@ def cleanup( ts_mins = Timeseries.get_property_for_many_timeseries(timeseries_ids, "Min") ts_maxs = Timeseries.get_property_for_many_timeseries(timeseries_ids, "Max") - for ts_id, (_, col) in zip(timeseries_ids, data_df.items()): + for ts_id, (_, col) in zip(timeseries_ids, data_df.items(), strict=True): if (ts_min := ts_mins[ts_id]) is not None: col.loc[col < float(ts_min)] = np.nan if (ts_max := ts_maxs[ts_id]) is not None: diff --git a/src/bemserver_core/process/completeness.py b/src/bemserver_core/process/completeness.py index 039da1ce..29795d57 100644 --- a/src/bemserver_core/process/completeness.py +++ b/src/bemserver_core/process/completeness.py @@ -76,7 +76,7 @@ def compute_completeness( else np.nan ) ) - for i, col in zip(intervals, counts_df.columns) + for i, col in zip(intervals, counts_df.columns, strict=True) ] # Add a special case for empty intervals to avoid a deprecation warning diff --git a/src/bemserver_core/process/weather.py b/src/bemserver_core/process/weather.py index 66971f47..dd3e46d6 100644 --- a/src/bemserver_core/process/weather.py +++ b/src/bemserver_core/process/weather.py @@ -185,7 +185,7 @@ def get_weather_data_for_site(self, site, start_dt, end_dt, forecast=False): convert_from = { ts.id: OIKOLAB_WEATHER_PARAMETERS_UNITS_MAPPING[param] - for ts, param in zip(ts_l, params_l) + for ts, param in zip(ts_l, params_l, strict=True) } tsdio.delete(start_dt, end_dt, ts_l, ds_clean) diff --git a/tests/conftest.py b/tests/conftest.py index eafe8290..81fca3d3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -144,8 +144,8 @@ def campaigns(request, bemservercore): for i in range(max(2, request.param)): campaign_i = model.Campaign.new( name=f"Campaign {i + 1}", - start_time=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), - end_time=dt.datetime(2020, 2, 1, tzinfo=dt.timezone.utc), + start_time=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), + end_time=dt.datetime(2020, 2, 1, tzinfo=dt.UTC), ) campaigns.append(campaign_i) db.session.commit() @@ -317,14 +317,14 @@ def events(bemservercore, campaign_scopes, event_categories): with OpenBar(): event_1 = model.Event.new( campaign_scope_id=campaign_scopes[0].id, - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), category_id=event_categories[0].id, level=model.EventLevelEnum.WARNING, source="src", ) event_2 = model.Event.new( campaign_scope_id=campaign_scopes[1].id, - timestamp=dt.datetime(2020, 1, 15, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 15, tzinfo=dt.UTC), category_id=event_categories[1].id, level=model.EventLevelEnum.DEBUG, source="src", @@ -446,13 +446,13 @@ def notifications(bemservercore, events, users): notif_1 = model.Notification.new( event_id=events[0].id, user_id=users[0].id, - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), read=False, ) notif_2 = model.Notification.new( event_id=events[1].id, user_id=users[1].id, - timestamp=dt.datetime(2021, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2021, 1, 1, tzinfo=dt.UTC), read=True, ) db.session.commit() diff --git a/tests/input_output/test_timeseries_data_io.py b/tests/input_output/test_timeseries_data_io.py index df2e4d7a..a0637b19 100644 --- a/tests/input_output/test_timeseries_data_io.py +++ b/tests/input_output/test_timeseries_data_io.py @@ -102,9 +102,7 @@ def test_timeseries_data_io_set_timeseries_data_as_admin( .all() ) - timestamps = [ - dt.datetime(2020, 1, 1, i, tzinfo=dt.timezone.utc) for i in range(4) - ] + timestamps = [dt.datetime(2020, 1, 1, i, tzinfo=dt.UTC) for i in range(4)] expected = [ (timestamp, tsbds_0.id, float(idx)) @@ -148,9 +146,7 @@ def test_timeseries_data_io_set_timeseries_data_as_admin( .all() ) - timestamps = [ - dt.datetime(2020, 1, 1, i, tzinfo=dt.timezone.utc) for i in range(4) - ] + timestamps = [dt.datetime(2020, 1, 1, i, tzinfo=dt.UTC) for i in range(4)] expected = [ (timestamp, tsbds_0.id, float(idx)) @@ -676,7 +672,7 @@ def test_timeseries_data_io_get_timeseries_data_as_admin( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) h1_dt = start_dt + dt.timedelta(hours=1) h2_dt = start_dt + dt.timedelta(hours=2) end_dt = start_dt + dt.timedelta(hours=3) @@ -867,7 +863,7 @@ def test_timeseries_data_io_get_timeseries_data_as_user( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -926,7 +922,7 @@ def test_timeseries_data_io_get_aggreagate_data( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( @@ -992,7 +988,7 @@ def test_timeseries_data_io_get_timeseries_buckets_data_fixed_size_as_admin( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( @@ -1138,7 +1134,7 @@ def test_timeseries_data_io_get_timeseries_buckets_data_fixed_size_as_admin( # Local TZ count 1 week data_df = tsdio.get_timeseries_buckets_data( # Check start_dt TZ doesn't change alignment to 00:00 local TZ - dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + dt.datetime(2020, 1, 1, tzinfo=dt.UTC), dt.datetime(2020, 1, 9, tzinfo=ZoneInfo("Europe/Paris")), ts_l, ds_1, @@ -1534,8 +1530,8 @@ def test_timeseries_data_io_get_timeseries_buckets_data_dst_as_admin( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 10, 25, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 10, 26, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 10, 25, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 10, 26, tzinfo=dt.UTC) timestamps = pd.date_range( start=start_dt, end=end_dt, inclusive="left", freq="h" @@ -1549,8 +1545,8 @@ def test_timeseries_data_io_get_timeseries_buckets_data_dst_as_admin( with CurrentUser(admin_user): # Local TZ count 1 hour data_df = tsdio.get_timeseries_buckets_data( - dt.datetime(2020, 10, 25, 0, 0, tzinfo=dt.timezone.utc), - dt.datetime(2020, 10, 25, 2, 0, tzinfo=dt.timezone.utc), + dt.datetime(2020, 10, 25, 0, 0, tzinfo=dt.UTC), + dt.datetime(2020, 10, 25, 2, 0, tzinfo=dt.UTC), ts_l, ds_1, 1, @@ -1588,16 +1584,16 @@ def test_timeseries_data_io_get_timeseries_buckets_data_fixed_size_dst_as_admin( # In fact, use UTC for all for date_range start_dt_1 = dt.datetime( 2020, 3, 28, tzinfo=ZoneInfo("Europe/Paris") - ).astimezone(dt.timezone.utc) + ).astimezone(dt.UTC) end_dt_1 = dt.datetime(2020, 3, 30, tzinfo=ZoneInfo("Europe/Paris")).astimezone( - dt.timezone.utc + dt.UTC ) start_dt_2 = dt.datetime( 2020, 10, 24, tzinfo=ZoneInfo("Europe/Paris") - ).astimezone(dt.timezone.utc) + ).astimezone(dt.UTC) end_dt_2 = dt.datetime( 2020, 10, 26, tzinfo=ZoneInfo("Europe/Paris") - ).astimezone(dt.timezone.utc) + ).astimezone(dt.UTC) timestamps_1 = pd.date_range( start=start_dt_1, end=end_dt_1, inclusive="left", freq="h" @@ -1651,8 +1647,8 @@ def test_timeseries_data_io_get_timeseries_buckets_data_variable_size_as_admin( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - start_dt_plus_3_months = dt.datetime(2020, 4, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + start_dt_plus_3_months = dt.datetime(2020, 4, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(days=366 + 365) timestamps = pd.date_range( @@ -2029,7 +2025,7 @@ def test_timeseries_data_io_get_timeseries_buckets_data_as_user( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( @@ -2089,7 +2085,7 @@ def test_timeseries_data_io_delete_as_admin( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -2123,7 +2119,7 @@ def test_timeseries_data_io_delete_as_user(self, users, timeseries): ds_1 = TimeseriesDataState.get(name="Raw").first() tsbds_1 = ts_1.get_timeseries_by_data_state(ds_1) - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -2213,9 +2209,7 @@ def test_timeseries_data_io_import_csv_as_admin( .all() ) - timestamps = [ - dt.datetime(2020, 1, 1, i, tzinfo=dt.timezone.utc) for i in range(4) - ] + timestamps = [dt.datetime(2020, 1, 1, i, tzinfo=dt.UTC) for i in range(4)] expected = [ (timestamp, tsbds_0.id, float(idx)) @@ -2259,9 +2253,7 @@ def test_timeseries_data_io_import_csv_as_admin( .all() ) - timestamps = [ - dt.datetime(2020, 1, 1, i, tzinfo=dt.timezone.utc) for i in range(4) - ] + timestamps = [dt.datetime(2020, 1, 1, i, tzinfo=dt.UTC) for i in range(4)] expected = [ (timestamp, tsbds_0.id, float(idx)) @@ -2421,7 +2413,7 @@ def test_timeseries_data_io_export_csv_as_admin(self, users, timeseries, col_lab ds_1 = TimeseriesDataState.get(name="Raw").first() ts_0.unit_symbol = "meter" - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -2515,7 +2507,7 @@ def test_timeseries_data_io_export_csv_as_user(self, users, timeseries, col_labe with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -2566,7 +2558,7 @@ def test_timeseries_data_io_export_csv_bucket_as_admin( ds_1 = TimeseriesDataState.get(name="Raw").first() ts_0.unit_symbol = "meter" - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( @@ -2730,7 +2722,7 @@ def test_timeseries_data_io_export_csv_bucket_as_user( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( @@ -2838,9 +2830,7 @@ def test_timeseries_data_io_import_json_as_admin( .all() ) - timestamps = [ - dt.datetime(2020, 1, 1, i, tzinfo=dt.timezone.utc) for i in range(4) - ] + timestamps = [dt.datetime(2020, 1, 1, i, tzinfo=dt.UTC) for i in range(4)] expected = [ (timestamp, tsbds_0.id, float(idx)) @@ -2884,9 +2874,7 @@ def test_timeseries_data_io_import_json_as_admin( .all() ) - timestamps = [ - dt.datetime(2020, 1, 1, i, tzinfo=dt.timezone.utc) for i in range(4) - ] + timestamps = [dt.datetime(2020, 1, 1, i, tzinfo=dt.UTC) for i in range(4)] expected = [ (timestamp, tsbds_0.id, float(idx)) @@ -3030,7 +3018,7 @@ def test_timeseries_data_io_export_json_as_admin( ds_1 = TimeseriesDataState.get(name="Raw").first() ts_0.unit_symbol = "meter" - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -3149,7 +3137,7 @@ def test_timeseries_data_io_export_json_as_user(self, users, timeseries, col_lab with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=3) timestamps = pd.date_range( @@ -3203,7 +3191,7 @@ def test_timeseries_data_io_export_json_bucket_as_admin( ds_1 = TimeseriesDataState.get(name="Raw").first() ts_0.unit_symbol = "meter" - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( @@ -3438,7 +3426,7 @@ def test_timeseries_data_io_export_json_bucket_as_user( with OpenBar(): ds_1 = TimeseriesDataState.get(name="Raw").first() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) end_dt = start_dt + dt.timedelta(hours=24 * 3) timestamps = pd.date_range( diff --git a/tests/model/test_events.py b/tests/model/test_events.py index 515ff38c..c5437dd5 100644 --- a/tests/model/test_events.py +++ b/tests/model/test_events.py @@ -134,8 +134,8 @@ def test_event_read_only_fields(self, campaign_scopes, event_categories): campaign_scope_2 = campaign_scopes[1] ec_1 = event_categories[0] - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) - timestamp_2 = dt.datetime(2020, 6, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) + timestamp_2 = dt.datetime(2020, 6, 1, tzinfo=dt.UTC) evt_1 = Event.new( campaign_scope_id=campaign_scope_1.id, @@ -175,7 +175,7 @@ def test_event_order_by_level(self, campaign_scopes, event_categories): campaign_scope_1 = campaign_scopes[0] ec_1 = event_categories[0] - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) evt_1 = Event.new( campaign_scope_id=campaign_scope_1.id, @@ -470,7 +470,7 @@ def test_event_authorizations_as_admin( assert Event.get_by_id(event_1.id) == event_1 Event.new( campaign_scope_id=campaign_scope_1.id, - timestamp=dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 5, 1, tzinfo=dt.UTC), category_id=ec_1.id, level=EventLevelEnum.WARNING, source="src", @@ -505,7 +505,7 @@ def test_event_authorizations_as_user( with pytest.raises(BEMServerAuthorizationError): Event.new( campaign_scope_id=campaign_scope_1.id, - timestamp=dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 5, 1, tzinfo=dt.UTC), category_id=ec_1.id, level=EventLevelEnum.WARNING, source="src", @@ -518,7 +518,7 @@ def test_event_authorizations_as_user( # Member of campaign_scope Event.new( campaign_scope_id=campaign_scope_2.id, - timestamp=dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 5, 1, tzinfo=dt.UTC), category_id=ec_1.id, level=EventLevelEnum.WARNING, source="src", @@ -549,7 +549,7 @@ def test_event_notify(self, users, campaign_scopes, event_categories): # Notify INFO: only user_0 is notified event_i = Event.new( campaign_scope_id=campaign_scopes[0].id, - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), category_id=event_categories[0].id, level=EventLevelEnum.INFO, source="src", @@ -565,7 +565,7 @@ def test_event_notify(self, users, campaign_scopes, event_categories): # Notify WARNING: both users are notified event_w = Event.new( campaign_scope_id=campaign_scopes[0].id, - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), category_id=event_categories[0].id, level=EventLevelEnum.WARNING, source="src", @@ -583,7 +583,7 @@ def test_event_notify(self, users, campaign_scopes, event_categories): # Notify ERROR: both users are notified event_e = Event.new( campaign_scope_id=campaign_scopes[0].id, - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), category_id=event_categories[0].id, level=EventLevelEnum.ERROR, source="src", @@ -599,7 +599,7 @@ def test_event_notify(self, users, campaign_scopes, event_categories): def test_event_notify_task(events): evt_1 = events[0] - dt_1 = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) + dt_1 = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) with pytest.raises(BEMServerCoreTaskError): notify_task(DUMMY_ID, dt_1) @@ -623,7 +623,7 @@ def test_event_after_insert(notify_delay_mock, campaign_scopes, event_categories event_1 = Event.new( campaign_scope_id=campaign_scope_1.id, - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), category_id=ec_1.id, level=EventLevelEnum.WARNING, source="src", @@ -644,7 +644,7 @@ def test_event_after_insert(notify_delay_mock, campaign_scopes, event_categories notify_delay_mock.reset_mock() event = Event.new( campaign_scope_id=campaign_scope_1.id, - timestamp=dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 2, tzinfo=dt.UTC), category_id=ec_1.id, level=EventLevelEnum.WARNING, source="src", @@ -658,7 +658,7 @@ def test_event_after_insert(notify_delay_mock, campaign_scopes, event_categories notify_delay_mock.reset_mock() Event.new( campaign_scope_id=campaign_scope_1.id, - timestamp=dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 2, tzinfo=dt.UTC), category_id=ec_1.id, level=EventLevelEnum.WARNING, source="src", diff --git a/tests/model/test_notifications.py b/tests/model/test_notifications.py index 38aa20c5..183da5a4 100644 --- a/tests/model/test_notifications.py +++ b/tests/model/test_notifications.py @@ -32,8 +32,8 @@ def test_notification_read_only_fields(self, users, events): event_1 = events[0] event_2 = events[1] - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) - timestamp_2 = dt.datetime(2020, 6, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) + timestamp_2 = dt.datetime(2020, 6, 1, tzinfo=dt.UTC) notif_1 = Notification.new( user_id=user_1.id, @@ -106,7 +106,7 @@ def test_notification_get_count_by_campaign_as_admin( cs_2 = campaign_scopes[1] ec_1 = event_categories[0] - timestamp_1 = dt.datetime(2021, 1, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2021, 1, 1, tzinfo=dt.UTC) with OpenBar(): event_1 = Event.new( @@ -217,7 +217,7 @@ def test_notification_mark_all_as_read_as_admin( cs_2 = campaign_scopes[1] ec_1 = event_categories[0] - timestamp_1 = dt.datetime(2021, 1, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2021, 1, 1, tzinfo=dt.UTC) with OpenBar(): event_1 = Event.new( @@ -297,7 +297,7 @@ def test_notification_authorizations_as_admin(self, users, events): assert admin_user.is_admin event_1 = events[0] - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) with CurrentUser(admin_user): notifs = list(Notification.get()) @@ -325,7 +325,7 @@ def test_notification_authorizations_as_user(self, users, events, notifications) notif_2 = notifications[1] assert notif_2.user == user_1 - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) with CurrentUser(user_1): notifs = list(Notification.get()) @@ -367,7 +367,7 @@ def test_send_notification_email_task(smtp_mock, users, events): user_1 = users[0] event_1 = events[0] - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) with pytest.raises(BEMServerCoreTaskError): send_notification_email(DUMMY_ID) @@ -415,7 +415,7 @@ def test_notification_after_insert(send_notification_email_delay_mock, users, ev user_1 = users[0] event_1 = events[0] - timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.timezone.utc) + timestamp_1 = dt.datetime(2020, 5, 1, tzinfo=dt.UTC) notif_1 = Notification.new( user_id=user_1.id, diff --git a/tests/model/test_tasks.py b/tests/model/test_tasks.py index 3658c6b1..1c96f36e 100644 --- a/tests/model/test_tasks.py +++ b/tests/model/test_tasks.py @@ -94,5 +94,5 @@ def test_task_by_campaign_make_interval(self, campaigns): ) start_dt, end_dt = tbc_1.make_interval() - assert start_dt == dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - assert end_dt == dt.datetime(2020, 1, 4, tzinfo=dt.timezone.utc) + assert start_dt == dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + assert end_dt == dt.datetime(2020, 1, 4, tzinfo=dt.UTC) diff --git a/tests/model/test_timeseries.py b/tests/model/test_timeseries.py index 1b68c460..d1fed7f2 100644 --- a/tests/model/test_timeseries.py +++ b/tests/model/test_timeseries.py @@ -97,7 +97,7 @@ def test_timeseries_data_state_delete_cascade( ts_data_state_1 = TimeseriesByDataState.get()[0] TimeseriesData.new( - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), timeseries_by_data_state_id=tsbds_1.id, value="12", ) @@ -164,7 +164,7 @@ def test_timeseries_delete_cascade( with CurrentUser(admin_user): TimeseriesData.new( - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), timeseries_by_data_state_id=tsbds_1.id, value="12", ) @@ -993,7 +993,7 @@ def test_timeseries_by_data_state_delete_cascade( with CurrentUser(admin_user): TimeseriesData.new( - timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), + timestamp=dt.datetime(2020, 1, 1, tzinfo=dt.UTC), timeseries_by_data_state_id=tsbds_1.id, value="12", ) diff --git a/tests/process/test_cleanup.py b/tests/process/test_cleanup.py index 8e73db42..b0168617 100644 --- a/tests/process/test_cleanup.py +++ b/tests/process/test_cleanup.py @@ -61,8 +61,8 @@ def test_cleanup_process(self, users, timeseries): value="42", ) - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.UTC) timestamps = pd.date_range(start_dt, end_dt, inclusive="both", freq="6h") values = [0, 13, 33, 42, 69] create_timeseries_data(ts_0, ds_1, timestamps, values) diff --git a/tests/process/test_completeness.py b/tests/process/test_completeness.py index 26655715..14721b14 100644 --- a/tests/process/test_completeness.py +++ b/tests/process/test_completeness.py @@ -55,13 +55,13 @@ def test_compute_completeness(self, users, timeseries): value="1200", ) - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - start_dt_plus_8_hours = dt.datetime(2020, 1, 1, 8, 0, tzinfo=dt.timezone.utc) - start_dt_plus_1_day = dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc) - start_dt_plus_2_days = dt.datetime(2020, 1, 3, tzinfo=dt.timezone.utc) - intermediate_dt_1 = dt.datetime(2020, 1, 25, 10, 3, tzinfo=dt.timezone.utc) - intermediate_dt_2 = dt.datetime(2020, 2, 1, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 3, 1, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + start_dt_plus_8_hours = dt.datetime(2020, 1, 1, 8, 0, tzinfo=dt.UTC) + start_dt_plus_1_day = dt.datetime(2020, 1, 2, tzinfo=dt.UTC) + start_dt_plus_2_days = dt.datetime(2020, 1, 3, tzinfo=dt.UTC) + intermediate_dt_1 = dt.datetime(2020, 1, 25, 10, 3, tzinfo=dt.UTC) + intermediate_dt_2 = dt.datetime(2020, 2, 1, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 3, 1, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, end_dt, inclusive="left", freq="600s") values_1 = range(len(timestamps_1)) @@ -94,8 +94,8 @@ def test_compute_completeness(self, users, timeseries): ret = compute_completeness(start_dt, end_dt, ts_l, ds_1, 1, "month") assert ret == { "timestamps": [ - dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc), - dt.datetime(2020, 2, 1, tzinfo=dt.timezone.utc), + dt.datetime(2020, 1, 1, tzinfo=dt.UTC), + dt.datetime(2020, 2, 1, tzinfo=dt.UTC), ], "timeseries": { 1: { @@ -158,12 +158,8 @@ def test_compute_completeness(self, users, timeseries): # 2 months - daily ret = compute_completeness(start_dt, end_dt, ts_l, ds_1, 1, "day") - assert ret["timestamps"][0] == dt.datetime( - 2020, 1, 1, tzinfo=dt.timezone.utc - ) - assert ret["timestamps"][-1] == dt.datetime( - 2020, 2, 29, tzinfo=dt.timezone.utc - ) + assert ret["timestamps"][0] == dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + assert ret["timestamps"][-1] == dt.datetime(2020, 2, 29, tzinfo=dt.UTC) assert ret["timeseries"][1]["avg_count"] == 144.0 assert ret["timeseries"][1]["total_count"] == 8640 assert ret["timeseries"][1]["avg_ratio"] == 1.0 @@ -197,12 +193,8 @@ def test_compute_completeness(self, users, timeseries): # 2 months - weekly ret = compute_completeness(start_dt, end_dt, ts_l, ds_1, 1, "week") - assert ret["timestamps"][0] == dt.datetime( - 2019, 12, 30, tzinfo=dt.timezone.utc - ) - assert ret["timestamps"][-1] == dt.datetime( - 2020, 2, 24, tzinfo=dt.timezone.utc - ) + assert ret["timestamps"][0] == dt.datetime(2019, 12, 30, tzinfo=dt.UTC) + assert ret["timestamps"][-1] == dt.datetime(2020, 2, 24, tzinfo=dt.UTC) assert ret["timeseries"][1]["count"] == [ 720, 1008, @@ -270,11 +262,9 @@ def test_compute_completeness(self, users, timeseries): ret = compute_completeness( start_dt, start_dt_plus_1_day, ts_l, ds_1, 1, "minute" ) - assert ret["timestamps"][0] == dt.datetime( - 2020, 1, 1, tzinfo=dt.timezone.utc - ) + assert ret["timestamps"][0] == dt.datetime(2020, 1, 1, tzinfo=dt.UTC) assert ret["timestamps"][-1] == dt.datetime( - 2020, 1, 1, 23, 59, tzinfo=dt.timezone.utc + 2020, 1, 1, 23, 59, tzinfo=dt.UTC ) assert ret["timeseries"][1]["avg_count"] == 0.1 assert ret["timeseries"][1]["total_count"] == 6 * 24 @@ -307,9 +297,9 @@ def test_compute_completeness(self, users, timeseries): ) assert ret == { "timestamps": [ - dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc), - dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.timezone.utc), - dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc), + dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC), + dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.UTC), + dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC), ], "timeseries": { 1: { diff --git a/tests/process/test_degree_days.py b/tests/process/test_degree_days.py index 2751338b..644fe89c 100644 --- a/tests/process/test_degree_days.py +++ b/tests/process/test_degree_days.py @@ -22,7 +22,7 @@ @pytest.mark.parametrize("type_", ("heating", "cooling")) @pytest.mark.parametrize("base", (18, 19.5)) -@pytest.mark.parametrize("timezone", (dt.timezone.utc, ZoneInfo("Europe/Paris"))) +@pytest.mark.parametrize("timezone", (dt.UTC, ZoneInfo("Europe/Paris"))) def test_compute_dd(type_, base, timezone): index = pd.date_range( "2020-01-01", "2021-01-01", freq="h", tz=timezone, inclusive="left" diff --git a/tests/process/test_energy_consumption.py b/tests/process/test_energy_consumption.py index 4bb1d769..3e26a899 100644 --- a/tests/process/test_energy_consumption.py +++ b/tests/process/test_energy_consumption.py @@ -30,8 +30,8 @@ class TestEnergyConsumption: def _create_data(self, campaign, campaign_scope): - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) timestamps = pd.date_range(start_dt, end_dt, inclusive="left", freq="h") diff --git a/tests/process/test_energy_power.py b/tests/process/test_energy_power.py index c7169fea..213979a6 100644 --- a/tests/process/test_energy_power.py +++ b/tests/process/test_energy_power.py @@ -50,10 +50,10 @@ def test_power2energy_process(self, users, timeseries): ts_2.unit_symbol = "kW" ts_3.unit_symbol = "W" - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.timezone.utc) - h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.UTC) + h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, h6_dt, inclusive="left", freq="h") values_1 = [ts.hour % 2 for ts in timestamps_1] @@ -75,8 +75,8 @@ def test_power2energy_process(self, users, timeseries): timestamps = sum( [ [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc), - dt.datetime(2020, 1, 1, hour, 30, tzinfo=dt.timezone.utc), + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC), + dt.datetime(2020, 1, 1, hour, 30, tzinfo=dt.UTC), ] for hour in (0, 1, 2, 3) ], @@ -90,8 +90,7 @@ def test_power2energy_process(self, users, timeseries): data_s = power2energy(start_dt, h4_dt, ts_0, ds_1, 3600, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 1, 2, 3) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3) ] expected_data_s = pd.Series( [0.0, 1.0, 0.0, 1.0], @@ -101,8 +100,7 @@ def test_power2energy_process(self, users, timeseries): data_s = power2energy(start_dt, h4_dt, ts_0, ds_1, 7200, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 2) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 2) ] expected_data_s = pd.Series( [1.0, 1.0], @@ -112,8 +110,7 @@ def test_power2energy_process(self, users, timeseries): data_s = power2energy(start_dt, h4_dt, ts_0, ds_1, 3600, "mWh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 1, 2, 3) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3) ] expected_data_s = pd.Series( [0.0, 1000.0, 0.0, 1000.0], @@ -123,7 +120,7 @@ def test_power2energy_process(self, users, timeseries): data_s = power2energy(h4_dt, end_dt, ts_1, ds_1, 7200, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (4, 6, 8, 10) ] expected_data_s = pd.Series( @@ -134,8 +131,7 @@ def test_power2energy_process(self, users, timeseries): data_s = power2energy(start_dt, end_dt, ts_2, ds_1, 14400, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 4, 8) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 4, 8) ] expected_data_s = pd.Series( [np.nan, 168000.0, 168000.0], @@ -145,8 +141,7 @@ def test_power2energy_process(self, users, timeseries): data_s = power2energy(start_dt, end_dt, ts_3, ds_1, 14400, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 4, 8) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 4, 8) ] expected_data_s = pd.Series( [np.nan, np.nan, np.nan], @@ -166,12 +161,12 @@ def test_power2energy_process(self, users, timeseries): timestamps = sum( [ [ - dt.datetime( - 2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc - ).astimezone(ZoneInfo("Europe/Paris")), - dt.datetime( - 2020, 1, 1, hour, 30, tzinfo=dt.timezone.utc - ).astimezone(ZoneInfo("Europe/Paris")), + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC).astimezone( + ZoneInfo("Europe/Paris") + ), + dt.datetime(2020, 1, 1, hour, 30, tzinfo=dt.UTC).astimezone( + ZoneInfo("Europe/Paris") + ), ] for hour in (0, 1, 2, 3) ], @@ -232,10 +227,10 @@ def test_energy2power_process(self, users, timeseries): value="3600", ) - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.timezone.utc) - h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.UTC) + h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, h6_dt, inclusive="left", freq="h") values_1 = [ts.hour % 2 for ts in timestamps_1] @@ -255,8 +250,7 @@ def test_energy2power_process(self, users, timeseries): with CurrentUser(admin_user): data_s = energy2power(start_dt, h4_dt, ts_0, ds_1, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 1, 2, 3) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3) ] expected_data_s = pd.Series( [0.0, 1.0, 0.0, 1.0], @@ -266,8 +260,7 @@ def test_energy2power_process(self, users, timeseries): data_s = energy2power(start_dt, h4_dt, ts_0, ds_1, "mW") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 1, 2, 3) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3) ] expected_data_s = pd.Series( [0.0, 1000.0, 0.0, 1000.0], @@ -277,8 +270,7 @@ def test_energy2power_process(self, users, timeseries): data_s = energy2power(h4_dt, end_dt, ts_1, ds_1, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (6, 9) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (6, 9) ] expected_data_s = pd.Series( [6.0, 9.0], @@ -287,7 +279,7 @@ def test_energy2power_process(self, users, timeseries): assert_series_equal(data_s, expected_data_s) data_s = energy2power(start_dt, end_dt, ts_2, ds_1, "W") - timestamps = [dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.timezone.utc)] + timestamps = [dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.UTC)] expected_data_s = pd.Series( [ 21000.0, @@ -300,9 +292,7 @@ def test_energy2power_process(self, users, timeseries): timestamps = [] expected_data_s = pd.Series( [], - index=pd.DatetimeIndex( - timestamps, name="timestamp", tz=dt.timezone.utc - ), + index=pd.DatetimeIndex(timestamps, name="timestamp", tz=dt.UTC), dtype=float, ) assert_series_equal(data_s, expected_data_s) @@ -318,7 +308,7 @@ def test_energy2power_process(self, users, timeseries): start_dt.astimezone(ZoneInfo("Europe/Paris")), h4_dt, ts_0, ds_1, "W" ) timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc).astimezone( + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC).astimezone( ZoneInfo("Europe/Paris") ) for hour in (0, 1, 2, 3) @@ -355,10 +345,10 @@ def test_energyindex2power_process(self, users, timeseries): ts_2.unit_symbol = "kWh" ts_3.unit_symbol = "Wh" - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.timezone.utc) - h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.UTC) + h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, h6_dt, inclusive="left", freq="h") values_1 = [ts.hour**2 for ts in timestamps_1] @@ -378,7 +368,7 @@ def test_energyindex2power_process(self, users, timeseries): with CurrentUser(admin_user): data_s = energyindex2power(start_dt, h6_dt, ts_0, ds_1, 3600, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3, 4, 5) ] expected_data_s = pd.Series( @@ -389,8 +379,7 @@ def test_energyindex2power_process(self, users, timeseries): data_s = energyindex2power(start_dt, h6_dt, ts_0, ds_1, 7200, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 2, 4) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 2, 4) ] expected_data_s = pd.Series( [2.0, 6.0, 9.0], @@ -400,7 +389,7 @@ def test_energyindex2power_process(self, users, timeseries): data_s = energyindex2power(start_dt, h6_dt, ts_0, ds_1, 3600, "mW") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3, 4, 5) ] expected_data_s = pd.Series( @@ -411,7 +400,7 @@ def test_energyindex2power_process(self, users, timeseries): data_s = energyindex2power(h4_dt, end_dt, ts_1, ds_1, 3600, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (4, 5, 6, 7, 8, 9, 10, 11) ] expected_data_s = pd.Series( @@ -422,7 +411,7 @@ def test_energyindex2power_process(self, users, timeseries): data_s = energyindex2power(start_dt, end_dt, ts_1, ds_1, 3600, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) ] expected_data_s = pd.Series( @@ -433,8 +422,7 @@ def test_energyindex2power_process(self, users, timeseries): data_s = energyindex2power(start_dt, end_dt, ts_2, ds_1, 3600, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in range(12) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in range(12) ] expected_data_s = pd.Series( 12 * [np.nan], @@ -444,13 +432,13 @@ def test_energyindex2power_process(self, users, timeseries): data_s = energyindex2power(start_dt, end_dt, ts_3, ds_1, 14400, "W") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in range(0, 12, 4) ] expected_data_s = pd.Series( 3 * [np.nan], index=pd.DatetimeIndex( - timestamps, name="timestamp", tz=dt.timezone.utc, freq="4h" + timestamps, name="timestamp", tz=dt.UTC, freq="4h" ), dtype=float, ) @@ -466,7 +454,7 @@ def test_energyindex2power_process(self, users, timeseries): "W", ) timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc).astimezone( + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC).astimezone( ZoneInfo("Europe/Paris") ) for hour in (0, 1, 2, 3, 4, 5) @@ -503,10 +491,10 @@ def test_energyindex2energy_process(self, users, timeseries): ts_2.unit_symbol = "kWh" ts_3.unit_symbol = "Wh" - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.timezone.utc) - h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.UTC) + h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, h6_dt, inclusive="left", freq="h") values_1 = [ts.hour**2 for ts in timestamps_1] @@ -526,7 +514,7 @@ def test_energyindex2energy_process(self, users, timeseries): with CurrentUser(admin_user): data_s = energyindex2energy(start_dt, h6_dt, ts_0, ds_1, 3600, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3, 4, 5) ] expected_data_s = pd.Series( @@ -537,8 +525,7 @@ def test_energyindex2energy_process(self, users, timeseries): data_s = energyindex2energy(start_dt, h6_dt, ts_0, ds_1, 7200, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in (0, 2, 4) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 2, 4) ] expected_data_s = pd.Series( [4.0, 12.0, 18.0], @@ -548,7 +535,7 @@ def test_energyindex2energy_process(self, users, timeseries): data_s = energyindex2energy(start_dt, h6_dt, ts_0, ds_1, 3600, "mWh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3, 4, 5) ] expected_data_s = pd.Series( @@ -559,7 +546,7 @@ def test_energyindex2energy_process(self, users, timeseries): data_s = energyindex2energy(h4_dt, end_dt, ts_1, ds_1, 3600, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (4, 5, 6, 7, 8, 9, 10, 11) ] expected_data_s = pd.Series( @@ -570,7 +557,7 @@ def test_energyindex2energy_process(self, users, timeseries): data_s = energyindex2energy(start_dt, end_dt, ts_1, ds_1, 3600, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) ] expected_data_s = pd.Series( @@ -581,8 +568,7 @@ def test_energyindex2energy_process(self, users, timeseries): data_s = energyindex2energy(start_dt, end_dt, ts_2, ds_1, 3600, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) - for hour in range(12) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in range(12) ] expected_data_s = pd.Series( 12 * [np.nan], @@ -592,13 +578,13 @@ def test_energyindex2energy_process(self, users, timeseries): data_s = energyindex2energy(start_dt, end_dt, ts_3, ds_1, 14400, "Wh") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in range(0, 12, 4) ] expected_data_s = pd.Series( 3 * [np.nan], index=pd.DatetimeIndex( - timestamps, name="timestamp", tz=dt.timezone.utc, freq="4h" + timestamps, name="timestamp", tz=dt.UTC, freq="4h" ), dtype=float, ) @@ -614,7 +600,7 @@ def test_energyindex2energy_process(self, users, timeseries): "Wh", ) timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc).astimezone( + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC).astimezone( ZoneInfo("Europe/Paris") ) for hour in (0, 1, 2, 3, 4, 5) diff --git a/tests/process/test_forward_fill.py b/tests/process/test_forward_fill.py index daf6f6b3..bf6ac835 100644 --- a/tests/process/test_forward_fill.py +++ b/tests/process/test_forward_fill.py @@ -34,10 +34,10 @@ def test_ffill_process(self, users, timeseries): with OpenBar(): ds_1 = TimeseriesDataState.get(name="Clean").first() - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.timezone.utc) - h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + h4_dt = dt.datetime(2020, 1, 1, 4, 0, tzinfo=dt.UTC) + h6_dt = dt.datetime(2020, 1, 1, 6, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, h6_dt, inclusive="left", freq="h") values_1 = [ts.hour % 2 for ts in timestamps_1] @@ -60,7 +60,7 @@ def test_ffill_process(self, users, timeseries): data_df = ffill(h4_dt, end_dt, ts_l, ds_1, 2, "hour") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (4, 5, 6, 8, 9, 10) ] expected_data_df = pd.DataFrame( @@ -80,7 +80,7 @@ def test_ffill_process(self, users, timeseries): ) timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (6, 8, 9, 10) ] expected_data_df = pd.DataFrame( @@ -100,7 +100,7 @@ def test_ffill_process(self, users, timeseries): data_df = ffill(h4_dt, end_dt, ts_l, ds_1, 2, "hour") timestamps = [ - dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.timezone.utc) + dt.datetime(2020, 1, 1, hour, 0, tzinfo=dt.UTC) for hour in (4, 5, 6, 8, 10) ] expected_data_df = pd.DataFrame( diff --git a/tests/process/test_weather.py b/tests/process/test_weather.py index f4b24761..23d5aa62 100644 --- a/tests/process/test_weather.py +++ b/tests/process/test_weather.py @@ -42,9 +42,9 @@ class TestWeatherClient: @patch("requests.get") @pytest.mark.parametrize("forecast", (False, True)) def test_get_weather_data(self, mock_get, forecast): - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) - oik_end_dt = dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) + oik_end_dt = dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.UTC) resp_data = { "columns": [ @@ -120,8 +120,8 @@ def test_get_weather_data_auth_error(self, mock_get): params=["AIR_TEMPERATURE"], latitude="dummy", longitude=6.0, - start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc), - end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc), + start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC), + end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC), ) @patch("requests.get") @@ -137,8 +137,8 @@ def test_get_weather_data_query_error(self, mock_get): params=["AIR_TEMPERATURE"], latitude="dummy", longitude=6.0, - start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc), - end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc), + start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC), + end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC), ) @patch("requests.get") @@ -153,8 +153,8 @@ def test_get_weather_data_connexion_error(self, mock_get): params=["AIR_TEMPERATURE"], latitude=46.0, longitude=6.0, - start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc), - end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc), + start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC), + end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC), ) @pytest.mark.parametrize( @@ -180,8 +180,8 @@ def test_get_weather_data_response_invalid_response_json_error( params=["AIR_TEMPERATURE", "RELATIVE_HUMIDITY"], latitude=46.0, longitude=6.0, - start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc), - end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc), + start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC), + end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC), ) @pytest.mark.parametrize( @@ -268,8 +268,8 @@ def test_get_weather_data_response_invalid_response_data_error( params=["AIR_TEMPERATURE", "RELATIVE_HUMIDITY"], latitude=46.0, longitude=6.0, - start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc), - end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc), + start_dt=dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC), + end_dt=dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC), ) @@ -294,9 +294,9 @@ def test_get_weather_data_for_site( rh_ts = wtbs_2.timeseries ds_clean = TimeseriesDataState.get(name="Clean").first() - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) - oik_end_dt = dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) + oik_end_dt = dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.UTC) # The payload should contain only air temp or RH depending on the call # but for the purpose of the test, it is easier here to write a single payload. @@ -433,8 +433,8 @@ def test_get_weather_data_for_site( def test_get_weather_data_for_site_no_call_if_no_ts(self, mock_get, sites): site_1 = sites[0] - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) wdp.get_weather_data_for_site(site_1, start_dt, end_dt) mock_get.assert_not_called() @@ -463,8 +463,8 @@ def test_get_weather_data_for_site_no_call_if_no_ts(self, mock_get, sites): def test_get_weather_data_for_site_api_settings_error(self, sites): site_1 = sites[0] - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) with pytest.raises( BEMServerCoreSettingsError, match="Missing weather API settings." @@ -489,8 +489,8 @@ def test_get_weather_data_for_site_missing_coordinates(self, sites, missing_coor for coord in missing_coords: setattr(site_1, coord, None) - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) with pytest.raises( BEMServerCoreWeatherProcessMissingCoordinatesError, @@ -505,8 +505,8 @@ def test_get_weather_data_for_site_as_user(self, users, sites): user_2 = users[1] site_1 = sites[0] - start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, 0, tzinfo=dt.UTC) with CurrentUser(user_2): with pytest.raises(BEMServerAuthorizationError): diff --git a/tests/scheduled_tasks/test_check_missing.py b/tests/scheduled_tasks/test_check_missing.py index c97937fa..5fc116c6 100644 --- a/tests/scheduled_tasks/test_check_missing.py +++ b/tests/scheduled_tasks/test_check_missing.py @@ -61,9 +61,9 @@ def test_check_missing_ts_data(self, users, timeseries, campaigns): ) db.session.flush() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - intermediate_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + intermediate_dt = dt.datetime(2020, 1, 1, 12, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.UTC) timestamps_1 = pd.date_range(start_dt, end_dt, inclusive="left", freq="600s") values_1 = range(len(timestamps_1)) diff --git a/tests/scheduled_tasks/test_check_outliers.py b/tests/scheduled_tasks/test_check_outliers.py index 4fc6ac17..d8a64a5f 100644 --- a/tests/scheduled_tasks/test_check_outliers.py +++ b/tests/scheduled_tasks/test_check_outliers.py @@ -77,8 +77,8 @@ def test_check_outliers_ts_data(self, users, timeseries, campaigns): ec_data_no_outliers = EventCategory.get(name="No data outliers").first() db.session.flush() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.UTC) timestamps = pd.date_range(start_dt, end_dt, inclusive="left", freq="5h") values = [0, 13, 33, 42, 69] create_timeseries_data(ts_1, ds_1, timestamps, values) diff --git a/tests/scheduled_tasks/test_cleanup.py b/tests/scheduled_tasks/test_cleanup.py index 8e479e87..f22522c6 100644 --- a/tests/scheduled_tasks/test_cleanup.py +++ b/tests/scheduled_tasks/test_cleanup.py @@ -38,8 +38,8 @@ def test_cleanup_data(self, users, timeseries, campaigns): ) db.session.flush() - start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 2, tzinfo=dt.UTC) timestamps = pd.date_range(start_dt, end_dt, inclusive="left", freq="12h") values = [0, 13] create_timeseries_data(ts_0, ds_1, timestamps, values) diff --git a/tests/scheduled_tasks/test_download_weather_data.py b/tests/scheduled_tasks/test_download_weather_data.py index 59f4d423..efe2ed05 100644 --- a/tests/scheduled_tasks/test_download_weather_data.py +++ b/tests/scheduled_tasks/test_download_weather_data.py @@ -47,9 +47,9 @@ def test_download_weather_data( campaign_1 = campaigns[0] campaign_2 = campaigns[1] - start_dt = dt.datetime(2020, 1, 1, 0, tzinfo=dt.timezone.utc) - end_dt = dt.datetime(2020, 1, 1, 2, tzinfo=dt.timezone.utc) - oik_end_dt = dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.timezone.utc) + start_dt = dt.datetime(2020, 1, 1, 0, tzinfo=dt.UTC) + end_dt = dt.datetime(2020, 1, 1, 2, tzinfo=dt.UTC) + oik_end_dt = dt.datetime(2020, 1, 1, 1, 0, tzinfo=dt.UTC) with OpenBar(): ds_clean = TimeseriesDataState.get(name="Clean").first() diff --git a/tests/test_authorization.py b/tests/test_authorization.py index a3d6ca09..6e8cd915 100644 --- a/tests/test_authorization.py +++ b/tests/test_authorization.py @@ -87,9 +87,9 @@ class TestAuthMgrMixinMinMax(Base, AuthMgrMixin): Test.__table__.create(bind=db.engine) - mes_1 = Test(note=10, date=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc)) - mes_2 = Test(note=15, date=dt.datetime(2025, 1, 1, tzinfo=dt.timezone.utc)) - mes_3 = Test(note=18, date=dt.datetime(2015, 1, 1, tzinfo=dt.timezone.utc)) + mes_1 = Test(note=10, date=dt.datetime(2020, 1, 1, tzinfo=dt.UTC)) + mes_2 = Test(note=15, date=dt.datetime(2025, 1, 1, tzinfo=dt.UTC)) + mes_3 = Test(note=18, date=dt.datetime(2015, 1, 1, tzinfo=dt.UTC)) db.session.add(mes_1) db.session.add(mes_2) db.session.add(mes_3) @@ -97,12 +97,12 @@ class TestAuthMgrMixinMinMax(Base, AuthMgrMixin): ret = Test.get(note_min=12).all() assert ret == [mes_2, mes_3] - ret = Test.get(date_min=dt.datetime(2019, 1, 1, tzinfo=dt.timezone.utc)).all() + ret = Test.get(date_min=dt.datetime(2019, 1, 1, tzinfo=dt.UTC)).all() assert ret == [mes_1, mes_2] ret = Test.get( note_max=12, - date_min=dt.datetime(2019, 1, 1, tzinfo=dt.timezone.utc), + date_min=dt.datetime(2019, 1, 1, tzinfo=dt.UTC), ).all() assert ret == [ mes_1, diff --git a/tests/test_database.py b/tests/test_database.py index 5046a98a..fcce3afa 100644 --- a/tests/test_database.py +++ b/tests/test_database.py @@ -98,9 +98,9 @@ class TestDatabaseBaseMinMax(Base): Test.__table__.create(bind=db.engine) - mes_1 = Test(note=10, date=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc)) - mes_2 = Test(note=15, date=dt.datetime(2025, 1, 1, tzinfo=dt.timezone.utc)) - mes_3 = Test(note=18, date=dt.datetime(2015, 1, 1, tzinfo=dt.timezone.utc)) + mes_1 = Test(note=10, date=dt.datetime(2020, 1, 1, tzinfo=dt.UTC)) + mes_2 = Test(note=15, date=dt.datetime(2025, 1, 1, tzinfo=dt.UTC)) + mes_3 = Test(note=18, date=dt.datetime(2015, 1, 1, tzinfo=dt.UTC)) db.session.add(mes_1) db.session.add(mes_2) db.session.add(mes_3) @@ -108,12 +108,12 @@ class TestDatabaseBaseMinMax(Base): ret = Test.get(note_min=12).all() assert ret == [mes_2, mes_3] - ret = Test.get(date_min=dt.datetime(2019, 1, 1, tzinfo=dt.timezone.utc)).all() + ret = Test.get(date_min=dt.datetime(2019, 1, 1, tzinfo=dt.UTC)).all() assert ret == [mes_1, mes_2] ret = Test.get( note_max=12, - date_min=dt.datetime(2019, 1, 1, tzinfo=dt.timezone.utc), + date_min=dt.datetime(2019, 1, 1, tzinfo=dt.UTC), ).all() assert ret == [ mes_1, @@ -135,17 +135,13 @@ class TestDatabaseBaseInSearch(Base): Test.__table__.create(bind=db.engine) - mes_1 = Test( - name="Toto", note=10, date=dt.datetime(2020, 1, 1, tzinfo=dt.timezone.utc) - ) + mes_1 = Test(name="Toto", note=10, date=dt.datetime(2020, 1, 1, tzinfo=dt.UTC)) mes_2 = Test( name="Juanito", note=15, - date=dt.datetime(2025, 1, 1, tzinfo=dt.timezone.utc), - ) - mes_3 = Test( - name="Juan", note=18, date=dt.datetime(2015, 1, 1, tzinfo=dt.timezone.utc) + date=dt.datetime(2025, 1, 1, tzinfo=dt.UTC), ) + mes_3 = Test(name="Juan", note=18, date=dt.datetime(2015, 1, 1, tzinfo=dt.UTC)) db.session.add(mes_1) db.session.add(mes_2) db.session.add(mes_3) @@ -156,7 +152,7 @@ class TestDatabaseBaseInSearch(Base): Test.get(in_note=12).all() db.session.rollback() with pytest.raises(sqla.exc.ProgrammingError): - Test.get(in_date=dt.datetime(2019, 1, 1, tzinfo=dt.timezone.utc)).all() + Test.get(in_date=dt.datetime(2019, 1, 1, tzinfo=dt.UTC)).all() db.session.rollback() # Exact matches. diff --git a/tests/test_time_utils.py b/tests/test_time_utils.py index 7ee4098d..989838e3 100644 --- a/tests/test_time_utils.py +++ b/tests/test_time_utils.py @@ -29,7 +29,7 @@ def test_time_utils_make_date_offset(): class TestTimeUtilsFloor: - @pytest.mark.parametrize("timezone", (dt.timezone.utc, ZoneInfo("Europe/Paris"))) + @pytest.mark.parametrize("timezone", (dt.UTC, ZoneInfo("Europe/Paris"))) def test_floor(self, timezone): datetime = dt.datetime(2020, 3, 17, 5, 23, 54, 123, tzinfo=timezone) assert floor(datetime, "year") == dt.datetime(2020, 1, 1, tzinfo=timezone) @@ -79,7 +79,7 @@ def test_floor_variable_size_with_multiplier(self, period): class TestTimeUtilsCeil: - @pytest.mark.parametrize("timezone", (dt.timezone.utc, ZoneInfo("Europe/Paris"))) + @pytest.mark.parametrize("timezone", (dt.UTC, ZoneInfo("Europe/Paris"))) def test_ceil(self, timezone): datetime = dt.datetime(2020, 3, 17, 5, 23, 54, 123, tzinfo=timezone) assert ceil(datetime, "year") == dt.datetime(2021, 1, 1, tzinfo=timezone) @@ -111,7 +111,7 @@ def test_ceil(self, timezone): 2020, 3, 17, 5, 24, 0, tzinfo=timezone ) - @pytest.mark.parametrize("timezone", (dt.timezone.utc, ZoneInfo("Europe/Paris"))) + @pytest.mark.parametrize("timezone", (dt.UTC, ZoneInfo("Europe/Paris"))) def test_ceil_round_value(self, timezone): datetime = dt.datetime(2018, 1, 1, 0, 0, 0, 0, tzinfo=timezone) assert ceil(datetime, "year") == datetime @@ -144,7 +144,7 @@ def test_ceil_variable_size_with_multiplier(self, period): ceil(dt.datetime(2020, 1, 1), period, 2) -@pytest.mark.parametrize("timezone", (dt.timezone.utc, ZoneInfo("Europe/Paris"))) +@pytest.mark.parametrize("timezone", (dt.UTC, ZoneInfo("Europe/Paris"))) def test_make_date_range_around_datetime(timezone): dt_1 = dt.datetime(2020, 1, 1, 0, 0, tzinfo=timezone) assert make_date_range_around_datetime(dt_1, "hour", 1, 0, 0) == (