[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Test saving_and_loading_descriptors example
commit 950d26d7ea8df575499def8ba1e948a547b6af65
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Fri Oct 2 12:39:45 2020 -0700
Test saving_and_loading_descriptors example
---
docs/_static/example/saving_and_loading_descriptors.py | 2 +-
test/unit/examples.py | 12 +++++++++++-
2 files changed, 12 insertions(+), 2 deletions(-)
diff --git a/docs/_static/example/saving_and_loading_descriptors.py b/docs/_static/example/saving_and_loading_descriptors.py
index 42e3ffe1..9112360a 100644
--- a/docs/_static/example/saving_and_loading_descriptors.py
+++ b/docs/_static/example/saving_and_loading_descriptors.py
@@ -2,5 +2,5 @@ import stem.descriptor.remote
server_descriptors = stem.descriptor.remote.get_server_descriptors().run()
-with open('/tmp/descriptor_dump', 'wb') as descriptor_file:
+with open('/tmp/descriptor_dump', 'w') as descriptor_file:
descriptor_file.write(''.join(map(str, server_descriptors)))
diff --git a/test/unit/examples.py b/test/unit/examples.py
index 0b66c124..73bae36c 100644
--- a/test/unit/examples.py
+++ b/test/unit/examples.py
@@ -918,7 +918,17 @@ class TestExamples(unittest.TestCase):
sys.modules = original_modules
def test_saving_and_loading_descriptors(self):
- pass
+ server_desc = RelayDescriptor.create({'router': 'caerSidi 71.35.133.197 9001 0 0'})
+
+ with patch('stem.descriptor.remote.get_server_descriptors', _download_of(server_desc)):
+ try:
+ import saving_and_loading_descriptors
+
+ with open('/tmp/descriptor_dump') as descriptor_file:
+ self.assertTrue(descriptor_file.read().startswith('router caerSidi 71.35.133.197'))
+ finally:
+ if os.path.exists('/tmp/descriptor_dump'):
+ os.remove('/tmp/descriptor_dump')
def test_slow_listener(self):
pass
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits