commit 992c94bc6065cee6281266df6e482a6367dd56c6 Author: Damian Johnson atagar@torproject.org Date: Sun Oct 13 16:39:28 2013 -0700
Fixing AttributeError in use_directory_mirrors()
Correcting a couple issues, one in the tests and another in the remote descriptor module, causing integ failures.
====================================================================== ERROR: test_use_directory_mirrors ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/stem/test/integ/descriptor/remote.py", line 62, in test_use_directory_mirrors downloader.use_directory_mirrors() File "/home/atagar/Desktop/stem/stem/descriptor/remote.py", line 419, in use_directory_mirrors if Flag.V2DIR in desc.flags: AttributeError: 'str' object has no attribute 'flags'
====================================================================== ERROR: test_using_authorities ---------------------------------------------------------------------- Traceback (most recent call last): File "/home/atagar/Desktop/stem/test/integ/descriptor/remote.py", line 34, in test_using_authorities for authority, (address, dirport) in stem.descriptor.remote.DIRECTORY_AUTHORITIES.items(): --- stem/descriptor/remote.py | 2 +- test/integ/descriptor/remote.py | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/stem/descriptor/remote.py b/stem/descriptor/remote.py index 4b04767..aa4d00c 100644 --- a/stem/descriptor/remote.py +++ b/stem/descriptor/remote.py @@ -415,7 +415,7 @@ class DescriptorDownloader(object):
consensus = list(self.get_consensus(document_handler = stem.descriptor.DocumentHandler.DOCUMENT).run())[0]
- for desc in consensus.routers: + for desc in consensus.routers.values(): if Flag.V2DIR in desc.flags: new_endpoints.add((desc.address, desc.dir_port))
diff --git a/test/integ/descriptor/remote.py b/test/integ/descriptor/remote.py index d11a4ae..27062ea 100644 --- a/test/integ/descriptor/remote.py +++ b/test/integ/descriptor/remote.py @@ -31,19 +31,19 @@ class TestDescriptorDownloader(unittest.TestCase):
queries = []
- for authority, (address, dirport) in stem.descriptor.remote.DIRECTORY_AUTHORITIES.items(): - queries.append(stem.descriptor.remote.Query( + for nickname, authority in stem.descriptor.remote.get_authorities().items(): + queries.append((stem.descriptor.remote.Query( '/tor/server/fp/9695DFC35FFEB861329B9F1AB04C46397020CE31', 'server-descriptor 1.0', - endpoints = [(address, dirport)], + endpoints = [(authority.address, authority.dir_port)], timeout = 30, - )) + ), authority))
- for query in queries: + for query, authority in queries: try: descriptors = list(query.run()) except Exception as exc: - self.fail("Unable to use %s (%s:%s, %s): %s" % (authority, address, dirport, type(exc), exc)) + self.fail("Unable to use %s (%s:%s, %s): %s" % (authority.nickname, authority.address, authority.dir_port, type(exc), exc))
self.assertEqual(1, len(descriptors)) self.assertEqual('moria1', descriptors[0].nickname)
tor-commits@lists.torproject.org