From 8f7e082a26e2be9964b8c8e8f5ae9219c0d1d22d Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Wed, 4 Sep 2024 14:22:18 +0200 Subject: [PATCH] Fix #138 (#139) * convert datetime.timedelta to seconds before comparison * bump version * remove function from tests * update actions to avoid warnings * fix error --------- Co-authored-by: Jan Caha --- .github/workflows/build_windows.yaml | 8 ++++---- .github/workflows/tests_mergin_db_sync.yaml | 1 - CHANGELOG.md | 4 ++++ dbsync_daemon.py | 5 ++++- test/test_config.py | 2 +- version.py | 2 +- 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_windows.yaml b/.github/workflows/build_windows.yaml index e6d8b37..e24e93c 100644 --- a/.github/workflows/build_windows.yaml +++ b/.github/workflows/build_windows.yaml @@ -10,9 +10,9 @@ jobs: steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - - uses: robinraju/release-downloader@v1.8 + - uses: robinraju/release-downloader@v1.10 with: repository: "MerginMaps/geodiff" latest: true @@ -26,7 +26,7 @@ jobs: cd scripts/windows_binaries del geodiff_*.zip - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: '3.10' @@ -44,7 +44,7 @@ jobs: run: copy config.yaml.default scripts/dist/config.yaml - name: Upload Zip file as artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: dbsync_standalone_win path: scripts/dist \ No newline at end of file diff --git a/.github/workflows/tests_mergin_db_sync.yaml b/.github/workflows/tests_mergin_db_sync.yaml index 50a0e53..f67eb22 100644 --- a/.github/workflows/tests_mergin_db_sync.yaml +++ b/.github/workflows/tests_mergin_db_sync.yaml @@ -59,7 +59,6 @@ jobs: python3 -m pip install -r requirements.txt python3 -m pip install -r requirements-dev.txt - - name: Run tests run: | pytest test --cov=. --cov-report=term-missing:skip-covered -vv diff --git a/CHANGELOG.md b/CHANGELOG.md index 8f9238a..72c17cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 2.1.2 + +- Fix datetime.timedelta comparison to seconds + ## 2.1.1 - Fix failure to start when notifications were not enabled diff --git a/dbsync_daemon.py b/dbsync_daemon.py index f381099..5baa1cb 100644 --- a/dbsync_daemon.py +++ b/dbsync_daemon.py @@ -191,7 +191,10 @@ def main(): else: min_time_delta_hr = 4 - if last_email_sent is None or (datetime.datetime.now() - last_email_sent) > min_time_delta_hr * 3600: + if ( + last_email_sent is None + or (datetime.datetime.now() - last_email_sent).total_seconds() > min_time_delta_hr * 3600 + ): send_email(str(e), config) last_email_sent = datetime.datetime.now() diff --git a/test/test_config.py b/test/test_config.py index c47db69..8d0258e 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -5,6 +5,7 @@ License: MIT """ + import pytest from config import ConfigError, config, get_ignored_tables, validate_config @@ -254,7 +255,6 @@ def test_get_ignored_tables(): def test_config_notification_setup(): _reset_config() - # no NOTIFICATIONS set should pass but cannot send email validate_config(config) # incomplete setting diff --git a/version.py b/version.py index 58039f5..4eabd0b 100644 --- a/version.py +++ b/version.py @@ -1 +1 @@ -__version__ = "2.1.1" +__version__ = "2.1.2"