Ejemplo n.º 1
0
def test_dict_compare_different():
    d1 = {'one': 1, 'two': False, 'three': {'nested zero': 0}}
    d2 = {'one': 1, 'three': {'nested zero': 1}, 'four': False}
    assert dict_compare(d1, d2) == ({'two'}, {'four'}, {
        'three': ({
            'nested zero': 0
        }, {
            'nested zero': 1
        })
    }, {'one'})
Ejemplo n.º 2
0
def diff_docs(doc1, doc2):
    """Print details of two differing QNR documents"""
    added, removed, modified, _ = dict_compare(doc1, doc2)
    assert not added
    assert not removed
    assert not set(modified) - set(['authored', 'group'])
    if modified:
        if len(doc1['group']) != len(doc2['group']):
            raise ValueError("diff group lens")
        answers1 = doc1['group']
        answers2 = doc2['group']
        for a1, a2 in zip(answers1, answers2):
            assert a1.keys() == a2.keys()
            assert (a1['answer']['valueCoding']['code'] ==
                    a2['answer']['valueCoding']['code'])
            if (a1['answer']['valueCoding']['extension']['valueDecimal'] !=
                    a2['answer']['valueCoding']['extension']['valueDecimal']):
                print("  Question: {} valueDecimal: {} VERSUS {}".format(
                    a1['answer']['valueCoding']['code'],
                    a1['answer']['valueCoding']['extension']['valueDecimal'],
                    a2['answer']['valueCoding']['extension']['valueDecimal']))
Ejemplo n.º 3
0
def diff_docs(doc1, doc2):
    """Print details of two differing QNR documents"""
    added, removed, modified, _ = dict_compare(doc1, doc2)
    assert not added
    assert not removed
    assert not set(modified) - set(['authored', 'group'])
    if modified:
        if len(doc1['group']) != len(doc2['group']):
            raise ValueError("diff group lens")
        answers1 = doc1['group']
        answers2 = doc2['group']
        for a1, a2 in zip(answers1, answers2):
            assert a1.keys() == a2.keys()
            assert (a1['answer']['valueCoding']['code'] == a2['answer']
                    ['valueCoding']['code'])
            if (a1['answer']['valueCoding']['extension']['valueDecimal'] !=
                    a2['answer']['valueCoding']['extension']['valueDecimal']):
                print("  Question: {} valueDecimal: {} VERSUS {}".format(
                    a1['answer']['valueCoding']['code'],
                    a1['answer']['valueCoding']['extension']['valueDecimal'],
                    a2['answer']['valueCoding']['extension']['valueDecimal']))
Ejemplo n.º 4
0
def test_dict_compare_same():
    d1 = {'one': 1, 'two': False, 'three': {'nested zero': 0}}
    d2 = {'one': 1, 'two': False, 'three': {'nested zero': 0}}
    assert dict_compare(d1, d2) == (set(), set(), {}, {'one', 'two', 'three'})
Ejemplo n.º 5
0
def test_dict_compare_different():
    d1 = {'one': 1, 'two': False, 'three': {'nested zero': 0}}
    d2 = {'one': 1, 'three': {'nested zero': 1}, 'four': False}
    assert dict_compare(d1, d2) == (
        {'two'}, {'four'},
        {'three': ({'nested zero': 0}, {'nested zero': 1})}, {'one'})
Ejemplo n.º 6
0
def test_dict_compare_same():
    d1 = {'one': 1, 'two': False, 'three': {'nested zero': 0}}
    d2 = {'one': 1, 'two': False, 'three': {'nested zero': 0}}
    assert dict_compare(d1, d2) == (set(), set(), {}, {'one', 'two', 'three'})