-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_get_current_user.py
47 lines (36 loc) · 1.14 KB
/
test_get_current_user.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
import time
import threading
from config import config
from message_monitor import MessageMonitor
from user import User
from util import Util
mm = MessageMonitor()
mm.clear_all_state()
user = User()
util = Util()
def get_current_user(results):
check = util.test_check(user.get_current_user() is not None, "A user was retrieved", "Unable to get current user")
if check is False:
return
# Did tests pass?
results["code"] = True
return
def thread_for_mm(args):
mm.run()
# test function
def test_get_current_user():
# 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=get_current_user, 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)
print("Testing get_current_user")
test_get_current_user()