-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsocket_tests.py
80 lines (70 loc) · 3.1 KB
/
socket_tests.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
69
70
71
72
73
74
75
76
77
78
79
80
import serv, unittest
import random
import json
from schema import *
import time
class SocketioTestCases(unittest.TestCase):
db.app = serv.app
# def test_add_message(self):
# client = serv.socket.test_client(serv.app)
# client.emit('new message', {'floor':1,'from':2,'message':'this is a test message from socket_tests.'})
# r = client.get_received()
# # response_message = r
# # print(r)
# self.assertIsNotNone(r)
# def test_create_floor(self):
# client = serv.socket.test_client(serv.app)
# i = random.randint(1,2222)
# fl_name = "floor"+str(i)
# client.emit('create floor',{'floor_name':fl_name, 'member_id':1,'is_public':True,'floor_genre':'Pop'})
# r = client.get_received()
# print("************************create_floor**************************")
# # song = r[0]['args'][0]['floor']['songlist']
# # print(song)
# self.assertIsNotNone(r)
# def test_join_floor(self):
# client = serv.socket.test_client(serv.app)
# # client2 = serv.socket.test_client(serv.app)
# client.emit('join floor',{'floor_id':1, 'member_id':1})
# # r = client.get_received()
# # client2.emit('join floor',{'floor_id':1, 'member_id':2})
# print("**************************test_join_floor***********")
# # print(r)
# # song = r[0]['args'][0]['floor']['songlist'][0]['stream_url']
# print("*******************songlist*******************")
# secR = client.get_received()
# print(json.dumps(secR,indent=4))
# # print(song)
# self.assertIsNone(None)
# def test_leave_floor(self):
# db.app = serv.app
# client = serv.socket.test_client(serv.app)
# client2 = serv.socket.test_client(serv.app)
# ran = random.randint(1,2333)
# print("**************************test_join_floor***********")
# new_mem = registerMember("fname","lname",("email" + str(ran)+"@.com"),"img")
# client.emit('join floor',{'floor_id':1, 'member_id':new_mem.member_id})
# r = client.get_received()
# print("r:",json.dumps(r,indent=4))
# time.sleep(10)
# # song = r[0]['args'][0]['floor']['songlist'][0]['stream_url']
# print("***************leave floor*****************")
# client.emit('leave floor',{'floor_id':1,'member_id':new_mem.member_id})
# rep2 = client.get_received()
# print(json.dumps(rep2,indent=4))
# # print(song)
# self.assertIsNone(None)
def test_update_prof(self):
db.app = serv.app
client = serv.socket.test_client(serv.app)
client.emit('join floor',{'floor_id':1, 'member_id':1})
r = client.get_received()
print("r:",json.dumps(r,indent=4))
time.sleep(10)
client.emit("update profile", {"member_id":1, "username":'DISboi1232',"f_name":'johnny boi', 'l_name': "HOTBOIIII"})
# print(song)
r2 = client.get_received()
print(r[0])
self.assertIsNone(None)
if __name__ == '__main__':
unittest.main()