1919TEST_TSID_COPY = f"{ TEST_LOCATION_ID } .Stage.Inst.15Minutes.0.Raw-Copy"
2020TEST_TSID_DELETE = f"{ TEST_LOCATION_ID } .Stage.Inst.15Minutes.0.Raw-Delete"
2121TEST_TSID_CHUNK_NULLS = f"{ TEST_LOCATION_ID } .Stage.Inst.15Minutes.0.Raw-Multi-Nulls"
22+ TEST_TSID_COPY_NULLS = f"{ TEST_LOCATION_ID } .Stage.Inst.15Minutes.0.Raw-Copy-Nulls"
2223TS_ID_REV_TEST = TEST_TSID_MULTI .replace ("Raw-Multi" , "Raw-Rev-Test" )
2324# Generate 15-minute interval timestamps
2425START_DATE_CHUNK_MULTI = datetime (2025 , 7 , 31 , 0 , 0 , tzinfo = timezone .utc )
3334 TEST_TSID_CHUNK_MULTI ,
3435 TEST_TSID_COPY ,
3536 TEST_TSID_CHUNK_NULLS ,
37+ TEST_TSID_COPY_NULLS ,
3638]
3739
3840
5052 "quality-code" : [0 ] * len (DT_CHUNK_MULTI ),
5153 }
5254)
55+ # Create a copy of the original DataFrame and introduce null values
56+ DF_WITH_NULLS = DF_CHUNK_MULTI .copy ()
57+ # Set the 100 and 200 index value to null
58+ DF_WITH_NULLS .loc [100 , "value" ] = None
59+ DF_WITH_NULLS .loc [200 , "value" ] = None
60+
5361
5462DF_MULTI_TIMESERIES1 = pd .DataFrame (
5563 {
@@ -283,14 +291,8 @@ def test_store_timesereis_chunk_to_with_null_values():
283291 office = TEST_OFFICE
284292 units = "m"
285293
286- # Create a copy of the original DataFrame and introduce null values
287- df_with_nulls = DF_CHUNK_MULTI .copy ()
288- # Set the 100 and 200 index value to null
289- df_with_nulls .loc [100 , "value" ] = None
290- df_with_nulls .loc [200 , "value" ] = None
291-
292294 # Convert DataFrame to JSON format
293- ts_json = ts .timeseries_df_to_json (df_with_nulls , ts_id , units , office )
295+ ts_json = ts .timeseries_df_to_json (DF_WITH_NULLS , ts_id , units , office )
294296
295297 ts .store_timeseries (ts_json , multithread = True )
296298
@@ -304,8 +306,35 @@ def test_store_timesereis_chunk_to_with_null_values():
304306 df_nulls = data_nulls .df
305307 # make sure the dataframe matches stored dataframe with null values
306308 pdt .assert_frame_equal (
307- df_nulls , df_with_nulls
308- ), f"Data frames do not match: original with nulls = { df_with_nulls .describe ()} , stored = { df_nulls .describe ()} "
309+ df_nulls , DF_WITH_NULLS
310+ ), f"Data frames do not match: original with nulls = { DF_WITH_NULLS .describe ()} , stored = { df_nulls .describe ()} "
311+
312+
313+ def test_copy_timeseries_chunk_json_with_nulls ():
314+ data_json = ts .get_timeseries (
315+ ts_id = TEST_TSID_CHUNK_NULLS ,
316+ office_id = TEST_OFFICE ,
317+ begin = START_DATE_CHUNK_MULTI ,
318+ end = END_DATE_CHUNK_MULTI ,
319+ max_days_per_chunk = 14 ,
320+ unit = "SI" ,
321+ ).json
322+ data_json ["name" ] = TEST_TSID_COPY_NULLS
323+ ts .store_timeseries (data_json )
324+
325+ data_multithread = ts .get_timeseries (
326+ ts_id = TEST_TSID_COPY_NULLS ,
327+ office_id = TEST_OFFICE ,
328+ begin = START_DATE_CHUNK_MULTI ,
329+ end = END_DATE_CHUNK_MULTI ,
330+ max_days_per_chunk = 14 ,
331+ unit = "SI" ,
332+ )
333+ df = data_multithread .df
334+ # make sure the dataframe matches stored dataframe with null values
335+ pdt .assert_frame_equal (
336+ df , DF_WITH_NULLS
337+ ), f"Data frames do not match: original with nulls = { DF_WITH_NULLS .describe ()} , stored = { df .describe ()} "
309338
310339
311340def test_copy_timeseries_chunk_json ():
0 commit comments