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

[tor-commits] [bridgedb/develop] Add additional unittests for bridgedb.parse.descriptors module.



commit 2a2c57acf68b1cd4a453823cdf746867bbb18381
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
Date:   Sun Jul 6 19:19:32 2014 +0000

    Add additional unittests for bridgedb.parse.descriptors module.
---
 lib/bridgedb/test/test_parse_descriptors.py |   37 +++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/lib/bridgedb/test/test_parse_descriptors.py b/lib/bridgedb/test/test_parse_descriptors.py
index c085a9c..7c4fc93 100644
--- a/lib/bridgedb/test/test_parse_descriptors.py
+++ b/lib/bridgedb/test/test_parse_descriptors.py
@@ -150,3 +150,40 @@ class ParseDescriptorsTests(unittest.TestCase):
         self.assertEqual(bridge.address, u'152.78.9.20')
         self.assertEqual(bridge.fingerprint,
                          u'6FA9216CF3A06E89A03121ACC31F70F8DFD7DDCC')
+
+    def test_parse_descriptors_parseBridgeNetworkStatusFile(self):
+        """Test for ``b.p.descriptors.parseNetworkStatusFile``."""
+        descFile = io.BytesIO(BRIDGE_NETWORKSTATUS)
+        routers = descriptors.parseNetworkStatusFile(descFile)
+        self.assertIsInstance(routers, list)
+        bridge = routers[0]
+        self.assertIsInstance(bridge, RelayDescriptor)
+        self.assertEqual(bridge.address, u'152.78.9.20')
+        self.assertEqual(bridge.fingerprint,
+                         u'6FA9216CF3A06E89A03121ACC31F70F8DFD7DDCC')
+
+    def test_parse_descriptors_parseBridgeExtraInfoFiles_one_file(self):
+        """Test for ``b.p.descriptors.parseBridgeExtraInfoFiles`` with only one
+        bridge extrainfo file."""
+        descFile = io.BytesIO(BRIDGE_EXTRA_INFO_DESCRIPTOR)
+        routers = descriptors.parseBridgeExtraInfoFiles(descFile)
+        self.assertIsInstance(routers, list)
+        bridge = routers[0]
+        self.assertIsInstance(bridge, BridgeExtraInfoDescriptor)
+        self.assertEqual(bridge.address, u'152.78.9.20')
+        self.assertEqual(bridge.fingerprint,
+                         u'6FA9216CF3A06E89A03121ACC31F70F8DFD7DDCC')
+
+    def test_parse_descriptors_parseBridgeExtraInfoFiles_two_files(self):
+        """Test for ``b.p.descriptors.parseBridgeExtraInfoFiles`` with two
+        bridge extrainfo files, and check that only the newest extrainfo
+        descriptor is used."""
+        descFileOne = io.BytesIO(BRIDGE_EXTRA_INFO_DESCRIPTOR)
+        descFileTwo = io.BytesIO(BRIDGE_EXTRA_INFO_DESCRIPTOR_NEWER_DUPLICATE)
+        routers = descriptors.parseBridgeExtraInfoFiles(descFileOne, descFileTwo)
+        self.assertIsInstance(routers, list)
+        bridge = routers[0]
+        self.assertIsInstance(bridge, BridgeExtraInfoDescriptor)
+        self.assertEqual(bridge.address, u'152.78.9.20')
+        self.assertEqual(bridge.fingerprint,
+                         u'6FA9216CF3A06E89A03121ACC31F70F8DFD7DDCC')



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