forked from TheretVM/Werewolf_Bot
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_main.py
180 lines (161 loc) · 7.08 KB
/
test_main.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
# This file runs CI on Travis
# It will be better soon
from config import max_channels_per_category, game_log
from management.position import positionof
from main_classes import Mailbox
import roles_n_rules.switch as switch
import interpretation.check as check
import management.db as db
import management.boxes as box
import reset
import hardcore_reset
# Sanity checks
def test_universe_is_working_properly():
assert 1 == 1 #If this fails, something is seriously wrong
assert True != False # Making sure
assert 1 == 1 # If this fails, something is seriously wrong
assert str(1) == "1" #Make sure python 6 hasn't released and changed all the names like minecraft did in 1.13 like seriously what was wrong with the old system there was nothing wrong with it why do I have to learn an entirely new system that I don't aaaaaaaaaaaa
# Check positionof() function
def test_positionof():
assert positionof("frozen") == 13
assert positionof("fakerole") == 6
assert positionof("votes") == 8
assert positionof("sleepingover") == 18
assert positionof("bitten") == 16
assert positionof("id") == 0
def test_kill_queue():
reset.reset(True)
db.add_kill(12738912739821,"Barber")
db.add_kill(12347892374923,"White Werewolf","7289347983274")
assert db.get_kill() == [1,u'12738912739821',u'Barber',u'']
assert db.get_kill() == [2,u'12347892374923',u'White Werewolf',u'7289347983274']
assert db.get_kill() == None
reset.reset(True)
return True
# Check the database
def test_database():
reset.reset(True)
assert db.count_categories() == 0
assert db.get_category() == None
assert db.get_columns() == []
assert db.poll_list() == []
db.signup(1,'Randium003',u':smirk:')
assert db.get_user(1) == (1, u'Randium003', u':smirk:', 0, game_log, 'Spectator', 'Spectator', 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, -1, 0, '', 0, 0, 0, 0)
assert db.db_get(1,'channel') == game_log
assert db.isParticipant(1) == False
assert db.isParticipant(1,True) == True
assert db.isParticipant(2) == False
assert db.isParticipant(2,True) == False
db.db_set(1,'frozen',1)
assert db.poll_list() == [(1,u':smirk:',1,0)]
db.add_category('24')
assert db.count_categories() == 1
assert db.get_category() == 24
assert db.get_columns() == [(1,)]
assert db.channel_get('1234555') == None
db.add_channel('1234555',1)
assert db.get_category() == 24
db.add_channel('12211',1)
assert db.get_category() == 24
assert db.channel_get('1234555') == (u'1234555',u'1',u'0')
assert db.channel_change_all(1,0,1) == [1234555,12211]
assert db.channel_get('1234555') == (u'1234555',u'1',u'1')
assert db.channel_get('12211') == (u'12211',u'1',u'1')
db.set_user_in_channel('1234555',1,2)
assert db.channel_get('1234555') == (u'1234555',u'1',u'2')
assert db.channel_get('1234555',1) == '2'
assert db.channel_change_all(1,2,3) == [1234555]
db.signup(420,"BenTechy66",":poop:")
assert db.channel_get('12211') == (u'12211',u'1',u'1',u'0')
for i in range(max_channels_per_category - 2):
assert db.get_category() == 24
db.add_channel(10*i,608435446804+7864467*i)
assert db.count_categories() == 1
assert db.get_category() == None
reset.reset(True)
# Make sure the check module is working as intended
def test_check():
class message:
content = "Deze tekst is Nederlands, maar bevat 4 cijfers; 1999 8 en 1 ! Jazeker, dat zijn er vier. Zoiets zou een Hooker zoals jij nooit opmerken."
x = message()
assert check.numbers(x) == [4,1999,8,1]
assert check.numbers(x,3) == [4,1999,8]
assert check.numbers(x,5) == False
assert check.emojis(x) == False
assert check.roles(x) == ['Hooker']
assert check.roles(x,1) == ['Hooker']
assert check.roles(x,2) == False
def test_control_freezers():
reset.reset(True)
assert db.add_freezer(1,3,'Pyromancer') == None
assert db.add_freezer(1,3,'The Thing') == 'Pyromancer'
assert db.add_freezer(1,4,'Assassin') == None
assert db.add_freezer(1,3,'Booh') == 'The Thing'
assert db.add_freezer(1,5,'Hooker') == None
assert db.add_freezer(2,9,'Fortune Teller') == None
assert db.get_freezers(1) == [(3, 'Booh'), (4, 'Assassin'), (5, 'Hooker')]
assert db.delete_freezer(1,7) == False
assert db.delete_freezer(1,4) == True
assert db.get_freezers(1) == [(3, 'Booh'), (5, 'Hooker')]
reset.reset(True)
def test_mexican():
reset.reset(True)
db.add_standoff(2,'Huntress',1)
db.add_standoff(3,'Cupid',1)
db.add_standoff(1,'Cupid',3)
assert db.get_standoff(3) == [[3,'1','Cupid','3']]
assert db.get_standoff(1) == [[1,'2','Huntress','1'],[2,'3','Cupid','1']]
db.delete_standoff(2)
assert db.get_standoff(1) == [[1,'2','Huntress','1']]
db.add_standoff(4,'Hooker',3)
assert db.get_standoff(3) == [[3,'1','Cupid','3'],[4,'4','Hooker','3']]
db.delete_hookers()
assert db.get_standoff(3) == [[3,'1','Cupid','3']]
reset.reset(True)
def test_secrets():
reset.reset(True)
assert db.get_secret_channels('Assassin') == []
db.add_secret_channel(1,'Assassin')
db.add_secret_channel(2,'Assassin')
assert db.get_secret_channels('Assassin') == [1,2]
db.add_secret_channel(3,'Werewolf')
assert db.get_secret_channels('Assassin') == [1,2]
db.add_secret_channel(4,'Assassin')
assert db.get_secret_channels('Assassin') == [1,2,4]
reset.reset(True)
def test_amulets():
reset.reset(True)
db.signup(1,'Alice',':hugging:')
db.signup(2,'Bob',':smirk:')
db.signup(3,'Charlie',':orange_book:')
db.add_category(100,True)
db.add_channel(10,1,True)
db.add_channel(11,2,True)
db.add_channel(12,1,True)
db.add_secret_channel(10,'Amulet_Holder')
db.add_secret_channel(11,'Amulet_Holder')
db.set_user_in_channel(10,1,1)
db.set_user_in_channel(10,2,3)
db.set_user_in_channel(11,2,1)
db.set_user_in_channel(12,1,1)
db.set_user_in_channel(12,3,1)
assert db.get_secret_channels('Amulet_Holder') == [10,11]
assert db.amulets(1) == [10]
assert db.amulets(2) == [10,11]
assert db.amulets(3) == []
assert db.has_amulet(1) == True
assert db.has_amulet(3) == False
reset.reset(True)
def test_box_system():
hardcore_reset.hard_reset(True)
assert box.add_token("BenTechyFTW",123456) == ('BenTechyFTW',123456,0,None,None,None,None,None,None)
assert box.add_token("BenTechyFTW",123456) == None
assert box.get_token_data("BenTechyFTW") == ('BenTechyFTW',123456,0,None,None,None,None,None,None)
assert box.add_token("Randiboom",88) == ('Randiboom',88,0,None,None,None,None,None,None)
assert box.add_source1("BenTechyFTW","Shrewsbury") == ('BenTechyFTW',123456,0,None,None,None,None,"Shrewsbury",None)
assert box.add_options("BenTechyFTW","001","002","003") == ('BenTechyFTW',123456,1,"001","002","003",None,"Shrewsbury",None)
assert box.get_token_data("BenTechyFTW") == ('BenTechyFTW',123456,1,"001","002","003",None,"Shrewsbury",None)
assert box.add_source2("BenTechyFTW","Shrewsbury too.") == ('BenTechyFTW',123456,1,"001","002","003",None,"Shrewsbury","Shrewsbury too.")
assert box.add_source2("BenTechyFTW","Whoops, nevermind.") == ('BenTechyFTW',123456,1,"001","002","003",None,"Shrewsbury","Whoops, nevermind.")
assert box.add_choice("BenTechyFTW","003") == ('BenTechyFTW',123456,2,"001","002","003","003","Shrewsbury","Whoops, nevermind.")
hardcore_reset.hard_reset(True)