Пример #1
0
 def test_get_cut_v1(self, caplog, temp_event_loop):
     caplog.set_level(logging.DEBUG)
     mock_reader = self.MockAsyncReader(GOOD_V1_HANDSHAKE[0:20])
     reslt = temp_event_loop.run_until_complete(get_proxy(mock_reader))
     assert isinstance(reslt, ProxyData)
     assert not reslt.valid
     assert reslt.error == "PROXYv1 malformed"
     expect = ("mail.debug", 30, "PROXY error: PROXYv1 malformed")
     assert expect in caplog.record_tuples
Пример #2
0
 def test_get_invalid_sig(self, caplog, temp_event_loop):
     caplog.set_level(logging.DEBUG)
     mock_reader = self.MockAsyncReader(b"PROXI TCP4 1.2.3.4 5.6.7.8 9 10\r\n")
     reslt = temp_event_loop.run_until_complete(get_proxy(mock_reader))
     assert isinstance(reslt, ProxyData)
     assert not reslt.valid
     expect_msg = "PROXY unrecognized signature"
     assert reslt.error == expect_msg
     expect = ("mail.debug", 30, "PROXY error: " + expect_msg)
     assert expect in caplog.record_tuples
Пример #3
0
 def test_get_cut_v2(self, caplog, temp_event_loop):
     caplog.set_level(logging.DEBUG)
     mock_reader = self.MockAsyncReader(TEST_V2_DATA1_EXACT[0:20])
     reslt = temp_event_loop.run_until_complete(get_proxy(mock_reader))
     assert isinstance(reslt, ProxyData)
     assert not reslt.valid
     expect_msg = "PROXY exception: Connection lost while waiting for tail part"
     assert reslt.error == expect_msg
     expect = ("mail.debug", 30, expect_msg)
     assert expect in caplog.record_tuples
Пример #4
0
 def test_get(
     self,
     caplog: pytest.LogCaptureFixture,
     temp_event_loop: asyncio.AbstractEventLoop,
     handshake: bytes,
 ):
     caplog.set_level(logging.DEBUG)
     mock_reader = self.MockAsyncReader(handshake)
     reslt = temp_event_loop.run_until_complete(get_proxy(mock_reader))
     assert isinstance(reslt, ProxyData)
     assert reslt.valid
Пример #5
0
 def test_get(self, caplog, temp_event_loop, handshake):
     caplog.set_level(logging.DEBUG)
     mock_reader = self.MockAsyncReader(handshake)
     reslt = temp_event_loop.run_until_complete(get_proxy(mock_reader))
     assert isinstance(reslt, ProxyData)
     assert reslt.valid