|
28 | 28 | nanoseconds_timestamp_conversion, |
29 | 29 | normalize_path, |
30 | 30 | second_timestamp_conversion, |
| 31 | + timestamp_conversion, |
31 | 32 | ) |
32 | 33 |
|
33 | 34 | test_bucket = "python-functions-testing.appspot.com" |
@@ -107,6 +108,59 @@ def test_second_conversion(): |
107 | 108 | assert second_timestamp_conversion(input_timestamp) == expected_datetime |
108 | 109 |
|
109 | 110 |
|
| 111 | +def test_timestamp_conversion_supported_formats(): |
| 112 | + """ |
| 113 | + Testing shared timestamp conversion handles supported RTDB and CloudEvent formats. |
| 114 | + """ |
| 115 | + timestamps = [ |
| 116 | + ( |
| 117 | + "2024-04-10T12:00:00.000Z", |
| 118 | + _dt.datetime(2024, 4, 10, 12, 0, tzinfo=_dt.timezone.utc), |
| 119 | + ), |
| 120 | + ( |
| 121 | + "2024-04-10T12:00:00.123456Z", |
| 122 | + _dt.datetime(2024, 4, 10, 12, 0, 0, 123456, tzinfo=_dt.timezone.utc), |
| 123 | + ), |
| 124 | + ( |
| 125 | + "2024-04-10T12:00:00.123456+05:30", |
| 126 | + _dt.datetime( |
| 127 | + 2024, |
| 128 | + 4, |
| 129 | + 10, |
| 130 | + 12, |
| 131 | + 0, |
| 132 | + 0, |
| 133 | + 123456, |
| 134 | + tzinfo=_dt.timezone(_dt.timedelta(hours=5, minutes=30)), |
| 135 | + ), |
| 136 | + ), |
| 137 | + ( |
| 138 | + "2024-04-10T12:00:00.123456-0700", |
| 139 | + _dt.datetime( |
| 140 | + 2024, |
| 141 | + 4, |
| 142 | + 10, |
| 143 | + 12, |
| 144 | + 0, |
| 145 | + 0, |
| 146 | + 123456, |
| 147 | + tzinfo=_dt.timezone(-_dt.timedelta(hours=7)), |
| 148 | + ), |
| 149 | + ), |
| 150 | + ( |
| 151 | + "2023-01-01T12:34:56.123456789Z", |
| 152 | + _dt.datetime(2023, 1, 1, 12, 34, 56, 123456, tzinfo=_dt.timezone.utc), |
| 153 | + ), |
| 154 | + ( |
| 155 | + "2025-10-30T21:15:51Z", |
| 156 | + _dt.datetime(2025, 10, 30, 21, 15, 51, tzinfo=_dt.timezone.utc), |
| 157 | + ), |
| 158 | + ] |
| 159 | + |
| 160 | + for input_timestamp, expected_datetime in timestamps: |
| 161 | + assert timestamp_conversion(input_timestamp) == expected_datetime |
| 162 | + |
| 163 | + |
110 | 164 | def test_is_nanoseconds_timestamp(): |
111 | 165 | """ |
112 | 166 | Testing is_nanoseconds_timestamp works as intended |
|
0 commit comments