summaryrefslogtreecommitdiff
path: root/tests.py
diff options
context:
space:
mode:
authorStefan Kögl <stefan@skoegl.net>2012-09-28 19:01:27 +0200
committerStefan Kögl <stefan@skoegl.net>2012-09-28 19:06:08 +0200
commit33ad0dc629b7802fa084afa2a23a9599c224fc40 (patch)
treeb703f489fbb76f297d82ed50edf0e248dbf0fccd /tests.py
parentd935044158c3bdcd2ca1014166d7ca323cd57c27 (diff)
downloadpython-json-patch-33ad0dc629b7802fa084afa2a23a9599c224fc40.tar.gz
implement __has__, __eq__ for JsonPatch, PatchOperation
Diffstat (limited to 'tests.py')
-rwxr-xr-xtests.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/tests.py b/tests.py
index 72fa584..6268f39 100755
--- a/tests.py
+++ b/tests.py
@@ -137,6 +137,21 @@ class ApplyPatchTestCase(unittest.TestCase):
+class EqualityTestCase(unittest.TestCase):
+
+ def test_patch_equality(self):
+ patch1 = jsonpatch.JsonPatch([{ "op": "add", "path": "/a/b/c", "value": "foo" }])
+ patch2 = jsonpatch.JsonPatch([{ "path": "/a/b/c", "op": "add", "value": "foo" }])
+ self.assertEqual(patch1, patch2)
+
+
+ def test_patch_unequal(self):
+ patch1 = jsonpatch.JsonPatch([{'op': 'test', 'path': '/test'}])
+ patch2 = jsonpatch.JsonPatch([{'op': 'test', 'path': '/test1'}])
+ self.assertNotEqual(patch1, patch2)
+
+
+
class MakePatchTestCase(unittest.TestCase):
@@ -201,6 +216,7 @@ def suite():
suite = unittest.TestSuite()
suite.addTest(doctest.DocTestSuite(jsonpatch))
suite.addTest(unittest.makeSuite(ApplyPatchTestCase))
+ suite.addTest(unittest.makeSuite(EqualityTestCase))
suite.addTest(unittest.makeSuite(MakePatchTestCase))
return suite