Exemple #1
0
def test_diff_block(test_name, json1, json2, expected):
    """Assert that the diff block gets created correctly."""
    from legal_api.core.utils import diff_dict
    diff = diff_dict(json1, json2)

    ld = [d.json for d in diff]

    assert expected == ld
Exemple #2
0
def test_diff_list_missing_diff_list_func():
    """Assert that the list is skipped if no diff_list function provided."""
    from legal_api.core.utils import diff_dict
    json1 = {'a': 'b', 'c': [{'a1', 'b1'}]}
    json2 = {'a': 'b', 'c': [{'a1', 'b2'}]}
    expected = []

    diff = diff_dict(json1, json2)

    assert diff == expected
Exemple #3
0
def test_diff_block_lists(test_name, json1, json2, expected):
    """Assert that the diff block gets created correctly."""
    from legal_api.core.utils import diff_dict, diff_list
    try:
        diff = diff_dict(json1, json2, diff_list_callback=diff_list)
    except Exception as err:
        print(err)

    ld = [d.json for d in diff]

    assert expected == ld
Exemple #4
0
def test_diff_block_ignore_keys():
    """Assert that the edge stop cases work."""
    from legal_api.core.utils import diff_dict
    json1 = {'a': 'b', 'c': {'a1', 'b1'}}
    json2 = {'a': 'b', 'c': {'a1', 'b2'}}
    ignore_keys = ['c']
    expected = []

    diff = diff_dict(json1, json2, ignore_keys=ignore_keys)

    assert diff == expected
Exemple #5
0
def test_filing_json_diff():
    """Assert the diff works on a sample filing structure."""
    from legal_api.core.utils import diff_dict, diff_list

    diff = diff_dict(CORRECTION_FILING_JSON,
                     MINIMAL_FILING_JSON,
                     ignore_keys=['header', 'business', 'correction'],
                     diff_list_callback=diff_list)

    ld = [d.json for d in diff] if diff else None

    assert ld == [{
        'newValue': 'Be it resolved, and now it is.',
        'oldValue': 'Be it resolved, that it is resolved to be resolved.',
        'path': '/filing/specialResolution/resolution'}]
Exemple #6
0
def test_filing_json_diff(test_name, diff_value_test, value):
    """Assert the diff works on filing."""
    from legal_api.core.utils import diff_dict, diff_list

    json1 = copy.deepcopy(MINIMAL_FILING_JSON)
    json2 = copy.deepcopy(CORRECTION_FILING_JSON)
    if diff_value_test:
        json1['filing']['specialResolution']['meetingDate'] = value
        json2['filing']['specialResolution']['meetingDate'] = value

    diff = diff_dict(json2,
                     json1,
                     ignore_keys=['header', 'business', 'correction'],
                     diff_list_callback=diff_list)

    ld = [d.json for d in diff] if diff else None

    assert ld == [{
        'newValue': 'Be it resolved, and now it is.',
        'oldValue': 'Be it resolved, that it is resolved to be resolved.',
        'path': RESOLUTION_PATH
    }]