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

[tor-commits] [stem/master] Change broke tests under mock 0.8.0



commit 72ef5421eb1611ad9dec9e210dd20b4d2e977b03
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Thu Dec 4 18:34:17 2014 -0800

    Change broke tests under mock 0.8.0
    
    Our last commit used behavior of mock's side_effect that was introduced in
    1.0.0...
    
      'Any exceptions in an iterable side_effect will be raised instead of returned'
      http://www.voidspace.org.uk/python/mock/changelog.html#version-1-0-0
    
    This is all well and good, but our Jenkins tests are still using 0.8.0. We
    really don't need to rely on that behavoir here so just avoiding it.
---
 test/unit/control/controller.py |   25 ++++++++++++++-----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/test/unit/control/controller.py b/test/unit/control/controller.py
index 1974e50..58df2d4 100644
--- a/test/unit/control/controller.py
+++ b/test/unit/control/controller.py
@@ -428,17 +428,6 @@ class TestControl(unittest.TestCase):
     except ControllerError as exc:
       self.assertEqual('Unable to determine our own fingerprint: nope, too bad', str(exc))
 
-    get_info_mock.side_effect = [
-      '5AC9C5AA75BA1F18D8459B326B4B8111A856D290',
-      InvalidArguments(None, 'GETINFO request contained unrecognized keywords: ns/id/5AC9C5AA75BA1F18D8459B326B4B8111A856D290'),
-    ]
-
-    try:
-      self.controller.get_network_status()
-      self.fail("We should've raised an exception")
-    except DescriptorUnavailable as exc:
-      self.assertEqual("Tor was unable to provide the descriptor for '5AC9C5AA75BA1F18D8459B326B4B8111A856D290'", str(exc))
-
     self.assertEqual('boom', self.controller.get_network_status(default = 'boom'))
 
     # successful request
@@ -453,6 +442,20 @@ class TestControl(unittest.TestCase):
     self.assertEqual(stem.descriptor.router_status_entry.RouterStatusEntryV3(desc), self.controller.get_network_status())
 
   @patch('stem.control.Controller.get_info')
+  def test_get_network_status_when_raising_descriptor_unavailable(self, get_info_mock):
+    """
+    Exercises the get_network_status() method.
+    """
+
+    get_info_mock.side_effect = InvalidArguments(None, 'GETINFO request contained unrecognized keywords: ns/id/5AC9C5AA75BA1F18D8459B326B4B8111A856D290')
+
+    try:
+      self.controller.get_network_status('5AC9C5AA75BA1F18D8459B326B4B8111A856D290')
+      self.fail("We should've raised an exception")
+    except DescriptorUnavailable as exc:
+      self.assertEqual("Tor was unable to provide the descriptor for '5AC9C5AA75BA1F18D8459B326B4B8111A856D290'", str(exc))
+
+  @patch('stem.control.Controller.get_info')
   def test_get_network_status(self, get_info_mock):
     """
     Exercises the get_network_status() method.

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