[tor-commits] [stem/master] Test that the Query class' 'start' argument works
atagar at torproject.org
atagar at torproject.org
Sun Nov 8 01:24:38 UTC 2020
commit bb0d68bee8477f3963dbbfef9a2713e30bed85e7
Author: Damian Johnson <atagar at torproject.org>
Date: Sat Oct 31 14:22:27 2020 -0700
Test that the Query class' 'start' argument works
Reading our Query class I became worried that our 'start' argument fails to get
honored because the start() method is asynchronous (so its invocation returns a
coroutine rather than running it).
I was wrong. It works because as a Synchronous subclass our metaprogramming
converts the call. That said, this is none the less a good thing to check.
---
test/unit/descriptor/remote.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/test/unit/descriptor/remote.py b/test/unit/descriptor/remote.py
index 7447fd16..58c7276a 100644
--- a/test/unit/descriptor/remote.py
+++ b/test/unit/descriptor/remote.py
@@ -78,6 +78,21 @@ class TestDescriptorDownloader(unittest.TestCase):
# prevent our mocks from impacting other tests
stem.descriptor.remote.SINGLETON_DOWNLOADER = None
+ @mock_download(TEST_DESCRIPTOR)
+ def test_initial_startup(self):
+ """
+ Check that the query can begin downloading in the background when first
+ constructed.
+ """
+
+ query = stem.descriptor.remote.get_server_descriptors('9695DFC35FFEB861329B9F1AB04C46397020CE31', start = False)
+ self.assertTrue(query._downloader_task is None)
+ query.stop()
+
+ query = stem.descriptor.remote.get_server_descriptors('9695DFC35FFEB861329B9F1AB04C46397020CE31', start = True)
+ self.assertTrue(query._downloader_task is not None)
+ query.stop()
+
@mock_download(TEST_DESCRIPTOR)
def test_download(self):
"""
More information about the tor-commits
mailing list