def test_get_diff():
    source = [{'id': 1, 'val': 2}, {'id': 2, 'val': 3}]
    dest = [{'id': 2, 'val': 3}, {'id': 3, 'val': 4}]
    assert get_diff(source, dest) == ([{
        'id': 1,
        'val': 2
    }], [{
        'id': 3,
        'val': 4
    }])
Exemplo n.º 2
0
def sync_records(fields, filename, xpath, kinto_client, bucket, collection,
                 schema=None, with_scrapping=False, force_signature=True):
    xml_records = get_xml_records(
        fields=fields,
        filename=filename,
        xpath=xpath)
    kinto_records = get_kinto_records(
        kinto_client=kinto_client,
        bucket=bucket,
        collection=collection,
        schema=schema,
        permissions=COLLECTION_PERMISSIONS)

    to_create, to_delete = get_diff(xml_records, kinto_records)

    if with_scrapping:
        to_create = scrap_details_from_amo(to_create)

    push_changes((to_create, to_delete), kinto_client,
                 bucket=bucket, collection=collection,
                 to_be_signed=force_signature)
def test_get_diff():
    source = [{'id': 1, 'val': 2}, {'id': 2, 'val': 3}]
    dest = [{'id': 2, 'val': 3}, {'id': 3, 'val': 4}]
    assert get_diff(source, dest) == (
        [{'id': 1, 'val': 2}],
        [{'id': 3, 'val': 4}])