File tree Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Expand file tree Collapse file tree 1 file changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ from unittest .mock import MagicMock
2
+
3
+ import pytest
4
+
5
+ from cloudbot .event import Event
6
+ from plugins import herald
7
+ from tests .util import wrap_hook_response
8
+
9
+
10
+ @pytest .fixture ()
11
+ def clear_cache ():
12
+ try :
13
+ yield
14
+ finally :
15
+ herald .herald_cache .clear ()
16
+
17
+
18
+ @pytest .fixture ()
19
+ def unset_timeout ():
20
+ try :
21
+ yield
22
+ finally :
23
+ herald .floodcheck .clear ()
24
+
25
+
26
+ @pytest .mark .usefixtures ("unset_timeout" )
27
+ class TestWelcome :
28
+ def _run (self ):
29
+ conn = MagicMock ()
30
+ event = Event (
31
+ hook = MagicMock (),
32
+ bot = conn .bot ,
33
+ conn = conn ,
34
+ channel = '#foo' ,
35
+ nick = 'foobaruser'
36
+ )
37
+ return wrap_hook_response (herald .welcome , event )
38
+
39
+ def test_no_herald (self ):
40
+ result = self ._run ()
41
+ assert result == []
42
+
43
+ @pytest .mark .parametrize ('text,out' , [
44
+ ('Hello world' , '\u200b Hello world' ),
45
+ ('bino' , '\u200b flenny' ),
46
+ ('\u200b hi' , '\u200b \u200b hi' ),
47
+ ('o\u200b <' , 'DECOY DUCK --> o\u200b <' ),
48
+ ])
49
+ def test_char_strip (self , clear_cache , text , out ):
50
+ herald .herald_cache ['#foo' ]['foobaruser' ] = text
51
+ result = self ._run ()
52
+ assert result == [('message' , ('#foo' , out ))]
You can’t perform that action at this time.
0 commit comments