@@ -12,19 +12,79 @@ def setUp(self):
1212 self .ct = CleanTalk (auth_key = '7emegy4e' )
1313
1414 def test_blacklisted (self ):
15- response = self .ct .request (message = 'abc' ,
16- sender_ip = '196.19.250.114' ,
17- sender_email = 'stop_email@example.com' ,
18- sender_nickname = 'spam_bot' ,
19- submit_time = 12 ,
20- js_on = 1 )
15+ response = self .ct .request (
16+ message = 'abc' , # Comment visitor to the site
17+ sender_ip = '196.19.250.114' , # IP address of the visitor
18+ sender_email = 'stop_email@example.com' , # Email IP of the visitor
19+ sender_nickname = 'spam_bot' , # Nickname of the visitor
20+ submit_time = 12 , # The time taken to fill the comment form in seconds
21+ js_on = 1 # The presence of JavaScript for the site visitor, 0|1
22+ )
23+ print (response )
24+ #make sure that 'allow' is 0
25+ self .assertFalse (response ['allow' ])
26+
27+ def test_correct_ip (self ):
28+ response = self .ct .request (
29+ message = 'abc' , # Comment visitor to the site
30+ sender_ip = '109.188.126.23' , # IP address of the visitor
31+ sender_email = '' , # Email IP of the visitor
32+ sender_nickname = 'spam_bot' , # Nickname of the visitor
33+ submit_time = 12 , # The time taken to fill the comment form in seconds
34+ js_on = 1 # The presence of JavaScript for the site visitor, 0|1
35+ )
36+ print (response )
37+ self .assertTrue (response ['allow' ])
38+
39+ def test_correct_email (self ):
40+ response = self .ct .request (
41+ message = 'abc' , # Comment visitor to the site
42+ sender_ip = '' , # IP address of the visitor
43+ sender_email = 'chelovek_cheloveku_volk@zombizombizombi.ru' , # Email IP of the visitor
44+ sender_nickname = 'spam_bot' , # Nickname of the visitor
45+ submit_time = 12 , # The time taken to fill the comment form in seconds
46+ js_on = 1 # The presence of JavaScript for the site visitor, 0|1
47+ )
48+ print (response )
49+ self .assertTrue (response ['allow' ])
2150
51+ def test_incorrect_js_and_submit_time (self ):
52+ response = self .ct .request (
53+ message = 'abc' , # Comment visitor to the site
54+ sender_ip = '' , # IP address of the visitor
55+ sender_email = 'aa-shi@yandex.ru' , # Email IP of the visitor
56+ sender_nickname = 'aa-shi' , # Nickname of the visitor
57+ submit_time = 1 , # The time taken to fill the comment form in seconds
58+ js_on = 0 # The presence of JavaScript for the site visitor, 0|1
59+ )
2260 print (response )
23- #make sure that response contain 'allow'
24- self .assertTrue ('allow' in response )
25- #make sure that 'allow' is true
2661 self .assertFalse (response ['allow' ])
2762
63+ def test_js_null (self ):
64+ #bad user
65+ response = self .ct .request (
66+ message = 'abc' , # Comment visitor to the site
67+ sender_ip = '196.19.250.114' , # IP address of the visitor
68+ sender_email = 'stop_email@example.com' , # Email IP of the visitor
69+ sender_nickname = 'spam_bot' , # Nickname of the visitor
70+ submit_time = 12 , # The time taken to fill the comment form in seconds
71+ js_on = None # The presence of JavaScript for the site visitor, 0|1
72+ )
73+ print (response )
74+ self .assertFalse (response ['allow' ])
75+
76+ #good user
77+ response = self .ct .request (
78+ message = 'abc' , # Comment visitor to the site
79+ sender_ip = '' , # IP address of the visitor
80+ sender_email = 'aa-shi@yandex.ru' , # Email IP of the visitor
81+ sender_nickname = 'aa-shi' , # Nickname of the visitor
82+ submit_time = 12 , # The time taken to fill the comment form in seconds
83+ js_on = None # The presence of JavaScript for the site visitor, 0|1
84+ )
85+ print (response )
86+ self .assertTrue (response ['allow' ])
87+
2888
2989if __name__ == '__main__' :
3090 unittest .main ()
0 commit comments