Exemple #1
0
 def test_key_by_key_validator_date_parse_except_fail(self):
     library = APILibrary()
     unmatched = []
     library.key_by_key_validator({"a": "a"}, {"a": "b"},
                                  unmatched_keys_list=unmatched)
     assert unmatched == [('------------------\nKey: a', 'Expected: b',
                           'Actual: a')]
Exemple #2
0
 def test_key_by_key_validator_simple_value_fail(self):
     library = APILibrary()
     unmatched = []
     library.key_by_key_validator({"a": 2}, {"a": 1},
                                  unmatched_keys_list=unmatched)
     assert unmatched == [('------------------\nKey: a', 'Expected: 1',
                           'Actual: 2')]
Exemple #3
0
 def test_key_by_key_validator_list_int_fail(self):
     library = APILibrary()
     unmatched = []
     library.key_by_key_validator({"a": [1]}, {"a": [2]},
                                  unmatched_keys_list=unmatched)
     assert unmatched == [('------------------\nKey: a[0]', 'Expected: 2',
                           'Actual: 1')]
Exemple #4
0
 def test_key_by_key_validator_list_sort_nested_dict(self):
     library = APILibrary()
     library.key_by_key_validator({"value": [{
         "a": ["1", "2"]
     }]}, {"value": [{
         "a": ["2", "1"]
     }]},
                                  sort_lists=True)
Exemple #5
0
 def test_key_by_key_validator_list_list_embedded_list_fail(self):
     library = APILibrary()
     unmatched = []
     library.key_by_key_validator({"a": [[1], [2, [3]]]},
                                  {"a": [[1], [2, [7]]]},
                                  unmatched_keys_list=unmatched)
     assert unmatched == [('------------------\nKey: a[1][0]',
                           'Expected: 7', 'Actual: 3')]
Exemple #6
0
 def test_key_by_key_validator_simple_dict_multiple_values(self):
     library = APILibrary()
     library.key_by_key_validator({"a": {
         "b": 1,
         "c": 1
     }}, {"a": {
         "b": 1,
         "c": 1
     }})
Exemple #7
0
 def test_key_by_key_validator_list_dict_fail(self):
     library = APILibrary()
     unmatched = []
     library.key_by_key_validator({"a": [{
         "b": 3
     }]}, {"a": [{
         "b": 4
     }]},
                                  unmatched_keys_list=unmatched)
     assert unmatched == [('------------------\nKey: a[0].b', 'Expected: 4',
                           'Actual: 3')]
Exemple #8
0
 def test_key_by_key_validator_list_dict_embedded_list_fail(self):
     library = APILibrary()
     unmatched = []
     library.key_by_key_validator({"a": [{
         "b": [{
             "c": [4, 5]
         }]
     }]}, {"a": [{
         "b": [{
             "c": [5, 5]
         }]
     }]},
                                  unmatched_keys_list=unmatched)
     assert unmatched == [('------------------\nKey: a[0].b[0].c',
                           'Expected: 5', 'Actual: 4')]
Exemple #9
0
 def test_key_by_key_validator_partial_list(self):
     library = APILibrary()
     library.key_by_key_validator(
         {
             "result": {
                 "locations": [{
                     "name": "Loc-1",
                     "sys_id": "1"
                 }, {
                     "name": "Loc-2",
                     "sys_id": "2"
                 }]
             }
         }, {"result": {
             "locations": [{
                 "name": "Loc-1",
                 "sys_id": "1"
             }]
         }})
Exemple #10
0
 def test_key_by_key_validator_simple_dict(self):
     library = APILibrary()
     library.key_by_key_validator({"a":{"b":1}}, {"a":{"b":1}})
Exemple #11
0
 def test_key_by_key_validator_list_do_not_match(self, fail):
     library = APILibrary()
     library.key_by_key_validator({"a": ["1", "2"]}, {"a": ["1", "3"]})
     fail.assert_called_with("Arrays do not match:\nExpected: ['1', '3']\nActual: ['1', '2']")
Exemple #12
0
 def test_key_by_key_validator_list_not_same_length_fail(self, fail):
     library = APILibrary()
     library.key_by_key_validator({"a": ["1", "2"]}, {"a": ["1"]})
     fail.assert_called_with("Arrays not the same length:\nExpected: ['1']\nActual: ['1', '2']")
Exemple #13
0
 def test_key_by_key_validator_key_not_in_actual_fail(self, fail):
     library = APILibrary()
     library.key_by_key_validator({"b":2, "c":3}, {"a":1, "c":3})
     fail.assert_called_with("Key not found in Actual : {'b': 2, 'c': 3} Key: a")
Exemple #14
0
 def test_key_by_key_validator_simple_none_dict(self, fail):
     library = APILibrary()
     library.key_by_key_validator({"a":None}, {"a":{"b": "2"}})
     fail.assert_called_with("Dicts do not match:\nExpected: {'b': '2'}\nActual is not a valid dictionary.")
Exemple #15
0
 def test_key_by_key_validator_collection_len_fail(self, fail):
     library = APILibrary()
     library.key_by_key_validator([{"a":1}, {"b":2}], {"a":1})
     fail.assert_called_with('Collections not the same length:\nActual length: 2\nExpected length 1')
Exemple #16
0
 def test_key_by_key_validator_simple_date_parse_except(self):
     library = APILibrary()
     library.key_by_key_validator({"a":"a"}, {"a":"a"})
Exemple #17
0
 def test_key_by_key_validator_dict_len_fail(self, fail):
     library = APILibrary()
     library.key_by_key_validator({"a":{"b":1,"c":1}}, {"a":{"b":1}})
     fail.assert_called_with("Dicts do not match:\nExpected: {'b': 1}\nActual: {'b': 1, 'c': 1}")
Exemple #18
0
 def test_key_by_key_validator_list_do_not_match(self, fail):
     library = APILibrary()
     library.key_by_key_validator({"a": ["1", "2"]}, {"a": ["1", "3"]})
     fail.assert_called_with(
         "Arrays do not match:\nExpected: ['1', '3']\nActual: ['1', '2']\nIf this is simply out of order try 'sort_list=True'"
     )
Exemple #19
0
 def test_key_by_key_validator_simple_date(self):
     library = APILibrary()
     library.key_by_key_validator({"a":"2017-08-08T05:05:05"}, {"a":"2017-08-08T05:05:05"})
Exemple #20
0
 def test_key_by_key_validator_simple_list_multiple_values(self):
     library = APILibrary()
     library.key_by_key_validator({"a":["1", "2"]}, {"a":["1", "2"]})
Exemple #21
0
 def test_key_by_key_validator_simple(self):
     library = APILibrary()
     library.key_by_key_validator({"a":1}, {"a":1})
Exemple #22
0
 def test_key_by_key_validator_list_int(self):
     library = APILibrary()
     library.key_by_key_validator({"a":[1]}, {"a":[1]})
Exemple #23
0
 def test_key_by_key_validator_simple_list(self):
     library = APILibrary()
     library.key_by_key_validator({"a":["1"]}, {"a":["1"]})
Exemple #24
0
 def test_key_by_key_validator_simple_ignored_key(self):
     library = APILibrary()
     library.key_by_key_validator({"a":["1"]}, {"a":["1"]}, ["a"])