@@ -1079,7 +1079,7 @@ def test__get(self):
10791079 "c" : "timeseriesid-c" ,
10801080 }
10811081 source = DrioDataSource (
1082- drio_client , labels , convert_date = True , raise_empty = False
1082+ drio_client , labels , storage = "archive" , convert_date = True , raise_empty = False
10831083 )
10841084
10851085 data_out = source ._get ("<start-time>" , "<end-time>" )
@@ -1120,6 +1120,121 @@ def test__get(self):
11201120 ]
11211121 )
11221122
1123+ def test__get_warm_storage (self ):
1124+ # Mock the drio_client
1125+ drio_client = Mock ()
1126+ drio_client .get_samples_aggregate .return_value = pd .Series (
1127+ data = [1.1 , 1.2 , 1.3 ], index = [1.0 , 2.0 , 3.0 ]
1128+ )
1129+
1130+ # Labels to request
1131+ labels = {
1132+ "a" : "timeseriesid-a" ,
1133+ "b" : "timeseriesid-b" ,
1134+ "c" : "timeseriesid-c" ,
1135+ }
1136+
1137+ # Instantiate DrioDataSource with storage="warm" and constructor kwargs
1138+ source = DrioDataSource (
1139+ drio_client ,
1140+ labels ,
1141+ storage = "warm" ,
1142+ convert_date = True ,
1143+ raise_empty = False ,
1144+ aggregation_period = "1h" ,
1145+ aggregation_function = "min" ,
1146+ )
1147+
1148+ # Call _get (no kwargs allowed per your current design)
1149+ data_out = source ._get ("<start-time>" , "<end-time>" )
1150+
1151+ # Expected output
1152+ data_expect = {
1153+ "a" : pd .Series (data = [1.1 , 1.2 , 1.3 ], index = [1.0 , 2.0 , 3.0 ]),
1154+ "b" : pd .Series (data = [1.1 , 1.2 , 1.3 ], index = [1.0 , 2.0 , 3.0 ]),
1155+ "c" : pd .Series (data = [1.1 , 1.2 , 1.3 ], index = [1.0 , 2.0 , 3.0 ]),
1156+ }
1157+
1158+ # Assert returned data is correct
1159+ assert data_out .keys () == data_expect .keys ()
1160+ for key , series_expect in data_expect .items ():
1161+ pd .testing .assert_series_equal (series_expect , data_out [key ])
1162+
1163+ # Assert get_samples_aggregate called with correct parameters
1164+ drio_client .get_samples_aggregate .assert_has_calls (
1165+ [
1166+ call (
1167+ "timeseriesid-a" ,
1168+ start = "<start-time>" ,
1169+ end = "<end-time>" ,
1170+ aggregation_period = "1h" ,
1171+ aggregation_function = "min" ,
1172+ ),
1173+ call (
1174+ "timeseriesid-b" ,
1175+ start = "<start-time>" ,
1176+ end = "<end-time>" ,
1177+ aggregation_period = "1h" ,
1178+ aggregation_function = "min" ,
1179+ ),
1180+ call (
1181+ "timeseriesid-c" ,
1182+ start = "<start-time>" ,
1183+ end = "<end-time>" ,
1184+ aggregation_period = "1h" ,
1185+ aggregation_function = "min" ,
1186+ ),
1187+ ]
1188+ )
1189+
1190+ def test__get_warm_defaults (self ):
1191+ # Mock the drio_client
1192+ drio_client = Mock ()
1193+ drio_client .get_samples_aggregate .return_value = pd .Series (
1194+ data = [10 , 20 , 30 ], index = [1 , 2 , 3 ]
1195+ )
1196+
1197+ labels = {
1198+ "x" : "ts-x" ,
1199+ "y" : "ts-y" ,
1200+ }
1201+
1202+ # Instantiate DrioDataSource with storage="warm", no overrides
1203+ source = DrioDataSource (
1204+ drio_client , labels , storage = "warm" , convert_date = True , raise_empty = False
1205+ )
1206+
1207+ # Call _get with defaults
1208+ data_out = source ._get ("<start>" , "<end>" )
1209+
1210+ # Expected series
1211+ expected = pd .Series ([10 , 20 , 30 ], index = [1 , 2 , 3 ])
1212+
1213+ # Assert keys and values
1214+ assert data_out .keys () == labels .keys ()
1215+ for key in labels :
1216+ pd .testing .assert_series_equal (data_out [key ], expected )
1217+
1218+ # Assert get_samples_aggregate called with default aggregation values
1219+ drio_client .get_samples_aggregate .assert_has_calls (
1220+ [
1221+ call (
1222+ "ts-x" ,
1223+ start = "<start>" ,
1224+ end = "<end>" ,
1225+ aggregation_period = "tick" ,
1226+ aggregation_function = "mean" ,
1227+ ),
1228+ call (
1229+ "ts-y" ,
1230+ start = "<start>" ,
1231+ end = "<end>" ,
1232+ aggregation_period = "tick" ,
1233+ aggregation_function = "mean" ,
1234+ ),
1235+ ]
1236+ )
1237+
11231238
11241239class Test_NullDataSource :
11251240 def test__init__ (self ):
0 commit comments