5
5
from cleantalk import CleanTalk
6
6
import os
7
7
import unittest
8
-
8
+ import json
9
9
10
10
class TestCleanTalk (unittest .TestCase ):
11
11
@@ -21,7 +21,8 @@ def test_blacklisted(self):
21
21
sender_email = '[email protected] ' ,
# Email IP of the visitor
22
22
sender_nickname = 'spam_bot' , # Nickname of the visitor
23
23
submit_time = 12 , # The time taken to fill the comment form in seconds
24
- js_on = 1 # The presence of JavaScript for the site visitor, 0|1
24
+ js_on = 1 , # The presence of JavaScript for the site visitor, 0|1
25
+ post_info = json .dumps ({'post_url' : 'https://text.com/1/2/3/4.html' })
25
26
)
26
27
print (response )
27
28
# make sure that 'allow' is 0
@@ -34,7 +35,8 @@ def test_correct_ip(self):
34
35
sender_email = '[email protected] ' ,
# Email IP of the visitor
35
36
sender_nickname = 'real human' , # Nickname of the visitor
36
37
submit_time = 12 , # The time taken to fill the comment form in seconds
37
- js_on = 1 # The presence of JavaScript for the site visitor, 0|1
38
+ js_on = 1 , # The presence of JavaScript for the site visitor, 0|1
39
+ post_info = json .dumps ({'post_url' : 'https://text.com/1/2/3/4.html' })
38
40
)
39
41
print (response )
40
42
self .assertTrue (response ['allow' ])
@@ -46,7 +48,8 @@ def test_incorrect_email(self):
46
48
sender_email = '[email protected] ' ,
# Email IP of the visitor
47
49
sender_nickname = 'real human' , # Nickname of the visitor
48
50
submit_time = 12 , # The time taken to fill the comment form in seconds
49
- js_on = 1 # The presence of JavaScript for the site visitor, 0|1
51
+ js_on = 1 , # The presence of JavaScript for the site visitor, 0|1
52
+ post_info = json .dumps ({'post_url' : 'https://text.com/1/2/3/4.html' })
50
53
)
51
54
print (response )
52
55
self .assertTrue (bool (response ['codes' ].find ('EMAIL_DOMAIN_NOT_EXISTS' )))
@@ -59,7 +62,8 @@ def test_incorrect_js_and_submit_time(self):
59
62
sender_email = '[email protected] ' ,
# Email IP of the visitor
60
63
sender_nickname = 'aa-shi' , # Nickname of the visitor
61
64
submit_time = 1 , # The time taken to fill the comment form in seconds
62
- js_on = 0 # The presence of JavaScript for the site visitor, 0|1
65
+ js_on = 1 , # The presence of JavaScript for the site visitor, 0|1
66
+ post_info = json .dumps ({'post_url' : 'https://text.com/1/2/3/4.html' })
63
67
)
64
68
print (response )
65
69
self .assertTrue (bool (response ['codes' ].find ('JS DISABLED' )))
@@ -73,7 +77,8 @@ def test_js_null(self):
73
77
sender_email = '[email protected] ' ,
# Email IP of the visitor
74
78
sender_nickname = 'spam_bot' , # Nickname of the visitor
75
79
submit_time = 12 , # The time taken to fill the comment form in seconds
76
- js_on = None # The presence of JavaScript for the site visitor, 0|1
80
+ js_on = 1 , # The presence of JavaScript for the site visitor, 0|1
81
+ post_info = json .dumps ({'post_url' : 'https://text.com/1/2/3/4.html' })
77
82
)
78
83
print (response )
79
84
self .assertTrue (bool (response ['codes' ].find ('JS DISABLED' )))
@@ -85,7 +90,8 @@ def test_js_null(self):
85
90
sender_email = '[email protected] ' ,
# Email IP of the visitor
86
91
sender_nickname = 'aa-shi' , # Nickname of the visitor
87
92
submit_time = 12 , # The time taken to fill the comment form in seconds
88
- js_on = None # The presence of JavaScript for the site visitor, 0|1
93
+ js_on = 1 , # The presence of JavaScript for the site visitor, 0|1
94
+ post_info = json .dumps ({'post_url' : 'https://text.com/1/2/3/4.html' })
89
95
)
90
96
print (response )
91
97
self .assertTrue (bool (response ['codes' ].find ('JS DISABLED' )))
0 commit comments