From: Peter Mikus Date: Thu, 15 May 2025 05:50:00 +0000 (+0200) Subject: fix(model): Remove test logic from model X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F62%2F42962%2F1;p=csit.git fix(model): Remove test logic from model Signed-off-by: Peter Mikus Change-Id: Ife334a4611ec2ca683764746fab280dc403d1de8 --- diff --git a/resources/libraries/python/model/ExportJson.py b/resources/libraries/python/model/ExportJson.py index a83bf5ec88..1eb0d58cfd 100644 --- a/resources/libraries/python/model/ExportJson.py +++ b/resources/libraries/python/model/ExportJson.py @@ -367,10 +367,6 @@ class ExportJson(): result_type = result_node["type"] if result_type == "unknown": # Device or something else not supported. - # Also could be MRR with all trials negative, write as a failure. - self.data["passed"] = False - self.data["message"] = "No result exported." - # TODO: Raise real Robot error after writing this JSON. return # Compute avg and stdev for mrr (rate and bandwidth). diff --git a/resources/libraries/python/model/ExportResult.py b/resources/libraries/python/model/ExportResult.py index b751e593f9..3cbb435353 100644 --- a/resources/libraries/python/model/ExportResult.py +++ b/resources/libraries/python/model/ExportResult.py @@ -100,7 +100,7 @@ def append_mrr_value(mrr_value, mrr_unit, bandwidth_value=None, bandwidth_unit="bps"): """Store mrr value to proper place so it is dumped into json. - Raises an error if the arguments would lead to invalid json. + The value is appended only when unit is not empty. :param mrr_value: Forwarding rate from MRR trial. :param mrr_unit: Unit of measurement for the rate. @@ -109,22 +109,19 @@ def append_mrr_value(mrr_value, mrr_unit, bandwidth_value=None, :type mrr_unit: str :type bandwidth_value: Optional[float] :type bandwidth_unit: Optional[str] - :raises RuntimeError: If mrr_unit is missing or any value is negative. """ if not mrr_unit: - raise RuntimeError(f"Cannot be falsey: {mrr_unit=}") + return data = get_export_data() data["result"]["type"] = "mrr" + for node_val, node_unit, node_name in ((mrr_value, mrr_unit, "rate"), (bandwidth_value, bandwidth_unit, "bandwidth")): if node_val is not None: - node_val = float(node_val) - if node_val < 0: - raise RuntimeError(f"Cannot be negative: {node_val=}") node = descend(descend(data["result"], "receive_rate"), node_name) node["unit"] = str(node_unit) values_list = descend(node, "values", list) - values_list.append(node_val) + values_list.append(float(node_val)) def export_search_bound(text, value, unit, bandwidth=None):