Test Added for get_asset_sensor_readings_stats
@@ -68,7 +68,7 @@ async def delete_master_data():
@pytest.allure.feature("api")
-@pytest.allure.story("browser-assets")
+@pytest.allure.story("assets-browser")
class TestBrowseAssets:
test_data_uid_list = []
test_data_x_val_list = []
@@ -330,10 +330,23 @@ class TestBrowseAssets:
assert retval[0][sensor_code_1] == self.test_data_x_val_list[-1]
assert retval[0]['timestamp'] == self.test_data_ts_list[-1]
+ @pytest.mark.xfail(reason="FOGL-546, FOGL-547")
async def test_get_asset_sensor_readings_stats(self):
- # Assert that if more than 20 readings, only 20 are returned as the default limit
- # http://localhost:8082/foglamp/asset/TESTAPI/x/summary
- pass
+ """
+ Verify that if more than 20 readings for an assets sensor value, summary of only 20 readings are returned as the default limit
+ http://localhost:8082/foglamp/asset/TESTAPI/x/summary
+ """
+ conn = http.client.HTTPConnection(BASE_URL)
+ conn.request("GET", '/foglamp/asset/{}/{}/summary'.format(test_data_asset_code, sensor_code_1))
+ r = conn.getresponse()
+ assert 200 == r.status
+ r = r.read().decode()
+ conn.close()
+ retval = json.loads(r)
+ assert 1 == len(retval)
+ assert retval[sensor_code_1]['min'] == min(self.test_data_x_val_list[1:-1])
+ assert retval[sensor_code_1]['average'] == sum(self.test_data_x_val_list[1:-1])/len(self.test_data_x_val_list[1:-1])
+ assert retval[sensor_code_1]['max'] == max(self.test_data_x_val_list[1:-1])
async def test_get_asset_sensor_readings_stats_q_limit(self):
pass
