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

[tor-commits] [stem/master] Fix typo in NYI Exception text



commit e779257c7e7c7cbe630d84e2e46341e7f8b4a16d
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date:   Sat May 26 22:02:45 2018 +0000

    Fix typo in NYI Exception text
    
    Also add test for this text and refactor existing test for other NYI
    text, since eventually that Cell will get implemented.
---
 stem/client/cell.py      |  2 +-
 test/unit/client/cell.py | 13 +++++++++++--
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/stem/client/cell.py b/stem/client/cell.py
index 7e3e78ef..a679968e 100644
--- a/stem/client/cell.py
+++ b/stem/client/cell.py
@@ -114,7 +114,7 @@ class Cell(object):
     raise ValueError("'%s' isn't a valid cell value" % value)
 
   def pack(self, link_protocol):
-    raise NotImplementedError('Unpacking not yet implemented for %s cells' % type(self).NAME)
+    raise NotImplementedError('Packing not yet implemented for %s cells' % type(self).NAME)
 
   @staticmethod
   def unpack(content, link_protocol):
diff --git a/test/unit/client/cell.py b/test/unit/client/cell.py
index 2123cd6f..2fe05369 100644
--- a/test/unit/client/cell.py
+++ b/test/unit/client/cell.py
@@ -102,8 +102,17 @@ class TestCell(unittest.TestCase):
     self.assertRaises(ValueError, Cell.by_value, 85)
     self.assertRaises(ValueError, Cell.by_value, None)
 
-  def test_unpack_not_implemented(self):
-    self.assertRaisesRegexp(NotImplementedError, 'Unpacking not yet implemented for AUTHORIZE cells', Cell.pop, b'\x00\x00\x84\x00\x06\x00\x01\x00\x02\x00\x03', 2)
+  def test_unimplemented_cell_methods(self):
+    class UnimplementedCell(Cell):
+      NAME = 'UNIMPLEMENTED'
+
+    instance = UnimplementedCell()
+
+    self.assertRaisesRegexp(NotImplementedError, '^%s$' % re.escape('Packing not yet implemented for UNIMPLEMENTED cells'), instance.pack, 2)
+
+    # ideally we'd test unpacking with Cell.pop(), but that would mean monkey-patching for Cell.pop() to see this UnimplementedCell
+    # that's probably not worth it; instead we'll use the instance method _unpack()
+    self.assertRaisesRegexp(NotImplementedError, '^%s$' % re.escape('Unpacking not yet implemented for UNIMPLEMENTED cells'), instance._unpack, b'dummy', 0, 2)
 
   def test_unpack_for_new_link(self):
     expected_certs = (



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