From f9ea2d07f78ba8513216b111c864a2b2858fb277 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Tue, 28 May 2024 12:09:57 +0200 Subject: [PATCH 1/5] convert datetime.timedelta to seconds before comparison --- dbsync_daemon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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() From 9bdb041bd7bdf1b735937d84f2fc79d4a8049788 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Tue, 28 May 2024 12:11:10 +0200 Subject: [PATCH 2/5] bump version --- CHANGELOG.md | 4 ++++ version.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) 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/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" From f27e0c0c03ed791b4e8722349d768ad481316986 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Tue, 28 May 2024 12:59:27 +0200 Subject: [PATCH 3/5] remove function from tests --- test/test_config.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/test/test_config.py b/test/test_config.py index cd6458c..39b2d84 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -5,10 +5,10 @@ License: MIT """ + import pytest from config import ConfigError, config, get_ignored_tables, validate_config -from smtp_functions import can_send_email from .conftest import _reset_config @@ -255,9 +255,7 @@ def test_get_ignored_tables(): def test_config_notification_setup(): _reset_config() - # no NOTIFICATIONS set should pass but cannot send email validate_config(config) - assert can_send_email(config) is False # incomplete setting config.update( @@ -347,6 +345,3 @@ def test_config_notification_setup(): with pytest.raises(ConfigError, match="Config SMTP Error"): validate_config(config) - - # notifications are set, emails can be send - but this config was not validated, as it would be in real run - assert can_send_email(config) From 352be3fa999c0a449b0c8daa944396ebc6eaba60 Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Tue, 28 May 2024 13:01:25 +0200 Subject: [PATCH 4/5] update actions to avoid warnings --- .github/workflows/build_windows.yaml | 8 ++++---- .github/workflows/tests_mergin_db_sync.yaml | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build_windows.yaml b/.github/workflows/build_windows.yaml index 6b7311b..2a0e46c 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' @@ -43,7 +43,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 6d6d5ee..cdf42b6 100644 --- a/.github/workflows/tests_mergin_db_sync.yaml +++ b/.github/workflows/tests_mergin_db_sync.yaml @@ -53,7 +53,7 @@ jobs: python3 -m pip install mergin-client pytest pytest-cov dynaconf psycopg2 - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: Run tests run: | From a078322296ba04e1365036d12578e1c186f2002f Mon Sep 17 00:00:00 2001 From: Jan Caha Date: Tue, 28 May 2024 13:11:08 +0200 Subject: [PATCH 5/5] fix error --- test/test_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_config.py b/test/test_config.py index 39b2d84..8d0258e 100644 --- a/test/test_config.py +++ b/test/test_config.py @@ -324,7 +324,7 @@ def test_config_notification_setup(): } ) - with pytest.raises(ConfigError, match="Config error: `smtp_port` must be set an integer"): + with pytest.raises(ConfigError, match="Config error: `smtp_port` must be set to an integer"): validate_config(config) # complete setting but does not work config.update(