Exemplo n.º 1
0
def test_populate_recid_from_ref_naming():
    json_dict = {
        'simple_key': {
            '$ref': 'http://x/y/1'
        },
        'key_with_record': {
            '$ref': 'http://x/y/2'
        },
        'record': {
            '$ref': 'http://x/y/3'
        },
        'embedded_list': [{
            'record': {
                '$ref': 'http://x/y/4'
            }
        }],
        'embedded_record': {
            'record': {
                '$ref': 'http://x/y/5'
            }
        }
    }

    populate_recid_from_ref(None, json_dict)

    assert json_dict['simple_key_recid'] == 1
    assert json_dict['key_with_recid'] == 2
    assert json_dict['recid'] == 3
    assert json_dict['embedded_list'][0]['recid'] == 4
    assert json_dict['embedded_record']['recid'] == 5
def test_populate_recid_from_ref_deleted_records():
    json_dict = {
        'deleted_records': [{'$ref': 'http://x/y/1'},
                            {'$ref': 'http://x/y/2'}]
    }

    populate_recid_from_ref(None, json_dict)

    assert json_dict['deleted_recids'] == [1, 2]
Exemplo n.º 3
0
def test_populate_recid_from_ref_deleted_records():
    json_dict = {
        'deleted_records': [{'$ref': 'http://x/y/1'},
                            {'$ref': 'http://x/y/2'}]
    }

    receivers.populate_recid_from_ref(None, json_dict)

    assert json_dict['deleted_recids'] == [1, 2]
def test_populate_recid_from_ref():
    json_dict = {
        'simple_key': {'$ref': 'http://x/y/1'},
        'key_with_record': {'$ref': 'http://x/y/2'},
        'record': {'$ref': 'http://x/y/3'},
        'embedded_list': [{'record': {'$ref': 'http://x/y/4'}}],
        'embedded_record': {'record': {'$ref': 'http://x/y/5'}}
    }

    populate_recid_from_ref(None, json_dict)

    assert json_dict['simple_key_recid'] == 1
    assert json_dict['key_with_recid'] == 2
    assert json_dict['recid'] == 3
    assert json_dict['embedded_list'][0]['recid'] == 4
    assert json_dict['embedded_record']['recid'] == 5