sta_connect_example.py: shows example of how to get passing state and failure messages

This commit is contained in:
Jed Reynolds
2020-06-04 15:06:31 -07:00
parent 0b8e460136
commit b7d497b904

View File

@@ -3,17 +3,17 @@
# Example of how to instantiate StaConnect and run the test # Example of how to instantiate StaConnect and run the test
import sys import sys
if sys.version_info[0] != 3: if sys.version_info[0] != 3:
print("This script requires Python 3") print("This script requires Python 3")
exit(1) exit(1)
if 'py-json' not in sys.path: if 'py-json' not in sys.path:
sys.path.append('../py-json') sys.path.append('../py-json')
from LANforge.LFUtils import *
# if you lack __init__.py in this directory you will not find sta_connect module # if you lack __init__.py in this directory you will not find sta_connect module
import sta_connect
from sta_connect import StaConnect from sta_connect import StaConnect
def main(): def main():
staConnect = StaConnect("localhost", 8080) staConnect = StaConnect("localhost", 8080)
staConnect.sta_mode = 0 staConnect.sta_mode = 0
@@ -24,9 +24,15 @@ def main():
staConnect.dut_ssid = "jedway-wpa2-x2048-5-1" staConnect.dut_ssid = "jedway-wpa2-x2048-5-1"
staConnect.dut_passwd = "jedway-wpa2-x2048-5-1" staConnect.dut_passwd = "jedway-wpa2-x2048-5-1"
staConnect.run() staConnect.run()
run_results = staConnect.get_result_list() is_passing = staConnect.passes()
for result in run_results: if is_passing == False:
print("test result: "+result) # run_results = staConnect.get_failed_result_list()
fail_message = staConnect.get_fail_message()
print("Some tests failed:\n" + fail_message)
else:
print("Tests pass")
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -