Example #1
0
    def test_command_close_cancels_timer(self):
        cmd = Command('CMD', 'tag', loop=self.loop, timeout=1)
        cmd.close('line', 'OK')
        yield from self.advance(3)

        yield from cmd.wait()
        self.assertEqual(Response('OK', ['line']), cmd.response)
Example #2
0
    def test_command_append_to_resp_resets_timer(self):
        cmd = Command('CMD', 'tag', loop=self.loop, timeout=2)

        yield from self.advance(1.9)
        cmd.append_to_resp('line 1')

        yield from self.advance(1.9)
        cmd.close('line 2', 'OK')

        yield from cmd.wait()
        self.assertEqual(Response('OK', ['line 1', 'line 2']), cmd.response)
Example #3
0
    def test_command_begin_literal_data_resets_timer(self):
        cmd = Command('CMD', 'tag', loop=self.loop, timeout=2)

        yield from self.advance(1)
        cmd.begin_literal_data(7, b'literal')

        yield from self.advance(1.9)
        cmd.close('line', 'OK')

        yield from cmd.wait()
        self.assertEqual(Response('OK', [b'literal', 'line']), cmd.response)
Example #4
0
    def test_command_append_to_resp_resets_timer(self):
        cmd = Command('CMD', 'tag', loop=self.loop, timeout=2)

        yield from self.advance(1.9)
        cmd.append_to_resp('line 1')

        yield from self.advance(1.9)
        cmd.close('line 2', 'OK')

        yield from cmd.wait()
        self.assertEqual(Response('OK', ['line 1', 'line 2']), cmd.response)
Example #5
0
    def test_command_begin_literal_data_resets_timer(self):
        cmd = Command('CMD', 'tag', loop=self.loop, timeout=2)

        yield from self.advance(1)
        cmd.begin_literal_data(7, b'literal')

        yield from self.advance(1.9)
        cmd.close('line', 'OK')

        yield from cmd.wait()
        self.assertEqual(Response('OK', [b'literal', 'line']), cmd.response)
    async def test_command_append_data_resets_timer(self):
        cmd = Command('CMD', 'tag', loop=self.loop, timeout=2)
        cmd.begin_literal_data(4, b'da')

        await self.advance(1.9)
        cmd.append_literal_data(b'ta')

        await self.advance(1.9)
        cmd.close('line', 'OK')

        await cmd.wait()
        self.assertEqual(Response('OK', [b'data', 'line']), cmd.response)