Test added for get_asset_sensor_readings_time_avg_q_limit_group_hrs
@@ -554,3 +554,27 @@ class TestBrowseAssets:
assert retval[-1]["max"] == max(self.test_data_x_val_list[-2:])
assert retval[-1]["min"] == min(self.test_data_x_val_list[-2:])
assert retval[-1]["time"] == grouped_ts_hrs[-1]
+
+ @pytest.mark.xfail(reason="FOGL-546, FOGL-547")
+ async def test_get_asset_sensor_readings_time_avg_q_limit_group_hrs(self):
+ """
+ Verify that series data is grouped by hours and limits are working
+ http://localhost:8082/foglamp/asset/TESTAPI/x/series?group=hours&limit=1
+ """
+ conn = http.client.HTTPConnection(BASE_URL)
+ conn.request("GET", '/foglamp/asset/{}/{}/series?group=hours&limit={}'.format(test_data_asset_code, sensor_code_1, 1))
+ r = conn.getresponse()
+ assert 200 == r.status
+ r = r.read().decode()
+ conn.close()
+ retval = json.loads(r)
+
+ # Find unique set of times grouped by hours from test data
+ grouped_ts_hrs = self.group_date_time(unit="hour")
+
+ # Verify the values of a group, We know first 19 records of test data were created within the same hour
+ assert 1 == len(retval)
+ assert retval[-1]["average"] == sum(self.test_data_x_val_list[:19]) / len(self.test_data_x_val_list[:19])
+ assert retval[-1]["max"] == max(self.test_data_x_val_list[:19])
+ assert retval[-1]["min"] == min(self.test_data_x_val_list[:19])
+ assert retval[-1]["time"] == grouped_ts_hrs[0]
