Beispiel #1
0
class TestIrcChannel(TestCase):

    def setUp(self):
        self.n = Network.objects.create(server='localhost')
        self.r = Room.objects.create(
            name='#example',
            subscribes_tags='default',
            blocks_tags='silly',
            server=self.n,
        )
        self.s = ChannelService(self.r)
        self.s.parent = mock.Mock()

    def test_maybe_say(self):
        self.assertEqual(
            self.s._maybe_say(None, 'Hello', tags=['default']),
            True,
        )
        self.s.parent.client.connection.privmsg.assert_called_with("#example", "Hello")

    def test_maybe_say_action(self):
        self.assertEqual(
            self.s._maybe_say(None, 'Hello', tags=['default'], action=True),
            True,
        )
        self.assertEqual(self.s.parent.client.connection.action.called, 1)

    def test_maybe_say_notice(self):
        self.assertEqual(
            self.s._maybe_say(None, 'Hello', tags=['default'], notice=True),
            True,
        )
        self.assertEqual(self.s.parent.client.connection.notice.called, 1)

    def test_maybe_not_say(self):
        self.assertEqual(
            self.s._maybe_say(None, 'Hello', tags=['serious']),
            False,
        )
        self.assertEqual(self.s.parent.client.msg.called, 0)

    def test_maybe_say_blocked(self):
        self.assertEqual(
            self.s._maybe_say(None, 'Hello', tags=['default', 'silly']),
            False,
        )
        self.assertEqual(self.s.parent.client.msg.called, 0)
Beispiel #2
0
 def setUp(self):
     self.n = Network.objects.create(server='localhost')
     self.r = Room.objects.create(
         name='#example',
         subscribes_tags='default',
         blocks_tags='silly',
         server=self.n,
     )
     self.s = ChannelService(self.r)
     self.s.parent = mock.Mock()