[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] Tests didn't reflect tracker's renamed methods



commit f700a3a4459fc2d0b5b1937199cbc94c1ba6d2f4
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Jun 28 12:09:38 2014 -0700

    Tests didn't reflect tracker's renamed methods
    
    We renamed a few methods in our tracker util but make them match in the tests,
    breaking our unit tests.
---
 test/util/tracker/connection_tracker.py |   28 ++++++++++++++--------------
 test/util/tracker/resource_tracker.py   |   12 ++++++------
 2 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/test/util/tracker/connection_tracker.py b/test/util/tracker/connection_tracker.py
index bdb1d69..0e756de 100644
--- a/test/util/tracker/connection_tracker.py
+++ b/test/util/tracker/connection_tracker.py
@@ -17,21 +17,21 @@ class TestConnectionTracker(unittest.TestCase):
   @patch('arm.util.tracker.connection.get_connections')
   @patch('arm.util.tracker.system', Mock(return_value = Mock()))
   @patch('arm.util.tracker.connection.get_system_resolvers', Mock(return_value = [connection.Resolver.NETSTAT]))
-  def test_fetching_connections(self, get_connections_mock, tor_controller_mock):
+  def test_fetching_connections(self, get_value_mock, tor_controller_mock):
     tor_controller_mock().get_pid.return_value = 12345
-    get_connections_mock.return_value = [CONNECTION_1, CONNECTION_2, CONNECTION_3]
+    get_value_mock.return_value = [CONNECTION_1, CONNECTION_2, CONNECTION_3]
 
     with ConnectionTracker(0.04) as daemon:
       time.sleep(0.01)
 
-      connections = daemon.get_connections()
+      connections = daemon.get_value()
 
       self.assertEqual(1, daemon.run_counter())
       self.assertEqual([CONNECTION_1, CONNECTION_2, CONNECTION_3], connections)
 
-      get_connections_mock.return_value = []  # no connection results
+      get_value_mock.return_value = []  # no connection results
       time.sleep(0.05)
-      connections = daemon.get_connections()
+      connections = daemon.get_value()
 
       self.assertEqual(2, daemon.run_counter())
       self.assertEqual([], connections)
@@ -40,37 +40,37 @@ class TestConnectionTracker(unittest.TestCase):
   @patch('arm.util.tracker.connection.get_connections')
   @patch('arm.util.tracker.system', Mock(return_value = Mock()))
   @patch('arm.util.tracker.connection.get_system_resolvers', Mock(return_value = [connection.Resolver.NETSTAT, connection.Resolver.LSOF]))
-  def test_resolver_failover(self, get_connections_mock, tor_controller_mock):
+  def test_resolver_failover(self, get_value_mock, tor_controller_mock):
     tor_controller_mock().get_pid.return_value = 12345
-    get_connections_mock.side_effect = IOError()
+    get_value_mock.side_effect = IOError()
 
     with ConnectionTracker(0.01) as daemon:
       time.sleep(0.03)
 
       self.assertEqual([connection.Resolver.NETSTAT, connection.Resolver.LSOF], daemon._resolvers)
-      self.assertEqual([], daemon.get_connections())
+      self.assertEqual([], daemon.get_value())
 
       time.sleep(0.05)
 
       self.assertEqual([connection.Resolver.LSOF], daemon._resolvers)
-      self.assertEqual([], daemon.get_connections())
+      self.assertEqual([], daemon.get_value())
 
       time.sleep(0.05)
 
       self.assertEqual([], daemon._resolvers)
-      self.assertEqual([], daemon.get_connections())
+      self.assertEqual([], daemon.get_value())
 
       # Now make connection resolution work. We still shouldn't provide any
       # results since we stopped looking.
 
-      get_connections_mock.return_value = [CONNECTION_1, CONNECTION_2]
-      get_connections_mock.side_effect = None
+      get_value_mock.return_value = [CONNECTION_1, CONNECTION_2]
+      get_value_mock.side_effect = None
       time.sleep(0.05)
-      self.assertEqual([], daemon.get_connections())
+      self.assertEqual([], daemon.get_value())
 
       # Finally, select a custom resolver. This should cause us to query again
       # reguardless of our prior failures.
 
       daemon.set_custom_resolver(connection.Resolver.NETSTAT)
       time.sleep(0.05)
-      self.assertEqual([CONNECTION_1, CONNECTION_2], daemon.get_connections())
+      self.assertEqual([CONNECTION_1, CONNECTION_2], daemon.get_value())
diff --git a/test/util/tracker/resource_tracker.py b/test/util/tracker/resource_tracker.py
index 41ef80e..10509cf 100644
--- a/test/util/tracker/resource_tracker.py
+++ b/test/util/tracker/resource_tracker.py
@@ -23,7 +23,7 @@ class TestResourceTracker(unittest.TestCase):
     with ResourceTracker(0.04) as daemon:
       time.sleep(0.01)
 
-      resources = daemon.get_resource_usage()
+      resources = daemon.get_value()
 
       self.assertEqual(1, daemon.run_counter())
       self.assertEqual(0.0, resources.cpu_sample)
@@ -35,7 +35,7 @@ class TestResourceTracker(unittest.TestCase):
 
       resources_via_proc_mock.return_value = (800.3, 3.2, 6020, 0.26)
       time.sleep(0.05)
-      resources = daemon.get_resource_usage()
+      resources = daemon.get_value()
 
       self.assertEqual(2, daemon.run_counter())
       self.assertEqual(6.600189933523267, resources.cpu_sample)
@@ -60,7 +60,7 @@ class TestResourceTracker(unittest.TestCase):
     with ResourceTracker(0.04) as daemon:
       time.sleep(0.01)
 
-      resources = daemon.get_resource_usage()
+      resources = daemon.get_value()
 
       self.assertEqual(1, daemon.run_counter())
       self.assertEqual(0.0, resources.cpu_sample)
@@ -75,7 +75,7 @@ class TestResourceTracker(unittest.TestCase):
     with ResourceTracker(0.04) as daemon:
       time.sleep(0.01)
 
-      resources = daemon.get_resource_usage()
+      resources = daemon.get_value()
 
       self.assertEqual(1, daemon.run_counter())
       self.assertEqual(0.0, resources.cpu_sample)
@@ -97,7 +97,7 @@ class TestResourceTracker(unittest.TestCase):
       time.sleep(0.03)
 
       self.assertEqual(True, daemon._use_proc)
-      resources = daemon.get_resource_usage()
+      resources = daemon.get_value()
 
       self.assertEqual(0, daemon.run_counter())
       self.assertEqual(0.0, resources.cpu_sample)
@@ -112,7 +112,7 @@ class TestResourceTracker(unittest.TestCase):
 
       self.assertEqual(False, daemon._use_proc)
 
-      resources = daemon.get_resource_usage()
+      resources = daemon.get_value()
 
       self.assertEqual(0.0, resources.cpu_sample)
       self.assertEqual(43.875, resources.cpu_average)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits