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

[tor-commits] [stem/master] Move descriptor_from_tor_control_socket test



commit 21725bd2f4efcb16f5300b2a9370a8817226a0d3
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Sep 27 16:11:42 2020 -0700

    Move descriptor_from_tor_control_socket test
---
 test/unit/examples.py | 13 +++++++++++--
 test/unit/tutorial.py | 13 +------------
 2 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/test/unit/examples.py b/test/unit/examples.py
index a117bb24..5b56261e 100644
--- a/test/unit/examples.py
+++ b/test/unit/examples.py
@@ -400,8 +400,17 @@ class TestExamples(unittest.TestCase):
   def test_descriptor_from_orport(self):
     pass
 
-  def test_descriptor_from_tor_control_socket(self):
-    pass
+  @patch('stem.control.Controller.from_port', spec = Controller)
+  @patch('sys.stdout', new_callable = io.StringIO)
+  def test_descriptor_from_tor_control_socket(self, stdout_mock, from_port_mock):
+    controller = from_port_mock().__enter__()
+    controller.get_network_statuses.return_value = [RouterStatusEntryV2.create({
+      'r': 'caerSidi p1aag7VwarGxqctS7/fS0y5FU+s oQZFLYe9e4A7bOkWKR7TaNxb0JE 2012-08-06 11:19:31 71.35.150.29 9001 0',
+    })]
+
+    import descriptor_from_tor_control_socket
+
+    self.assertEqual('found relay caerSidi (A7569A83B5706AB1B1A9CB52EFF7D2D32E4553EB)\n', stdout_mock.getvalue())
 
   def test_descriptor_from_tor_data_directory(self):
     pass
diff --git a/test/unit/tutorial.py b/test/unit/tutorial.py
index 90dfc661..d1093bd5 100644
--- a/test/unit/tutorial.py
+++ b/test/unit/tutorial.py
@@ -12,7 +12,7 @@ import test
 from unittest.mock import Mock, patch
 
 from stem.control import Controller
-from stem.descriptor.router_status_entry import RouterStatusEntryV2, RouterStatusEntryV3
+from stem.descriptor.router_status_entry import RouterStatusEntryV3
 from stem.descriptor.networkstatus import NetworkStatusDocumentV3
 from stem.descriptor.server_descriptor import RelayDescriptor
 from stem.exit_policy import ExitPolicy
@@ -112,17 +112,6 @@ class TestTutorial(unittest.TestCase):
 
     self.assertEqual(OVER_THE_RIVER_OUTPUT, stdout_mock.getvalue())
 
-  @patch('sys.stdout', new_callable = io.StringIO)
-  @patch('stem.control.Controller.from_port', spec = Controller)
-  def test_mirror_mirror_on_the_wall_2(self, from_port_mock, stdout_mock):
-    controller = from_port_mock().__enter__()
-    controller.get_network_statuses.return_value = [RouterStatusEntryV2.create({
-      'r': 'caerSidi p1aag7VwarGxqctS7/fS0y5FU+s oQZFLYe9e4A7bOkWKR7TaNxb0JE 2012-08-06 11:19:31 71.35.150.29 9001 0',
-    })]
-
-    exec_documentation_example('descriptor_from_tor_control_socket.py')
-    self.assertEqual('found relay caerSidi (A7569A83B5706AB1B1A9CB52EFF7D2D32E4553EB)\n', stdout_mock.getvalue())
-
   @patch('sys.stdout', new_callable = io.StringIO)
   @patch('%s.open' % __name__, create = True)
   def test_mirror_mirror_on_the_wall_3(self, open_mock, stdout_mock):



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