From 80472a70a49498e294ad40e533ac66f8f59b90f1 Mon Sep 17 00:00:00 2001 From: Jayati Patel Date: Wed, 24 Jul 2024 18:43:18 +0000 Subject: [PATCH 01/11] unti test for dassert_is_valid_timestamp --- helpers/test/test_hdatetime.py | 41 ++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 3754fa8a9c..9b9a2f4ce3 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -773,3 +773,44 @@ def test2(self) -> None: hdateti.dassert_str_is_date(date) actual = str(err.exception) self.check_string(actual) + +# ############################################################################# +# Test_dassert_is_valid_timestamp +# ############################################################################# + +class Test_dassert_is_valid_timestamp(hunitest.TestCase): + + def test1(self) -> None: + """ + Test dassert_timestamp_lt by checking a timestamp with a timezone + """ + timestamp = _PD_TS_UTC + + # This should not raise any exceptions. + hdateti.dassert_is_valid_timestamp(timestamp) + + + def test2(self) -> None: + """ + Test dassert_timestamp_lt by checking a timestamp without a timezone + """ + timestamp = _PD_TS_NAIVE # No timezone info + + with self.assertRaises(AssertionError) as cm: + hdateti.dassert_is_valid_timestamp(timestamp) + act = str(cm.exception) + exp = """ + * Failed assertion * + 'None' is not 'None' + datetime_='2021-01-04 09:30:00' doesn't have timezone info + """ + self.assert_equal(act, exp, fuzzy_match=True) + + def test3(self) -> None: + """ + Test dassert_timestamp_lt by checking a timestamp as None + """ + timestamp = None + + # This should not raise any exceptions. + hdateti.dassert_is_valid_timestamp(timestamp) \ No newline at end of file From a9c0660385c8349222873084b08d248307ff8b95 Mon Sep 17 00:00:00 2001 From: Jayati Patel Date: Wed, 24 Jul 2024 21:50:04 +0000 Subject: [PATCH 02/11] update --- helpers/test/test_hdatetime.py | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 9b9a2f4ce3..162336422e 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -782,20 +782,18 @@ class Test_dassert_is_valid_timestamp(hunitest.TestCase): def test1(self) -> None: """ - Test dassert_timestamp_lt by checking a timestamp with a timezone + Test by checking a timestamp with a timezone. """ - timestamp = _PD_TS_UTC - + timestamp = pd.Timestamp("2021-01-04 09:30:00-05:00", tz="America/New_York") # This should not raise any exceptions. hdateti.dassert_is_valid_timestamp(timestamp) def test2(self) -> None: """ - Test dassert_timestamp_lt by checking a timestamp without a timezone + Test by checking a timestamp without a timezone. """ - timestamp = _PD_TS_NAIVE # No timezone info - + timestamp = pd.Timestamp("2021-01-04 09:30:00") with self.assertRaises(AssertionError) as cm: hdateti.dassert_is_valid_timestamp(timestamp) act = str(cm.exception) @@ -808,9 +806,23 @@ def test2(self) -> None: def test3(self) -> None: """ - Test dassert_timestamp_lt by checking a timestamp as None + Test by checking a timestamp as None. """ timestamp = None + # This should not raise any exceptions. + hdateti.dassert_is_valid_timestamp(timestamp) - # This should not raise any exceptions. - hdateti.dassert_is_valid_timestamp(timestamp) \ No newline at end of file + def test4(self) -> None: + """ + Test by passing a timestamp as a string. + """ + timestamp = "2021-01-04 09:30:00" + with self.assertRaises(AssertionError) as cm: + hdateti.dassert_is_valid_timestamp(timestamp) + act = str(cm.exception) + exp = """ + * Failed assertion * + Instance of '2021-01-04 09:30:00' is '' instead of ' + ' + """ + self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file From d8ace90a51ea317b70efc6464e40c566c03cccc7 Mon Sep 17 00:00:00 2001 From: Jayati Patel Date: Wed, 24 Jul 2024 21:52:11 +0000 Subject: [PATCH 03/11] update --- helpers/test/test_hdatetime.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 162336422e..48c3049ebc 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -822,7 +822,6 @@ def test4(self) -> None: act = str(cm.exception) exp = """ * Failed assertion * - Instance of '2021-01-04 09:30:00' is '' instead of ' - ' + Instance of '2021-01-04 09:30:00' is '' instead of '' """ self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file From a397d3291da5c196734d0bbaf2ca691eddc8523b Mon Sep 17 00:00:00 2001 From: Jayati Patel Date: Wed, 24 Jul 2024 21:54:05 +0000 Subject: [PATCH 04/11] update --- helpers/test/test_hdatetime.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 48c3049ebc..bdb94e3021 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -791,7 +791,7 @@ def test1(self) -> None: def test2(self) -> None: """ - Test by checking a timestamp without a timezone. + Check timestamp without a timezone info, should raise an exception. """ timestamp = pd.Timestamp("2021-01-04 09:30:00") with self.assertRaises(AssertionError) as cm: @@ -814,7 +814,7 @@ def test3(self) -> None: def test4(self) -> None: """ - Test by passing a timestamp as a string. + Test by passing a timestamp as a string, should raise an exception. """ timestamp = "2021-01-04 09:30:00" with self.assertRaises(AssertionError) as cm: From adf3ea6c2f97c3390dd5447e762e82670d6851e0 Mon Sep 17 00:00:00 2001 From: Jayati Patel Date: Thu, 25 Jul 2024 13:30:00 +0000 Subject: [PATCH 05/11] update --- helpers/test/test_hdatetime.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index bdb94e3021..27ea6a614d 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -802,6 +802,7 @@ def test2(self) -> None: 'None' is not 'None' datetime_='2021-01-04 09:30:00' doesn't have timezone info """ + #check. self.assert_equal(act, exp, fuzzy_match=True) def test3(self) -> None: @@ -824,4 +825,5 @@ def test4(self) -> None: * Failed assertion * Instance of '2021-01-04 09:30:00' is '' instead of '' """ + #check. self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file From 7b93633216adcffddfe67ee867486f102b126b42 Mon Sep 17 00:00:00 2001 From: Jayati Patel Date: Sat, 27 Jul 2024 22:35:27 +0000 Subject: [PATCH 06/11] update --- helpers/test/test_hdatetime.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 27ea6a614d..9b822550c0 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -782,16 +782,14 @@ class Test_dassert_is_valid_timestamp(hunitest.TestCase): def test1(self) -> None: """ - Test by checking a timestamp with a timezone. + Test should not raise an exception when timestamp has a timezone. """ timestamp = pd.Timestamp("2021-01-04 09:30:00-05:00", tz="America/New_York") - # This should not raise any exceptions. hdateti.dassert_is_valid_timestamp(timestamp) - def test2(self) -> None: """ - Check timestamp without a timezone info, should raise an exception. + Test should raise an exception when timestamp is without timezone info. """ timestamp = pd.Timestamp("2021-01-04 09:30:00") with self.assertRaises(AssertionError) as cm: @@ -802,20 +800,19 @@ def test2(self) -> None: 'None' is not 'None' datetime_='2021-01-04 09:30:00' doesn't have timezone info """ - #check. + # check. self.assert_equal(act, exp, fuzzy_match=True) def test3(self) -> None: """ - Test by checking a timestamp as None. + Test should not raise an exception when timestamp is none. """ timestamp = None - # This should not raise any exceptions. hdateti.dassert_is_valid_timestamp(timestamp) def test4(self) -> None: """ - Test by passing a timestamp as a string, should raise an exception. + Test should raise an exception when timestamp is of type string. """ timestamp = "2021-01-04 09:30:00" with self.assertRaises(AssertionError) as cm: @@ -825,5 +822,5 @@ def test4(self) -> None: * Failed assertion * Instance of '2021-01-04 09:30:00' is '' instead of '' """ - #check. + # check. self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file From fe015159873de31c6da558db35a317be4e99aad4 Mon Sep 17 00:00:00 2001 From: jayati1397 Date: Tue, 30 Jul 2024 11:58:13 -0400 Subject: [PATCH 07/11] linter update --- helpers/test/test_hdatetime.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 9b822550c0..931b3e2498 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -774,19 +774,22 @@ def test2(self) -> None: actual = str(err.exception) self.check_string(actual) + # ############################################################################# # Test_dassert_is_valid_timestamp # ############################################################################# -class Test_dassert_is_valid_timestamp(hunitest.TestCase): +class Test_dassert_is_valid_timestamp(hunitest.TestCase): def test1(self) -> None: """ Test should not raise an exception when timestamp has a timezone. """ - timestamp = pd.Timestamp("2021-01-04 09:30:00-05:00", tz="America/New_York") + timestamp = pd.Timestamp( + "2021-01-04 09:30:00-05:00", tz="America/New_York" + ) hdateti.dassert_is_valid_timestamp(timestamp) - + def test2(self) -> None: """ Test should raise an exception when timestamp is without timezone info. @@ -823,4 +826,4 @@ def test4(self) -> None: Instance of '2021-01-04 09:30:00' is '' instead of '' """ # check. - self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file + self.assert_equal(act, exp, fuzzy_match=True) From 96dea4b06cb43b95bbab67d8cda024b4f2adcf20 Mon Sep 17 00:00:00 2001 From: jayati1397 Date: Tue, 30 Jul 2024 12:10:36 -0400 Subject: [PATCH 08/11] linter update --- helpers/test/test_hdatetime.py | 1 + 1 file changed, 1 insertion(+) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 931b3e2498..f6fbc6bd8e 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -827,3 +827,4 @@ def test4(self) -> None: """ # check. self.assert_equal(act, exp, fuzzy_match=True) + From 79491b1fc7497b43cefc4e97236c9095c9d64661 Mon Sep 17 00:00:00 2001 From: jayati1397 Date: Tue, 30 Jul 2024 12:11:58 -0400 Subject: [PATCH 09/11] linter update --- helpers/test/test_hdatetime.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index f6fbc6bd8e..4271eedc33 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -826,5 +826,4 @@ def test4(self) -> None: Instance of '2021-01-04 09:30:00' is '' instead of '' """ # check. - self.assert_equal(act, exp, fuzzy_match=True) - + self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file From df406e1675b33ca2e681c60f063e421ac1e82ca6 Mon Sep 17 00:00:00 2001 From: Samarth KaPatel Date: Tue, 30 Jul 2024 20:37:42 -0400 Subject: [PATCH 10/11] Update test_hdatetime.py --- helpers/test/test_hdatetime.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 4271eedc33..00898907ac 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -803,7 +803,7 @@ def test2(self) -> None: 'None' is not 'None' datetime_='2021-01-04 09:30:00' doesn't have timezone info """ - # check. + # Check. self.assert_equal(act, exp, fuzzy_match=True) def test3(self) -> None: @@ -825,5 +825,5 @@ def test4(self) -> None: * Failed assertion * Instance of '2021-01-04 09:30:00' is '' instead of '' """ - # check. - self.assert_equal(act, exp, fuzzy_match=True) \ No newline at end of file + # Check. + self.assert_equal(act, exp, fuzzy_match=True) From 581286f6ab703ce86bc385cfe087e072184a6611 Mon Sep 17 00:00:00 2001 From: Samarth KaPatel Date: Tue, 30 Jul 2024 20:45:01 -0400 Subject: [PATCH 11/11] Update test_hdatetime.py --- helpers/test/test_hdatetime.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/helpers/test/test_hdatetime.py b/helpers/test/test_hdatetime.py index 00898907ac..9afff0508b 100644 --- a/helpers/test/test_hdatetime.py +++ b/helpers/test/test_hdatetime.py @@ -794,7 +794,9 @@ def test2(self) -> None: """ Test should raise an exception when timestamp is without timezone info. """ + # Set inputs. timestamp = pd.Timestamp("2021-01-04 09:30:00") + # Run. with self.assertRaises(AssertionError) as cm: hdateti.dassert_is_valid_timestamp(timestamp) act = str(cm.exception) @@ -817,7 +819,9 @@ def test4(self) -> None: """ Test should raise an exception when timestamp is of type string. """ + # Set input. timestamp = "2021-01-04 09:30:00" + # Run. with self.assertRaises(AssertionError) as cm: hdateti.dassert_is_valid_timestamp(timestamp) act = str(cm.exception)