-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_submit_firmware.py
68 lines (56 loc) · 2.07 KB
/
test_submit_firmware.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import time
import threading
from config import config
from message_monitor import MessageMonitor
from util import Util
from firmware import Firmware
from fabmo_info import Fabmo_Info
mm = MessageMonitor()
mm.clear_all_state()
util = Util()
firmware = Firmware()
fabmo_info = Fabmo_Info()
def submit_firmware(results):
print("testing submit_firmware")
firmware_to_submit = "g2core_101_57_44.bin"
# Submit the firmware
firmware.submit(firmware_to_submit)
# Sometimes this can take awhile
time.sleep(200)
get_firmware_version = fabmo_info.info()
check = util.test_check(get_firmware_version['data']['info']['firmware']['version'] == '101.57.44', "Firmware version matches what was submitted", "Firmware version is incorrect")
if check is False:
return
print("Repeat the test with the most recent firmware.")
firmware_to_submit = "g2core_101_57_45.bin"
# Submit the firmware
firmware.submit(firmware_to_submit)
# Sometimes this can take awhile
time.sleep(200)
get_firmware_version = fabmo_info.info()
check = util.test_check(get_firmware_version['data']['info']['firmware']['version'] == '101.57.45-dirty', "Firmware version matches what was submitted", "Firmware version is incorrect")
if check is False:
return
# Did test pass?
results["code"] = True
return
def thread_for_mm(args):
mm.run()
# test function
def test_submit_firmware():
# setting things up so test can run
messageMonitorThread = threading.Thread(target=thread_for_mm, args=(1,), daemon=True)
results = {"code":False}
testThread = threading.Thread(target=submit_firmware, args=(results,))
# test sequence
messageMonitorThread.start()
time.sleep(1) # time for the MessageMonitor to fabmo_info up and running
testThread.start()
testThread.join() #waiting for the test to return
#reporting results
# debug (i'm sure there is pytest way to turn this on and off)
print(results)
assert results["code"] is True
if __name__ == "__main__":
print(config.API_URL)
test_submit_firmware()