Skip to content

Commit

Permalink
Mark OpReverse as pending depreciation
Browse files Browse the repository at this point in the history
  • Loading branch information
petertodd committed Sep 5, 2016
1 parent 1d7de29 commit ff2ab8a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
2 changes: 2 additions & 0 deletions opentimestamps/core/op.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class OpReverse(UnaryOp):
TAG_NAME = 'reverse'

def __call__(self, msg):
import warnings
warnings.warn("OpReverse may get removed; see https://github.com/opentimestamps/python-opentimestamps/issues/5", PendingDeprecationWarning)
return msg[::-1]


Expand Down
6 changes: 3 additions & 3 deletions opentimestamps/tests/core/test_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ def test_prepend(self):
"""Prepend operation"""
self.assertEqual(OpPrepend(b'prefix')(b'msg'), b'prefixmsg')

def test_reverse(self):
"""Reverse operation"""
self.assertEqual(OpReverse()(b'abcd'), b'dcba')
# def test_reverse(self):
# """Reverse operation"""
# self.assertEqual(OpReverse()(b'abcd'), b'dcba')

def test_sha256(self):
"""SHA256 operation"""
Expand Down
14 changes: 7 additions & 7 deletions opentimestamps/tests/core/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ class Test_Timestamp(unittest.TestCase):
def test_add_op(self):
"""Adding operations to timestamps"""
t = Timestamp(b'abcd')
t.ops.add(OpReverse())
self.assertEqual(t.ops[OpReverse()], Timestamp(b'dcba'))
t.ops.add(OpAppend(b'efgh'))
self.assertEqual(t.ops[OpAppend(b'efgh')], Timestamp(b'abcdefgh'))

# The second add should succeed
t.ops.add(OpReverse())
self.assertEqual(t.ops[OpReverse()], Timestamp(b'dcba'))
# The second add should succeed with the timestamp unchanged
t.ops.add(OpAppend(b'efgh'))
self.assertEqual(t.ops[OpAppend(b'efgh')], Timestamp(b'abcdefgh'))

def test_set_result_timestamp(self):
"""Setting an op result timestamp"""
Expand All @@ -42,10 +42,10 @@ def test_set_result_timestamp(self):
def test_set_fail_if_wrong_message(self):
"""Setting an op result timestamp fails if the messages don't match"""
t = Timestamp(b'abcd')
t.ops.add(OpReverse())
t.ops.add(OpSHA256())

with self.assertRaises(ValueError):
t.ops[OpReverse()] = Timestamp(b'wrong')
t.ops[OpSHA256()] = Timestamp(b'wrong')

def test_merge(self):
"""Merging timestamps"""
Expand Down

0 comments on commit ff2ab8a

Please sign in to comment.