test result summary at end
This commit is contained in:
1 parent
50f9630ff1
commit
826538e667
1 file changed
+31
-1
+31
-1
@@ -279,7 +279,12 @@ def test(test_count = 0) -> None:
|
|||||||
for sensor in sensors:
|
for sensor in sensors:
|
||||||
temp_f = (sensor['temp'] * 1.80) + 32.0
|
temp_f = (sensor['temp'] * 1.80) + 32.0
|
||||||
print(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}")
|
print(f" {sensor['name']} - Temp: {round(temp_f,1)} | Humidity: {sensor['humidity']}")
|
||||||
|
result = {
|
||||||
|
"found_macs": found_macs,
|
||||||
|
"sensor_results": sensors
|
||||||
|
}
|
||||||
test_result = True
|
test_result = True
|
||||||
|
return result
|
||||||
else:
|
else:
|
||||||
print(f" Test run incomplete/failed, re-running, loop {test_loop_count}. Updating test list")
|
print(f" Test run incomplete/failed, re-running, loop {test_loop_count}. Updating test list")
|
||||||
for sensor in sensors:
|
for sensor in sensors:
|
||||||
@@ -311,13 +316,38 @@ if __name__ == "__main__":
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
test_count = 0
|
test_count = 0
|
||||||
|
test_results = []
|
||||||
print(f"Starting BLE Test for {count} iterations")
|
print(f"Starting BLE Test for {count} iterations")
|
||||||
while test_count < count:
|
while test_count < count:
|
||||||
test_count = test_count + 1
|
test_count = test_count + 1
|
||||||
|
this_test_result = []
|
||||||
print(f"Starting test run {test_count} of {count}")
|
print(f"Starting test run {test_count} of {count}")
|
||||||
try:
|
try:
|
||||||
test(test_count)
|
test_label = f"Test {test_count} result"
|
||||||
|
this_test_result = {
|
||||||
|
"test_label": test_label,
|
||||||
|
"test_result": test(test_count)
|
||||||
|
}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"Test failed brah - {e}")
|
print(f"Test failed brah - {e}")
|
||||||
if "org.freedesktop.DBus.Error.AccessDenied" in e:
|
if "org.freedesktop.DBus.Error.AccessDenied" in e:
|
||||||
reset_adapter()
|
reset_adapter()
|
||||||
|
test_results.append(this_test_result)
|
||||||
|
|
||||||
|
print("Test run completed")
|
||||||
|
for test_result in test_results:
|
||||||
|
print(f"Test {test_result['test_label']}:")
|
||||||
|
parts: List[str] = []
|
||||||
|
for reading in test_result['test_result']:
|
||||||
|
mac = reading.get("name", "")
|
||||||
|
temp = reading.get("temp", 0)
|
||||||
|
# Grab the last two octets of the MAC address
|
||||||
|
octets = mac.split(":")[-2:]
|
||||||
|
short_mac = ":".join(octets)
|
||||||
|
parts.append(f"{short_mac} - {temp:.1f}")
|
||||||
|
result_summary = " | ".join(parts)
|
||||||
|
print(result_summary)
|
||||||
|
|
||||||
|
# Insert before the main guard
|
||||||
|
|
||||||
|
|
||||||
Reference in new issue
Block a user