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

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



commit b2cf76cb0cc69e16dfd34eec618262e4ac227f15
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Sep 27 16:08:49 2020 -0700

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

diff --git a/test/unit/examples.py b/test/unit/examples.py
index 9250280e..a117bb24 100644
--- a/test/unit/examples.py
+++ b/test/unit/examples.py
@@ -19,7 +19,7 @@ from stem.control import Controller
 from stem.descriptor.bandwidth_file import BandwidthFile
 from stem.descriptor.extrainfo_descriptor import RelayExtraInfoDescriptor
 from stem.descriptor.networkstatus import NetworkStatusDocumentV3
-from stem.descriptor.router_status_entry import RouterStatusEntryV3
+from stem.descriptor.router_status_entry import RouterStatusEntryV2, RouterStatusEntryV3
 from stem.descriptor.server_descriptor import RelayDescriptor
 from stem.directory import DIRECTORY_AUTHORITIES
 from stem.exit_policy import ExitPolicy
@@ -383,8 +383,16 @@ class TestExamples(unittest.TestCase):
   def test_create_descriptor_content(self):
     pass
 
-  def test_current_descriptors(self):
-    pass
+  @patch('stem.descriptor.remote.DescriptorDownloader')
+  @patch('sys.stdout', new_callable = io.StringIO)
+  def test_current_descriptors(self, stdout_mock, downloader_mock):
+    downloader_mock().get_consensus.return_value = [RouterStatusEntryV2.create({
+      'r': 'caerSidi p1aag7VwarGxqctS7/fS0y5FU+s oQZFLYe9e4A7bOkWKR7TaNxb0JE 2012-08-06 11:19:31 71.35.150.29 9001 0',
+    })]
+
+    import current_descriptors
+
+    self.assertEqual('found relay caerSidi (A7569A83B5706AB1B1A9CB52EFF7D2D32E4553EB)\n', stdout_mock.getvalue())
 
   def test_custom_path_selection(self):
     pass
diff --git a/test/unit/tutorial.py b/test/unit/tutorial.py
index 92793afe..90dfc661 100644
--- a/test/unit/tutorial.py
+++ b/test/unit/tutorial.py
@@ -112,16 +112,6 @@ class TestTutorial(unittest.TestCase):
 
     self.assertEqual(OVER_THE_RIVER_OUTPUT, stdout_mock.getvalue())
 
-  @patch('sys.stdout', new_callable = io.StringIO)
-  @patch('stem.descriptor.remote.DescriptorDownloader')
-  def test_mirror_mirror_on_the_wall_1(self, downloader_mock, stdout_mock):
-    downloader_mock().get_consensus.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('current_descriptors.py')
-    self.assertEqual('found relay caerSidi (A7569A83B5706AB1B1A9CB52EFF7D2D32E4553EB)\n', 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):



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