[tor-commits] [arm/master] Testing fixes for renamed functions and header panel

atagar at torproject.org atagar at torproject.org
Tue Sep 2 03:56:01 UTC 2014


commit 514913522c74341bfad64e2d6da9939efb2e8b47
Author: Damian Johnson <atagar at torproject.org>
Date:   Mon Sep 1 20:57:01 2014 -0700

    Testing fixes for renamed functions and header panel
    
    Oops, didn't update our unit tests as I went along. Also a couple minor
    corrections from static checks for our header panel.
---
 arm/header_panel.py                     |    4 +---
 test/util/tracker/connection_tracker.py |    4 ++--
 test/util/tracker/daemon.py             |    6 +++---
 test/util/tracker/resource_tracker.py   |    6 +++---
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/arm/header_panel.py b/arm/header_panel.py
index 97a7fb3..0278285 100644
--- a/arm/header_panel.py
+++ b/arm/header_panel.py
@@ -19,7 +19,7 @@ import arm.popups
 import arm.starter
 import arm.util.tracker
 
-from stem.control import Listener, State
+from stem.control import Listener
 from stem.util import conf, log, str_tools
 
 from util import panel, tor_controller
@@ -358,8 +358,6 @@ class HeaderPanel(panel.Panel, threading.Thread):
     last_ran = -1
 
     while not self._halt:
-      current_time = time.time()
-
       if self.is_paused() or not self._vals.is_connected or (time.time() - last_ran) < UPDATE_RATE:
         with self._pause_condition:
           if not self._halt:
diff --git a/test/util/tracker/connection_tracker.py b/test/util/tracker/connection_tracker.py
index 0e756de..e6120bf 100644
--- a/test/util/tracker/connection_tracker.py
+++ b/test/util/tracker/connection_tracker.py
@@ -16,7 +16,7 @@ class TestConnectionTracker(unittest.TestCase):
   @patch('arm.util.tracker.tor_controller')
   @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]))
+  @patch('arm.util.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
     get_value_mock.return_value = [CONNECTION_1, CONNECTION_2, CONNECTION_3]
@@ -39,7 +39,7 @@ class TestConnectionTracker(unittest.TestCase):
   @patch('arm.util.tracker.tor_controller')
   @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]))
+  @patch('arm.util.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
     get_value_mock.side_effect = IOError()
diff --git a/test/util/tracker/daemon.py b/test/util/tracker/daemon.py
index 9d409e2..89f6031 100644
--- a/test/util/tracker/daemon.py
+++ b/test/util/tracker/daemon.py
@@ -14,7 +14,7 @@ class TestDaemon(unittest.TestCase):
     # properly retrieve the process' pid and name.
 
     tor_controller_mock().get_pid.return_value = 12345
-    system_mock.get_name_by_pid.return_value = 'local_tor'
+    system_mock.name_by_pid.return_value = 'local_tor'
 
     daemon = Daemon(0.05)
 
@@ -23,7 +23,7 @@ class TestDaemon(unittest.TestCase):
     self.assertEqual('local_tor', daemon._process_name)
 
     tor_controller_mock().add_status_listener.assert_called_with(daemon._tor_status_listener)
-    system_mock.get_name_by_pid.assert_called_with(12345)
+    system_mock.name_by_pid.assert_called_with(12345)
 
   @patch('arm.util.tracker.tor_controller')
   @patch('arm.util.tracker.system')
@@ -31,7 +31,7 @@ class TestDaemon(unittest.TestCase):
     # Check when we default to 'tor' if unable to determine the process' name.
 
     tor_controller_mock().get_pid.return_value = 12345
-    system_mock.get_name_by_pid.return_value = None
+    system_mock.name_by_pid.return_value = None
 
     daemon = Daemon(0.05)
     self.assertEqual('tor', daemon._process_name)
diff --git a/test/util/tracker/resource_tracker.py b/test/util/tracker/resource_tracker.py
index 10509cf..64883d9 100644
--- a/test/util/tracker/resource_tracker.py
+++ b/test/util/tracker/resource_tracker.py
@@ -131,9 +131,9 @@ class TestResourceTracker(unittest.TestCase):
     self.assertEqual(0.004, memory_in_percent)
 
   @patch('time.time', Mock(return_value = 1388967218.973117))
-  @patch('arm.util.tracker.proc.get_stats', Mock(return_value = (1.5, 0.5, 1388967200.9)))
-  @patch('arm.util.tracker.proc.get_memory_usage', Mock(return_value = (19300352, 6432)))
-  @patch('arm.util.tracker.proc.get_physical_memory', Mock(return_value = 4825088000))
+  @patch('arm.util.tracker.proc.stats', Mock(return_value = (1.5, 0.5, 1388967200.9)))
+  @patch('arm.util.tracker.proc.memory_usage', Mock(return_value = (19300352, 6432)))
+  @patch('arm.util.tracker.proc.physical_memory', Mock(return_value = 4825088000))
   def test_resources_via_proc(self):
     total_cpu_time, uptime, memory_in_bytes, memory_in_percent = _resources_via_proc(12345)
 



More information about the tor-commits mailing list