commit aac5d653b82db5dca9cfe955749a66a627b9e157 Author: Arturo Filastò art@fuffa.org Date: Mon Aug 18 14:53:05 2014 +0200
Add a unittest for txscapy. --- ooni/tests/test_txscapy.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/ooni/tests/test_txscapy.py b/ooni/tests/test_txscapy.py index 045eeeb..1dbb8cc 100644 --- a/ooni/tests/test_txscapy.py +++ b/ooni/tests/test_txscapy.py @@ -38,8 +38,10 @@ class TestTxScapy(unittest.TestCase): sender = txscapy.ScapySender() self.scapy_factory.registerProtocol(sender)
- packet_sent = IP(dst='8.8.8.8', src='127.0.0.1') / TCP(dport=53, sport=5300) - packet_received = IP(dst='127.0.0.1', src='8.8.8.8') / TCP(sport=53, dport=5300) + packet_sent = IP(dst='8.8.8.8', src='127.0.0.1') / TCP(dport=53, + sport=5300) + packet_received = IP(dst='127.0.0.1', src='8.8.8.8') / TCP(sport=53, + dport=5300)
d = sender.startSending([packet_sent]) self.scapy_factory.super_socket.send.assert_called_with(packet_sent) @@ -49,3 +51,17 @@ class TestTxScapy(unittest.TestCase): result = yield d assert result[0][0][0] == packet_sent assert result[0][0][1] == packet_received + + def test_get_addresses(self): + addresses = txscapy.getAddresses() + assert isinstance(addresses, list) + + # @defer.inlineCallbacks + # def test_multi_traceroute(self): + # traceroute = txscapy.MPTraceroute() + # traceroute.timeout = 3 + # self.scapy_factory.registerProtocol(traceroute) + # yield traceroute.ICMPTraceroute('8.8.8.8') + # yield traceroute.TCPTraceroute('8.8.8.8') + # yield traceroute.UDPTraceroute('8.8.8.8') + # self.scapy_factory.super_socket.send.assert_called()