コード例 #1
0
    async def setUp(self):
        await super().setUp()

        self.dbmain.getCustomCommands.side_effect = lambda *_: AsyncIterator([
            ('kappa', '', 'Kappa'),
            ('kappa', 'owner', 'Kappa'),
        ])
        getCustomCommandProperties = self.dbmain.getCustomCommandProperties
        getCustomCommandProperties.side_effect = lambda *_: AsyncIterator([
            ('kappa', '', 'prop', 'value'),
        ])

        self.channel = 'megotsthis'
        self.key = f'twitch:{self.channel}:commands'
コード例 #2
0
    async def setUp(self):
        await super().setUp()

        self.dbmain.getFeatures.return_value = AsyncIterator(['feature'])

        self.channel = 'megotsthis'
        self.key = f'twitch:{self.channel}:features'
コード例 #3
0
 async def test_no_channel(self):
     self.data.getAutoRepeatToSend.return_value = AsyncIterator(
         [AutoRepeatMessage('megotsthis', '', 'Kappa')])
     await tasks.autoRepeatMessage(self.now)
     self.assertFalse(self.data.sentAutoRepeat.called)
     self.assertFalse(self.mock_timeout.called)
     self.assertFalse(self.channel.send.called)
コード例 #4
0
 async def test_many(self, mock_messages):
     self.database.listBannedChannels.return_value = AsyncIterator(
         ['botgotsthis', 'megotsthis'])
     mock_messages.return_value = ''
     self.assertIs(await banned.list_banned_channels(self.send), True)
     mock_messages.assert_called_once_with(['botgotsthis', 'megotsthis'],
                                           StrContains('Banned'))
     self.send.assert_called_once_with('')
コード例 #5
0
    async def setUp(self):
        await super().setUp()

        self.dbmain.getPermittedUsers.return_value = AsyncIterator(
            ['botgotsthis'])

        self.channel = 'megotsthis'
        self.key = f'twitch:{self.channel}:permitted'
コード例 #6
0
 async def test_something_to_send_count(self):
     self.dbmain.getAutoRepeats.return_value = AsyncIterator([
         RepeatData('botgotsthis', '', 'FrankerZ', 10, 1, self.now),
         RepeatData('megotsthis', '', 'Kappa', 10, 1,
                    self.now - timedelta(minutes=1)),
     ])
     self.assertEqual([r async for r in self.data.getAutoRepeatToSend()],
                      [AutoRepeatMessage('megotsthis', '', 'Kappa')])
コード例 #7
0
 async def test(self):
     self.data.getAutoRepeatToSend.return_value = AsyncIterator([
         AutoRepeatMessage('botgotsthis', '', 'Kappa'),
     ])
     await tasks.autoRepeatMessage(self.now)
     self.data.sentAutoRepeat.assert_called_once_with('botgotsthis', '')
     self.assertFalse(self.mock_timeout.called)
     self.channel.send.assert_called_once_with('Kappa')
コード例 #8
0
 async def test_something_to_send_decimal(self):
     self.dbmain.getAutoRepeats.return_value = AsyncIterator([
         RepeatData('botgotsthis', '', 'FrankerZ', None, 1,
                    self.now - timedelta(seconds=5)),
         RepeatData('megotsthis', '', 'Kappa', None, 0.1,
                    self.now - timedelta(seconds=6)),
     ])
     self.assertEqual([r async for r in self.data.getAutoRepeatToSend()],
                      [AutoRepeatMessage('megotsthis', '', 'Kappa')])
コード例 #9
0
    async def setUp(self):
        await super().setUp()

        self.now = datetime.utcnow()

        self.dbmain.getAutoRepeats.return_value = AsyncIterator([
            RepeatData('botgotsthis', '', 'FrankerZ', None, 1, self.now),
            RepeatData('megotsthis', '', 'Kappa', None, 1,
                       self.now - timedelta(minutes=1)),
        ])
コード例 #10
0
 async def test_process_list_empty(self):
     self.args = self.args._replace(message=Message('!autorepeat list'))
     self.data.listAutoRepeat.return_value = AsyncIterator([])
     self.assertIs(await channel.process_auto_repeat(self.args, 1), True)
     self.data.listAutoRepeat.assert_called_once_with(
         self.channel.channel)
     self.assertFalse(self.data.removeAutoRepeat.called)
     self.assertFalse(self.data.setAutoRepeat.called)
     self.channel.send.assert_called_once_with(
         StrContains('No', 'Auto Repeats'))
コード例 #11
0
    async def setUp(self):
        await super().setUp()

        self.dbmain.getAllChatProperties.return_value = AsyncIterator([
            ('kappa', '0'),
            ('keepo', '1'),
        ])

        self.channel = 'megotsthis'
        self.key = f'twitch:{self.channel}:properties'
コード例 #12
0
 async def test_mod(self):
     self.channel.isMod = True
     self.data.getAutoRepeatToSend.return_value = AsyncIterator([
         AutoRepeatMessage('botgotsthis', '', 'Kappa'),
     ])
     await tasks.autoRepeatMessage(self.now)
     self.data.sentAutoRepeat.assert_called_once_with('botgotsthis', '')
     self.mock_timeout.assert_called_once_with(self.channel, None, 'Kappa',
                                               None, 'autorepeat')
     self.channel.send.assert_called_once_with('Kappa')
コード例 #13
0
 async def test_multiple(self):
     self.data.getAutoRepeatToSend.return_value = AsyncIterator([
         AutoRepeatMessage('botgotsthis', '', 'Kappa'),
         AutoRepeatMessage('botgotsthis', 'Kappa', 'Keepo'),
     ])
     await tasks.autoRepeatMessage(self.now)
     self.data.sentAutoRepeat.assert_has_calls(
         [call('botgotsthis', ''),
          call('botgotsthis', 'Kappa')])
     self.assertFalse(self.mock_timeout.called)
     self.channel.send.assert_has_calls([call('Kappa'), call('Keepo')])
コード例 #14
0
 async def test_process_list(self):
     self.args = self.args._replace(message=Message('!autorepeat list'))
     self.data.listAutoRepeat.return_value = AsyncIterator([
         AutoRepeatList('Kappa', 'Keepo', None, 1, self.now),
         AutoRepeatList(':)', ':(', None, 5, self.now),
         ])
     self.assertIs(await channel.process_auto_repeat(self.args, 1), True)
     self.data.listAutoRepeat.assert_called_once_with(
         self.channel.channel)
     self.assertFalse(self.data.removeAutoRepeat.called)
     self.assertFalse(self.data.setAutoRepeat.called)
     self.channel.send.assert_has_calls([
         call(StrContains('Auto Repeats')),
         call(StrContains('Kappa', 'Keepo', '1')),
         call(StrContains(':)', ':(', '5')),
         ])
コード例 #15
0
 async def test_nothing_to_send(self):
     self.dbmain.getAutoRepeats.return_value = AsyncIterator([
         RepeatData('botgotsthis', '', 'FrankerZ', None, 1, self.now),
     ])
     self.assertEqual(
         [r async for r in self.data.getAutoRepeatToSend(self.now)], [])
コード例 #16
0
 async def test_empty(self):
     self.dbmain.getAutoRepeats.return_value = AsyncIterator([])
     self.assertEqual(
         [r async for r in self.data.getAutoRepeatToSend(self.now)], [])
コード例 #17
0
    async def setUp(self):
        await super().setUp()

        self.dbmain.getBotManagers.return_value = AsyncIterator(
            ['botgotsthis'])
コード例 #18
0
 async def test(self):
     self.database.listBannedChannels.return_value = AsyncIterator([])
     self.assertIs(await banned.list_banned_channels(self.send), True)
     self.send.assert_called_once_with(StrContains('no'))
コード例 #19
0
 async def test_empty(self):
     self.data.getAutoRepeatToSend.return_value = AsyncIterator([])
     await tasks.autoRepeatMessage(self.now)
     self.assertFalse(self.data.sentAutoRepeat.called)
     self.assertFalse(self.mock_timeout.called)
     self.assertFalse(self.channel.send.called)
コード例 #20
0
 async def test_list_empty(self):
     self.dbmain.getAutoRepeats.return_value = AsyncIterator([])
     self.assertEqual(
         [r async for r in self.data.listAutoRepeat('botgotsthis')], [])
コード例 #21
0
    async def setUp(self):
        await super().setUp()

        self.dbmain.getGameAbbreviations.return_value = AsyncIterator([
            ('kappa', 'FrankerZ'),
        ])