Example #1
0
    def test_ValidJSONs(self):
        differ = Differ()

        #Empty jsons must fail the validation
        self.assertEqual(differ.isLeftValid(),"false", "Expected left invalid when empty")
        self.assertEqual(differ.isRightValid(), "false", "Expected right invalid when empty")

        #Invalid jsons must fail the validation
        differ.left = invalidJSON
        differ.right = invalidJSON
        self.assertEqual(differ.isLeftValid(), "false", "Expected left invalid")
        self.assertEqual(differ.isRightValid(), "false", "Expected right invalid")

        #Valid jsons must pass the validation
        differ.left = validJSON
        differ.right = validJSON
        self.assertEqual(differ.isLeftValid(), "true", "Expected left valid")
        self.assertEqual(differ.isRightValid(), "true", "Expected right valid")
Example #2
0
    def test_Diffs(self):
        differ = Differ()

        #Test equal content
        differ.left = validJSON
        differ.right = validJSON
        self.assertIn("left and right are equal", differ.Diff(), "Expected equal content")

        #Test diff size
        differ.left = validJSON
        differ.right = validJSONDiffSize
        self.assertIn("sizes are different", differ.Diff(), "Expected different size")

        #Test same size diff contents
        differ.left = validJSON
        differ.right = validJSON2
        self.assertIn("Sizes are equal but contents different", differ.Diff(), "Expected different contents")
        self.assertIn("offset", differ.Diff(), "Expected different contents")
Example #3
0
    def test_getState(self):

        differ = Differ()

        differ.left=""
        differ.right=""
        self.assertEqual(differ.getState(), "22", "Expected getState 22")

        differ.left=""
        differ.right=invalidJSON
        self.assertEqual(differ.getState(), "21", "Expected getState 21")

        differ.left=""
        differ.right=validJSON
        self.assertEqual(differ.getState(), "20", "Expected getState 20")

        differ.left=invalidJSON
        differ.right=""
        self.assertEqual(differ.getState(), "12", "Expected getState 12")

        differ.left=invalidJSON
        differ.right=invalidJSON
        self.assertEqual(differ.getState(),"11", "Expected getState 11")

        differ.left=invalidJSON
        differ.right=validJSON
        self.assertEqual(differ.getState(),"10", "Expected getState 10")

        differ.left=validJSON
        differ.right=""
        self.assertEqual(differ.getState(),"02", "Expected getState 02")

        differ.left=validJSON
        differ.right=invalidJSON
        self.assertEqual(differ.getState(), "01", "Expected getState 01")

        differ.left=validJSON
        differ.right=validJSON
        self.assertEqual(differ.getState(), "00", "Expected getState 00")