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)
 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('')
    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'])
 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')], [])
    async def setUp(self):
        await super().setUp()

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