@@ -178,61 +178,40 @@ def test_creates_api_time_series_from_data(
178178 )
179179
180180 @pytest .mark .django_db
181- def test_reingests_with_updated_embargo_and_later_refresh_date (
181+ def test_updates_api_timeseries_embargo_date (
182182 self ,
183- example_headline_data : type_hints .INCOMING_DATA_TYPE ,
184183 example_time_series_data : type_hints .INCOMING_DATA_TYPE ,
185184 ):
186185 """
187- Given headline and time series data ingested once
186+ Given time series data ingested once
188187 When the same data is ingested again with a later refresh date
189188 and an updated embargo timestamp
190- Then the latest records for CoreHeadline, CoreTimeSeries, and APITimeSeries
189+ Then the latest records for CoreTimeSeries and APITimeSeries
191190 reflect the updated embargo timestamps
192191 """
193192
194193 # Before ingestion
195- assert CoreHeadline .objects .all ().count () == 0
196194 assert CoreTimeSeries .objects .all ().count () == 0
197195 assert APITimeSeries .objects .all ().count () == 0
198196
199197 # Given
200- initial_headline_data = copy .deepcopy (example_headline_data )
201198 initial_timeseries_data = copy .deepcopy (example_time_series_data )
202- updated_headline_data = copy .deepcopy (initial_headline_data )
203199 updated_timeseries_data = copy .deepcopy (initial_timeseries_data )
204200
205201 # When
206- data_ingester (data = initial_headline_data )
207202 data_ingester (data = initial_timeseries_data )
208203
209204 # Reingest with updated embargo and later refresh date
210- updated_headline_refresh_date = "2023-11-10"
211205 updated_timeseries_refresh_date = "2023-11-21"
212- updated_headline_embargo = "2023-11-18 08:00:00"
213206 updated_timeseries_embargo = "2023-11-19 09:15:00"
214207
215- updated_headline_data ["refresh_date" ] = updated_headline_refresh_date
216- for record in updated_headline_data ["data" ]:
217- record ["embargo" ] = updated_headline_embargo
218-
219208 updated_timeseries_data ["refresh_date" ] = updated_timeseries_refresh_date
220209 for record in updated_timeseries_data ["time_series" ]:
221210 record ["embargo" ] = updated_timeseries_embargo
222211
223- data_ingester (data = updated_headline_data )
224212 data_ingester (data = updated_timeseries_data )
225213
226214 # Then
227- updated_headlines = CoreHeadline .objects .filter (
228- refresh_date__date = updated_headline_refresh_date
229- )
230- assert len (updated_headline_data ["data" ]) == 2
231- for record in updated_headlines :
232- assert (
233- record .embargo .strftime ("%Y-%m-%d %H:%M:%S" ) == updated_headline_embargo
234- )
235-
236215 updated_core_timeseries = CoreTimeSeries .objects .filter (
237216 refresh_date__date = updated_timeseries_refresh_date
238217 )
@@ -254,3 +233,46 @@ def test_reingests_with_updated_embargo_and_later_refresh_date(
254233 record .embargo .strftime ("%Y-%m-%d %H:%M:%S" )
255234 == updated_timeseries_embargo
256235 )
236+
237+ @pytest .mark .django_db
238+ def test_updates_api_coreheadline_embargo_date (
239+ self ,
240+ example_headline_data : type_hints .INCOMING_DATA_TYPE ,
241+ ):
242+ """
243+ Given headline data ingested once
244+ When the same data is ingested again with a later refresh date
245+ and an updated embargo timestamp
246+ Then the latest record for CoreHeadline
247+ reflect the updated embargo timestamps
248+ """
249+
250+ # Before ingestion
251+ assert CoreHeadline .objects .all ().count () == 0
252+
253+ # Given
254+ initial_headline_data = copy .deepcopy (example_headline_data )
255+ updated_headline_data = copy .deepcopy (initial_headline_data )
256+
257+ # When
258+ data_ingester (data = initial_headline_data )
259+
260+ # Reingest with updated embargo and later refresh date
261+ updated_headline_refresh_date = "2023-11-21"
262+ updated_headline_embargo = "2023-11-18 08:00:00"
263+
264+ updated_headline_data ["refresh_date" ] = updated_headline_refresh_date
265+ for record in updated_headline_data ["data" ]:
266+ record ["embargo" ] = updated_headline_embargo
267+
268+ data_ingester (data = updated_headline_data )
269+
270+ # Then
271+ updated_headlines = CoreHeadline .objects .filter (
272+ refresh_date__date = updated_headline_refresh_date
273+ )
274+ assert len (updated_headline_data ["data" ]) == 2
275+ for record in updated_headlines :
276+ assert (
277+ record .embargo .strftime ("%Y-%m-%d %H:%M:%S" ) == updated_headline_embargo
278+ )
0 commit comments