File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -968,6 +968,26 @@ def test_custom_state(self):
968968 assert self .b .get_status (tid ) == states .SUCCESS
969969 assert self .b .get_result (tid ) == 42
970970
971+ def test_date_started_is_timezone_aware (self ):
972+ """Test that date_started is timezone-aware when task is started"""
973+ tid = uuid ()
974+
975+ # Create a task in PENDING state
976+ self .b .store_result (tid , None , states .PENDING )
977+ tr = TaskResult .objects .get (task_id = tid )
978+ assert tr .date_started is None
979+
980+ # Mark as started
981+ self .b .mark_as_started (tid )
982+
983+ # Verify date_started is set and timezone-aware
984+ tr = TaskResult .objects .get (task_id = tid )
985+ assert tr .date_started is not None
986+ assert isinstance (tr .date_started , datetime .datetime )
987+ # Check if datetime is timezone-aware (has tzinfo set)
988+ assert tr .date_started .tzinfo is not None
989+ assert tr .date_started .tzinfo .utcoffset (tr .date_started ) is not None
990+
971991
972992class DjangoCeleryResultRouter :
973993 route_app_labels = {"django_celery_results" }
You can’t perform that action at this time.
0 commit comments