Beispiel #1
0
 async def test_something_to_send_multiple(self):
     self.dbmain.getAutoRepeats.return_value = AsyncIterator([
         RepeatData('botgotsthis', '', 'FrankerZ', 10, 1,
                    self.now - timedelta(minutes=1)),
         RepeatData('megotsthis', '', 'Kappa', 10, 1,
                    self.now - timedelta(minutes=1)),
     ])
     self.assertEqual([r async for r in self.data.getAutoRepeatToSend()], [
         AutoRepeatMessage('botgotsthis', '', 'FrankerZ'),
         AutoRepeatMessage('megotsthis', '', 'Kappa')
     ])
Beispiel #2
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')])
Beispiel #3
0
 async def test_something_to_send_multiple(self):
     dt = datetime.utcnow()
     dt -= timedelta(microseconds=dt.microsecond)
     await self.executemany(
         "INSERT INTO auto_repeat VALUES (?, ?, ?, ?, ?, ?, ?)",
         [('botgotsthis', '', 'Kappa', 10, 5, dt - timedelta(minutes=5),
           dt),
          ('botgotsthis', 'kappa', 'Kappa', None, 5,
           dt - timedelta(minutes=5), dt)])
     self.assertEqual(
         [r async for r in self.database.getAutoRepeatToSend()], [
             AutoRepeatMessage('botgotsthis', '', 'Kappa'),
             AutoRepeatMessage('botgotsthis', 'kappa', 'Kappa')
         ])
Beispiel #4
0
 async def test(self):
     self.assertEqual(
         [r async for r in self.data.getAutoRepeatToSend(self.now)],
         [AutoRepeatMessage('megotsthis', '', 'Kappa')])
     self.assertTrue(self.dbmain.getAutoRepeats.called)
     self.dbmain.getAutoRepeats.reset_mock()
     self.assertEqual(
         [r async for r in self.data.getAutoRepeatToSend(self.now)],
         [AutoRepeatMessage('megotsthis', '', 'Kappa')])
     self.assertFalse(self.dbmain.getAutoRepeats.called)
     self.assertEqual(
         [r async for r in self.data.listAutoRepeat('botgotsthis')],
         [AutoRepeatList('', 'FrankerZ', None, 1, self.now)])
     self.assertFalse(self.dbmain.getAutoRepeats.called)
     self.assertIsNotNone(await self.redis.get('autorepeat'))
Beispiel #5
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)
Beispiel #6
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')
Beispiel #7
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')])
Beispiel #8
0
 async def test_something_to_send(self):
     await self.executemany(
         "INSERT INTO auto_repeat VALUES (?, ?, ?, ?, ?, ?, ?)",
         [('botgotsthis', '', 'Kappa', None, 5,
           datetime.utcnow() - timedelta(minutes=5), datetime.utcnow()),
          ('botgotsthis', 'kappa', 'Kappa', None, 5, datetime.utcnow(),
           datetime.utcnow())])
     self.assertEqual(
         [r async for r in self.database.getAutoRepeatToSend()],
         [AutoRepeatMessage('botgotsthis', '', 'Kappa')])
Beispiel #9
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')
Beispiel #10
0
 async def test_something_to_send(self):
     self.assertEqual(
         [r async for r in self.data.getAutoRepeatToSend(self.now)],
         [AutoRepeatMessage('megotsthis', '', 'Kappa')])