Exemplo n.º 1
0
 def test_nested_list_order_inner_val_sensitivity_false(self):
     a = {
         "failureReason" : "Invalid request entity",
         "fieldValidationErrors" : [
             {
                 "field" : "Catalog.catalogOwner",
                 "reason" : "may not be smelly"
             },
             {
                 "field" : "Catalog.name",
                 "reason" : "may not be null"
             }
         ]
     }
     b = {
         "failureReason" : "Invalid request entity",
         "fieldValidationErrors" : [
             {
                 "field" : "Catalog.name",
                 "reason" : "may not be null"
             },
             {
                 "field" : "Catalog.catalogOwner",
                 "reason" : "may not be null"
             }
         ]
     }
     self.assertFalse(jsoncompare.are_same(a, b, True)[0])
Exemplo n.º 2
0
 def test_list_of_hashes_ignore_key(self):
     a = [
         {"wtf1": "omg1"},
         {"wtf2": "omg"}
     ]
     b = [
         {"wtf1": "omg1"},
         {"wtf2": "omg3"}
     ]
     self.assertTrue(jsoncompare.are_same(a, b, True, ["wtf2"])[0])
Exemplo n.º 3
0
 def test_list_of_hashes_unordered_fail(self):
     a = [
         {"wtf1": "omg1"},
         {"wtf": "omg"}
     ]
     b = [
         {"wtf": "omg"},
         {"wtf1": "omg1"}
     ]
     self.assertFalse(jsoncompare.are_same(a, b)[0])
Exemplo n.º 4
0
 def test_list_of_hashes_unordered(self):
     a = [
         {"wtf1": "omg1"},
         {"wtf": "omg"}
     ]
     b = [
         {"wtf": "omg"},
         {"wtf1": "omg1"}
     ]
     self.assertTrue(jsoncompare.are_same(a, b, True)[0])
Exemplo n.º 5
0
 def test_hash_vs_list_fail(self):
     a = {
         "wtf": [
             {"wtf1": "omg1"},
             {"wtf": "omg"}
         ]
     }
     b = [
         {"wtf1": "omg1"}
     ]
     self.assertFalse(jsoncompare.are_same(a, b)[0])
Exemplo n.º 6
0
 def test_inner_val_sensitivity_false(self):
     a = {
         "failureReason":
         "Invalid request entity",
         "fieldValidationErrors": [{
             "field": "Catalog.catalogOwner",
             "reason": "may not be smelly"
         }, {
             "field": "Catalog.name",
             "reason": "may not be null"
         }]
     }
     b = {
         "failureReason":
         "Invalid request entity",
         "fieldValidationErrors": [{
             "field": "Catalog.catalogOwner",
             "reason": "may not be null"
         }, {
             "field": "Catalog.name",
             "reason": "may not be null"
         }]
     }
     self.assertFalse(jsoncompare.are_same(a, b, True)[0])
Exemplo n.º 7
0
 def test_nested_list_order_sensitivity(self):
     a = {
         "failureReason":
         "Invalid request entity",
         "fieldValidationErrors": [{
             "field": "Catalog.catalogOwner",
             "reason": "may not be null"
         }, {
             "field": "Catalog.name",
             "reason": "may not be null"
         }]
     }
     b = {
         "failureReason":
         "Invalid request entity",
         "fieldValidationErrors": [{
             "field": "Catalog.name",
             "reason": "may not be null"
         }, {
             "field": "Catalog.catalogOwner",
             "reason": "may not be null"
         }]
     }
     self.assertTrue(jsoncompare.are_same(a, b, True)[0])
Exemplo n.º 8
0
import json, sys
import jsoncompare
import ast


if len(sys.argv) < 3:
  sys.exit('Error')
json1 = json.loads(open(sys.argv[1],'r').read())
json2 = json.loads(open(sys.argv[2],'r').read())

ignoredKeys = ["@schema"]

try:
    ignoredKeys += ast.literal_eval(sys.argv[3])
except IndexError:
    pass

json2 = json.loads(open(sys.argv[2],'r').read())

(check,stack) = jsoncompare.are_same(json1,json2,
                                     ignore_list_order_recursively=False,
                                     ignore_missing_keys=False,
                                     ignore_value_of_keys=ignoredKeys)

if not check:
  print stack
  sys.exit(1)
Exemplo n.º 9
0
 def test_list_vs_hash_fail(self):
     a = [{"wtf1": "omg1"}]
     b = {"wtf": [{"wtf1": "omg1"}, {"wtf": "omg"}]}
     self.assertFalse(jsoncompare.are_same(a, b)[0])
Exemplo n.º 10
0
 def test_hash_list_of_hashes_unordered_fail(self):
     a = {"wtf": [{"wtf1": "omg1"}, {"wtf": "omg"}]}
     b = {"wtf": [{"wtf": "omg"}, {"wtf1": "omg1"}]}
     self.assertFalse(jsoncompare.are_same(a, b)[0])
Exemplo n.º 11
0
 def test_hash_list_of_hashes_unordered(self):
     a = {"wtf": [{"wtf1": "omg1"}, {"wtf": "omg"}]}
     b = {"wtf": [{"wtf": "omg"}, {"wtf1": "omg1"}]}
     self.assertTrue(jsoncompare.are_same(a, b, True)[0])
Exemplo n.º 12
0
 def test_list_of_hashes_ignore_key(self):
     a = [{"wtf1": "omg1"}, {"wtf2": "omg"}]
     b = [{"wtf1": "omg1"}, {"wtf2": "omg3"}]
     self.assertTrue(jsoncompare.are_same(a, b, True, ["wtf2"])[0])
Exemplo n.º 13
0
 def test_list_of_hashes(self):
     a = [{"wtf": "omg"}, {"wtf1": "omg1"}]
     b = [{"wtf": "omg"}, {"wtf1": "omg1"}]
     self.assertTrue(jsoncompare.are_same(a, b)[0])
Exemplo n.º 14
0
#!/usr/bin/env python

import jsoncompare

a = {
    "failureReason":
    "Invalid request entity",
    "fieldValidationErrors": [{
        "field": "normal value 1",
        "reason": "may not be smelly"
    }, {
        "field": "Catalog.name",
        "reason": "may not be null"
    }]
}
b = {
    "failureReason":
    "Invalid request entity",
    "fieldValidationErrors": [{
        "field": "crazy value 2",
        "reason": "may not be null"
    }, {
        "field": "Catalog.catalogOwner",
        "reason": "may not be null"
    }]
}
print jsoncompare.are_same(a, b)[1]
Exemplo n.º 15
0
import jsoncompare

a = {
    "failureReason" : "Invalid request entity",
    "fieldValidationErrors" : [
        {
            "field" : "normal value 1",
            "reason" : "may not be smelly"
        },
        {
            "field" : "Catalog.name",
            "reason" : "may not be null"
        }
    ]
}
b = {
    "failureReason" : "Invalid request entity",
    "fieldValidationErrors" : [
        {
            "field" : "crazy value 2",
            "reason" : "may not be null"
        },
        {
            "field" : "Catalog.catalogOwner",
            "reason" : "may not be null"
        }
    ]
}
print jsoncompare.are_same(a, b)[1]
Exemplo n.º 16
0
 def test_hash_vs_list_size_fail(self):
     a = {"wtf": [{"wtf1": "omg1"}, {"wtf": "omg"}]}
     b = [{"wtf": "omg"}, {"wtf1": "omg1"}]
     self.assertFalse(jsoncompare.are_same(a, b)[0])
Exemplo n.º 17
0
import json, sys
import jsoncompare

if len(sys.argv) != 3:
    sys.exit('Error')
json1 = json.loads(open(sys.argv[1], 'r').read())
json2 = json.loads(open(sys.argv[2], 'r').read())

(check, stack) = jsoncompare.are_same(json1,
                                      json2,
                                      ignore_list_order_recursively=True,
                                      ignore_missing_keys=True,
                                      ignore_value_of_keys=["@schema"])

if not check:
    print stack
    sys.exit(1)
Exemplo n.º 18
0
import json, sys
import jsoncompare
import ast

if len(sys.argv) < 3:
    sys.exit('Error')
json1 = json.loads(open(sys.argv[1], 'r').read())
json2 = json.loads(open(sys.argv[2], 'r').read())

ignoredKeys = ["@schema"]

try:
    ignoredKeys += ast.literal_eval(sys.argv[3])
except IndexError:
    pass

json2 = json.loads(open(sys.argv[2], 'r').read())

(check, stack) = jsoncompare.are_same(json1,
                                      json2,
                                      ignore_list_order_recursively=False,
                                      ignore_missing_keys=False,
                                      ignore_value_of_keys=ignoredKeys)

if not check:
    print(stack)
    sys.exit(1)