commit c4a7093cb3c0e96e5c6ae99e028a68305954e091 Author: Damian Johnson atagar@torproject.org Date: Sat Nov 4 15:40:42 2017 -0700
Fix unit tests
Couple recent changes need to be accounted for. --- test/panel/connection.py | 6 +++--- test/tracker/connection_tracker.py | 11 +++++++---- 2 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/test/panel/connection.py b/test/panel/connection.py index ccc3aa5..b432df5 100644 --- a/test/panel/connection.py +++ b/test/panel/connection.py @@ -206,7 +206,7 @@ class TestConnectionPanel(unittest.TestCase):
test_data = (( line(), - ' 75.119.206.243:22 (de) --> 82.121.9.9:3531 15.4s (INBOUND)', + ' 75.119.206.243:22 (de) --> 82.121.9.9:3531 15.4s (INBOUND)', ), ( line(entry = MockEntry(entry_type = Category.CIRCUIT), line_type = LineType.CIRCUIT_HEADER), ' 82.121.9.9 --> 75.119.206.243:22 (de) 15.4s (CIRCUIT)', @@ -233,13 +233,13 @@ class TestConnectionPanel(unittest.TestCase):
test_data = (( line(), - '75.119.206.243:22 (de) --> 82.121.9.9:3531', + '75.119.206.243:22 (de) --> 82.121.9.9:3531', ), ( line(entry = MockEntry(entry_type = Category.EXIT)), '82.121.9.9:3531 --> 75.119.206.243:22 (SSH)', ), ( line(line_type = LineType.CIRCUIT_HEADER, circ = MockCircuit(status = 'EXTENDING')), - 'Building... --> 82.121.9.9', + 'Building... --> 82.121.9.9', ), ( line(line_type = LineType.CIRCUIT), '82.121.9.9', diff --git a/test/tracker/connection_tracker.py b/test/tracker/connection_tracker.py index 20f0095..993d460 100644 --- a/test/tracker/connection_tracker.py +++ b/test/tracker/connection_tracker.py @@ -1,7 +1,7 @@ import time import unittest
-from nyx.tracker import CustomResolver, ConnectionTracker +from nyx.tracker import ConnectionTracker
from stem.util import connection
@@ -22,6 +22,7 @@ class TestConnectionTracker(unittest.TestCase): @patch('nyx.tracker.tor_controller') @patch('nyx.tracker.connection.get_connections') @patch('nyx.tracker.system', Mock(return_value = Mock())) + @patch('stem.util.proc.is_available', Mock(return_value = False)) @patch('nyx.tracker.connection.system_resolvers', Mock(return_value = [connection.Resolver.NETSTAT])) def test_fetching_connections(self, get_value_mock, tor_controller_mock): tor_controller_mock().get_pid.return_value = 12345 @@ -46,6 +47,7 @@ class TestConnectionTracker(unittest.TestCase): @patch('nyx.tracker.tor_controller') @patch('nyx.tracker.connection.get_connections') @patch('nyx.tracker.system', Mock(return_value = Mock())) + @patch('stem.util.proc.is_available', Mock(return_value = False)) @patch('nyx.tracker.connection.system_resolvers', Mock(return_value = [connection.Resolver.NETSTAT, connection.Resolver.LSOF])) def test_resolver_failover(self, get_value_mock, tor_controller_mock): tor_controller_mock().get_pid.return_value = 12345 @@ -55,17 +57,17 @@ class TestConnectionTracker(unittest.TestCase): with ConnectionTracker(0.01) as daemon: time.sleep(0.015)
- self.assertEqual([connection.Resolver.NETSTAT, connection.Resolver.LSOF, CustomResolver.INFERENCE], daemon._resolvers) + self.assertEqual([connection.Resolver.NETSTAT, connection.Resolver.LSOF], daemon._resolvers) self.assertEqual([], daemon.get_value())
time.sleep(0.025)
- self.assertEqual([connection.Resolver.LSOF, CustomResolver.INFERENCE], daemon._resolvers) + self.assertEqual([connection.Resolver.LSOF], daemon._resolvers) self.assertEqual([], daemon.get_value())
time.sleep(0.035)
- self.assertEqual([CustomResolver.INFERENCE], daemon._resolvers) + self.assertEqual([], daemon._resolvers) self.assertEqual([], daemon.get_value())
# Now make connection resolution work. We still shouldn't provide any @@ -86,6 +88,7 @@ class TestConnectionTracker(unittest.TestCase): @patch('nyx.tracker.tor_controller') @patch('nyx.tracker.connection.get_connections') @patch('nyx.tracker.system', Mock(return_value = Mock())) + @patch('stem.util.proc.is_available', Mock(return_value = False)) @patch('nyx.tracker.connection.system_resolvers', Mock(return_value = [connection.Resolver.NETSTAT])) def test_tracking_uptime(self, get_value_mock, tor_controller_mock): tor_controller_mock().get_pid.return_value = 12345