-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_run_nextJob.py
64 lines (51 loc) · 1.86 KB
/
test_run_nextJob.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
import time
import threading
from config import config
from message_monitor import MessageMonitor
from job import Job
from util import Util
mm = MessageMonitor()
mm.clear_all_state()
job = Job()
util = Util()
# Runs the job that is currently in the job manager queue
def run_next_job(results):
filename = "sample_shopbot_logo.sbp"
name = "testing dev check one"
description = "test_description"
job.submit(filename, name, description)
print("Test run next job currently in queue")
job.run_next_job_in_queue()
print("waiting for running")
check = util.test_check(mm.wait_for_state("running", 10), "now running", "timed out while waiting for running")
if check is False:
return
print("wait for message at the end of the file, indicating completion")
check = util.test_check(mm.wait_for_message("DONE with ShopBot Logo ... any key to continue", 600), "DONE with ShopBot Logo", "timed out while waiting for ShopBot Logo to complete")
if check is False:
return
job.resume()
print("waiting for idle")
check = util.test_check(mm.wait_for_state("idle", 10), "now idle", "timed out while waiting for idle")
if check is False:
return
results["code"] = True
return
def thread_for_mm(args):
mm.run()
# test function
def test_run_next_job():
# 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=run_next_job, args=(results,))
# test sequence
messageMonitorThread.start()
time.sleep(1) # time for the MessageMonitor to get up and running
testThread.start()
testThread.join() #waiting for the test to return
#reporting results
assert results["code"] is True
if __name__ == "__main__":
print(config.API_URL)
test_run_next_job()