From 244482ba1d4798658428274f83e4cb9323252b14 Mon Sep 17 00:00:00 2001 From: geirawsm Date: Mon, 26 Aug 2024 23:56:21 +0200 Subject: [PATCH] Fixing `datetime_handling_test` --- sausage_bot/test/datetime_handling_test.py | 44 ++++++++++++---------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/sausage_bot/test/datetime_handling_test.py b/sausage_bot/test/datetime_handling_test.py index fa99dea..9239b85 100755 --- a/sausage_bot/test/datetime_handling_test.py +++ b/sausage_bot/test/datetime_handling_test.py @@ -4,39 +4,43 @@ from sausage_bot.util import datetime_handling as dt -def test_correct_date_converting(): - assert str(dt.make_dt('17.05.22')) == '2022-05-17 00:00:00+00:00' - assert str(dt.make_dt('17.05.20 22')) == '2022-05-17 00:00:00+00:00' - assert str(dt.make_dt('17.05.2022 1322')) == '2022-05-17 13:22:00+00:00' - assert str(dt.make_dt('17.05.2022, 13.22')) == '2022-05-17 13:22:00+00:00' - assert str(dt.make_dt('17.05.2022, 1322')) == '2022-05-17 13:22:00+00:00' - assert str(dt.make_dt('17.05.20 22, 13.22')) == '2022-05-17 13:22:00+00:00' +async def test_correct_date_converting(): + assert str(await dt.make_dt('17.05.22')) == '2022-05-17 00:00:00+00:00' + assert str(await dt.make_dt('17.05.20 22')) == '2022-05-17 00:00:00+00:00' + assert str(await dt.make_dt('17.05.2022 1322')) ==\ + '2022-05-17 13:22:00+00:00' + assert str(await dt.make_dt('17.05.2022, 13.22')) ==\ + '2022-05-17 13:22:00+00:00' + assert str(await dt.make_dt('17.05.2022, 1322')) ==\ + '2022-05-17 13:22:00+00:00' + assert str(await dt.make_dt('17.05.20 22, 13.22')) ==\ + '2022-05-17 13:22:00+00:00' -def test_change_dt(): - orig_date = dt.make_dt('17.05.2022, 13.22') +async def test_change_dt(): + orig_date = await dt.make_dt('17.05.2022, 13.22') # All OK - plus_nineteen_years = dt.make_dt('17.05.2041, 13:22') - minus_four_months = dt.make_dt('17.01.2022, 13.22') - plus_two_days = dt.make_dt('19.05.2022, 13:22') - minus_three_hours = dt.make_dt('17.05.2022, 10.22') - plus_thirty_minutes = dt.make_dt('17.05.2022, 13.52') + plus_nineteen_years = await dt.make_dt('17.05.2041, 13:22') + minus_four_months = await dt.make_dt('17.01.2022, 13.22') + plus_two_days = await dt.make_dt('19.05.2022, 13:22') + minus_three_hours = await dt.make_dt('17.05.2022, 10.22') + plus_thirty_minutes = await dt.make_dt('17.05.2022, 13.52') # All OK - assert dt.change_dt( + assert await dt.change_dt( orig_date, 'add', 19, 'years' ) == plus_nineteen_years - assert dt.change_dt( + assert await dt.change_dt( orig_date, 'remove', 4, 'months' ) == minus_four_months - assert dt.change_dt( + assert await dt.change_dt( orig_date, 'add', 2, 'days' ) == plus_two_days - assert dt.change_dt( + assert await dt.change_dt( orig_date, 'remove', 3, 'hours' ) == minus_three_hours - assert dt.change_dt( + assert await dt.change_dt( orig_date, 'add', 30, 'minutes' ) == plus_thirty_minutes # Fails - assert dt.change_dt(orig_date, 'add', 'two', 'days') is None + assert await dt.change_dt(orig_date, 'add', 'two', 'days') is None