@@ -84,6 +84,54 @@ def test_delete_dpi_from_datajobs_without_dpi_created_time(self, mock_fetch_dpis
84
84
self .cleanup .delete_dpi_from_datajobs (job )
85
85
self .assertEqual (10 , self .report .num_aspects_removed )
86
86
87
+ @patch (
88
+ "datahub.ingestion.source.gc.dataprocess_cleanup.DataProcessCleanup.fetch_dpis"
89
+ )
90
+ def test_delete_dpi_from_datajobs_without_dpi_null_created_time (
91
+ self , mock_fetch_dpis
92
+ ):
93
+ job = DataJobEntity (
94
+ urn = "urn:li:dataJob:1" ,
95
+ flow_urn = "urn:li:dataFlow:1" ,
96
+ lastIngested = int (datetime .now (timezone .utc ).timestamp ()),
97
+ jobId = "job1" ,
98
+ dataPlatformInstance = "urn:li:dataPlatformInstance:1" ,
99
+ total_runs = 10 ,
100
+ )
101
+ mock_fetch_dpis .return_value = [
102
+ {"urn" : f"urn:li:dataprocessInstance:{ i } " } for i in range (10 )
103
+ ] + [
104
+ {
105
+ "urn" : "urn:li:dataprocessInstance:11" ,
106
+ "created" : {"time" : None },
107
+ }
108
+ ]
109
+ self .cleanup .delete_dpi_from_datajobs (job )
110
+ self .assertEqual (11 , self .report .num_aspects_removed )
111
+
112
+ @patch (
113
+ "datahub.ingestion.source.gc.dataprocess_cleanup.DataProcessCleanup.fetch_dpis"
114
+ )
115
+ def test_delete_dpi_from_datajobs_without_dpi_without_time (self , mock_fetch_dpis ):
116
+ job = DataJobEntity (
117
+ urn = "urn:li:dataJob:1" ,
118
+ flow_urn = "urn:li:dataFlow:1" ,
119
+ lastIngested = int (datetime .now (timezone .utc ).timestamp ()),
120
+ jobId = "job1" ,
121
+ dataPlatformInstance = "urn:li:dataPlatformInstance:1" ,
122
+ total_runs = 10 ,
123
+ )
124
+ mock_fetch_dpis .return_value = [
125
+ {"urn" : f"urn:li:dataprocessInstance:{ i } " } for i in range (10 )
126
+ ] + [
127
+ {
128
+ "urn" : "urn:li:dataprocessInstance:11" ,
129
+ "created" : None ,
130
+ }
131
+ ]
132
+ self .cleanup .delete_dpi_from_datajobs (job )
133
+ self .assertEqual (11 , self .report .num_aspects_removed )
134
+
87
135
def test_fetch_dpis (self ):
88
136
assert self .cleanup .ctx .graph
89
137
self .cleanup .ctx .graph = MagicMock ()
0 commit comments