Exemplo n.º 1
0
    def should_pass():
        child = {}
        parent = {'children': [child]}
        child['parent'] = parent

        my_object = {'a': 1, 'b': 'two', 'c': parent}
        assert contain_subset(my_object, {'a': 1, 'c': parent})
Exemplo n.º 2
0
    def should_pass():
        child = {}
        parent = {"children": [child]}
        child["parent"] = parent

        my_object = {"a": 1, "b": "two", "c": parent}
        assert contain_subset(my_object, {"a": 1, "c": parent})
Exemplo n.º 3
0
 def should_pass_for_smaller_object_2():
     assert contain_subset(tested_object,
                           {'e': {
                               'foo': 'bar',
                               'baz': {
                                   'qux': 'quux'
                               }
                           }})
Exemplo n.º 4
0
 def should_pass_for_similar_but_not_the_same_object():
     assert not contain_subset(
         tested_object, {"e": {
             "foo": "bar",
             "baz": {
                 "qux": "notAQuux"
             }
         }})
Exemplo n.º 5
0
 def should_pass_for_smaller_object_2():
     assert contain_subset(tested_object,
                           {"e": {
                               "foo": "bar",
                               "baz": {
                                   "qux": "quux"
                               }
                           }})
Exemplo n.º 6
0
 def should_pass_for_similar_but_not_the_same_object():
     assert not contain_subset(
         tested_object, {'e': {
             'foo': 'bar',
             'baz': {
                 'qux': 'notAQuux'
             }
         }})
Exemplo n.º 7
0
 def should_pass_for_same_object():
     assert contain_subset(tested_object, {
         'a': 'b',
         'c': 'd',
         'e': {
             'foo': 'bar',
             'baz': {
                 'qux': 'quux'
             }
         }
     })
Exemplo n.º 8
0
 def should_contain_subdocument(test_object):
     assert contain_subset(
         test_object,
         {'arr': [{
             'arr': []
         }, {
             'arr': []
         }, [{
             'arr': []
         }, {
             'arr': []
         }]]})
Exemplo n.º 9
0
 def should_not_contain_similar_object(test_object):
     assert not contain_subset(
         test_object, {
             'arr': [{
                 'arr': ['just random field']
             }, {
                 'arr': []
             }, [{
                 'arr': []
             }, {
                 'arr': []
             }]]
         })
Exemplo n.º 10
0
 def should_pass_for_same_object():
     assert contain_subset(
         tested_object,
         {
             "a": "b",
             "c": "d",
             "e": {
                 "foo": "bar",
                 "baz": {
                     "qux": "quux"
                 }
             }
         },
     )
Exemplo n.º 11
0
 def should_not_contain_similar_object(test_object):
     assert not contain_subset(
         test_object,
         {
             "arr": [
                 {
                     "arr": ["just random field"]
                 },
                 {
                     "arr": []
                 },
                 [{
                     "arr": []
                 }, {
                     "arr": []
                 }],
             ]
         },
     )
Exemplo n.º 12
0
 def should_pass_for_smaller_object_1():
     assert contain_subset(tested_object, {'a': 'b', 'e': {'foo': 'bar'}})
Exemplo n.º 13
0
 def should_pass_for_similar_but_not_the_same_object():
     assert not contain_subset(tested_object, {'a': 'notB', 'c': 'd'})
Exemplo n.º 14
0
 def works_well_with_lists():
     assert contain_subset(test_list, [{'a': 'a'}])
     assert contain_subset(test_list, [{'a': 'a', 'b': 'b'}])
     assert not contain_subset(test_list, [{'a': 'a', 'b': 'bd'}])
Exemplo n.º 15
0
 def should_pass_for_smaller_object():
     assert contain_subset(tested_object, {'a': 'b'})
Exemplo n.º 16
0
 def should_fail_when_function_returns_false():
     assert not contain_subset({'a': 5}, {'a': lambda a: not a})
Exemplo n.º 17
0
 def works_well_with_lists():
     assert contain_subset(test_list, [{"a": "a"}])
     assert contain_subset(test_list, [{"a": "a", "b": "b"}])
     assert not contain_subset(test_list, [{"a": "a", "b": "bd"}])
Exemplo n.º 18
0
 def should_pass_for_smaller_object_1():
     assert contain_subset(tested_object, {"a": "b", "e": {"foo": "bar"}})
Exemplo n.º 19
0
 def should_pass_for_the_same_date_if_nested():
     assert contain_subset({'a': date(2015, 11, 30)},
                           {'a': date(2015, 11, 30)})
Exemplo n.º 20
0
 def should_pass_for_similar_but_not_the_same_object():
     assert not contain_subset(tested_object, {"a": "notB", "c": "d"})
Exemplo n.º 21
0
 def should_not_fail_for_same_non_object_string_variables():
     assert contain_subset('string', 'string')
Exemplo n.º 22
0
 def should_fail_if_expected_subset_is_not_an_object():
     assert not contain_subset({'a': 1}, None)
Exemplo n.º 23
0
 def should_fail_if_actual_subset_is_null():
     assert not contain_subset(None, {'a': 1})
Exemplo n.º 24
0
 def should_pass_for_function_with_no_arguments():
     assert contain_subset({'a': 5}, {'a': lambda: True})
Exemplo n.º 25
0
 def should_pass_for_same_object():
     assert contain_subset(tested_object, {'a': 'b', 'c': 'd'})
Exemplo n.º 26
0
 def should_fail_for_a_different_date():
     assert not contain_subset(date(2015, 11, 30), date(2012, 2, 22))
Exemplo n.º 27
0
 def should_fail_if_comparing_when_comparing_objects_to_dates():
     assert not contain_subset(tested_object, {'e': date.today()})
Exemplo n.º 28
0
 def should_fail_for_a_different_date_if_nested():
     assert not contain_subset({'a': date(2015, 11, 30)},
                               {'a': date(2015, 2, 22)})
Exemplo n.º 29
0
 def should_pass_for_the_same_date():
     assert contain_subset(date(2015, 11, 30), date(2015, 11, 30))
Exemplo n.º 30
0
 def should_pass_when_function_returns_true():
     assert contain_subset({'a': 5}, {'a': lambda a: a})