def test_nested():
    diff = []

    dict_a = {'id': '1', 'bloc': {'act': '1'}}
    dict_b = {'id': '1', 'bloc': {'act': '2'}}

    diff.extend(
        get_diff(dict_a, dict_b, '', {}, ['bloc.act'], p_complex_details=True))

    expected_diff = []

    assert diff == expected_diff
def test_basic():
    diff = []

    dict_a = {'field_1': 'id1', 'field_2': 'vala1'}
    dict_b = {'field_1': 'id3', 'field_2': 'valb1'}

    diff.extend(
        get_diff(dict_a, dict_b, '', {}, ['field_1'], p_complex_details=True))

    expected_diff = [{
        'path_to_object': 'field_2',
        'filter': 'field_2',
        'kind': 'E',
        'lhs': 'vala1',
        'rhs': 'valb1'
    }]

    assert diff == expected_diff
def test_empty_diff():
    diff = []

    obj_a = {
        'id': 'cabinetinfirmière',
        'blocs_reponses': [
            {
                'activites_affichage_immediat': [
                    {
                        'suggestion_editoriale': False,
                        'machine_learning_etat': 'valide',
                        'correction': False,
                        'machine_learning_source': 'rr',
                        'scoring_qui_quoi': 'FORT',
                        'identifiant': 'ac1',
                        'libelle': 'INFIRMIERS(CABINETS,SOINSÀDOMICILE)',
                        'expressions': [
                            {
                                'formes_brutes': [
                                    'cabinet',
                                    'infirmière'
                                ],
                                'code': 'Objet_cabinetinfirmier_Principale',
                                'formes_normales': [
                                    'XXX'
                                ],
                                'libelle': 'cabinetinfirmière',
                                'type_crc': '',
                                'rubriques_fines': [

                                ],
                                'chaine_saisie': 'cabinetinfirmière',
                                'type_expression': 'ACTIVITE'
                            }
                        ],
                        'type_bloc_activite': 'IMMEDIAT',
                        'rubriques': [
                            {
                                'libelle_rubrique': 'infirmiers(cabinets,soinsàdomicile)',
                                'code_an8': '432240',
                                'code_an9': '58101800'
                            }
                        ],
                        'ordre': 1,
                        'identifications_bloc_reponse_activite': [
                            {
                                'origine_bloc_reponse': 'MANUEL',
                                'identifiant_bloc_reponse': '4124'
                            }
                        ]
                    }
                ],
                'type_interpretation': 'QUOI',
                'identifiant_de_bloc': 'ac1'
            }
        ],
        'mots_signifiants': [
            'infirmière'
        ],
        'ambiguite': True,
        'mots_faibles': [
            'cabinet'
        ]
    }

    obj_b = {
        'id': 'cabinetinfirmière',
        'blocs_reponses': [
            {
                'activites_affichage_immediat': [
                    {
                        'suggestion_editoriale': False,
                        'machine_learning_etat': 'valide',
                        'correction': False,
                        'machine_learning_source': 'rr',
                        'scoring_qui_quoi': 'FORT',
                        'identifiant': 'ac1',
                        'libelle': 'INFIRMIERS(CABINETS,SOINSÀDOMICILE)',
                        'expressions': [
                            {
                                'formes_brutes': [
                                    'cabinet',
                                    'infirmière'
                                ],
                                'code': 'Objet_cabinetinfirmier_Principale',
                                'formes_normales': [
                                    'XXX'
                                ],
                                'libelle': 'cabinetinfirmière',
                                'type_crc': '',
                                'rubriques_fines': [

                                ],
                                'chaine_saisie': 'cabinetinfirmière',
                                'type_expression': 'ACTIVITE'
                            }
                        ],
                        'type_bloc_activite': 'IMMEDIAT',
                        'rubriques': [
                            {
                                'libelle_rubrique': 'infirmiers(cabinets,soinsàdomicile)',
                                'code_an8': '432240',
                                'code_an9': '58101800'
                            }
                        ],
                        'ordre': 1,
                        'identifications_bloc_reponse_activite': [
                            {
                                'origine_bloc_reponse': 'MANUEL',
                                'identifiant_bloc_reponse': '4124'
                            }
                        ]
                    }
                ],
                'type_interpretation': 'QUOI',
                'identifiant_de_bloc': 'ac1'
            }
        ],
        'mots_signifiants': [
            'infirmière'
        ],
        'ambiguite': True,
        'mots_faibles': [
            'cabinet'
        ]
    }

    mapping = []

    diff.extend(get_diff(obj_a, obj_b, [], mapping, p_complex_details=True))

    expected_diff = []

    assert diff == expected_diff
예제 #4
0
def test_empty_diff():
    a = {
            "api_response": {
                "status_code": 200
            },
            "ambiguite": True,
            "creation_date": "2015-12-15T10:31:41.074353+00:00",
            "blocs_reponses": [{
                "type_interpretation": "QUOI",
                "activites_affichage_immediat": [{
                    "forme_canonique": "paysagiste",
                    "machine_learning_source": "rr",
                    "suggestion_editoriale": False,
                    "type_bloc_activite": "IMMEDIAT",
                    "rubriques": [{
                        "code_an8": "850008",
                        "code_an9": "00850008",
                        "libelle_rubrique": "paysagistes d'intérieur"
                    }, {
                        "code_an8": "850009",
                        "code_an9": "00850009",
                        "libelle_rubrique": "paysagistes conseils"
                    }, {
                        "principale": True,
                        "code_an8": "594420",
                        "code_an9": "30055800",
                        "libelle_rubrique": "paysagistes"
                    }, {
                        "code_an8": "447010",
                        "code_an9": "30455800",
                        "libelle_rubrique": "aménagement, entretien de jardins, de parcs"
                    }],
                    "machine_learning_etat": "valide",
                    "expressions": [{
                        "formes_brutes": ["paysagiste"],
                        "chaine_saisie": "paysagiste",
                        "rubriques_fines": [],
                        "type_expression": "ACTIVITE",
                        "formes_normales": ["XXX"],
                        "type_crc": "",
                        "libelle": "paysagiste",
                        "code": "Objet_paysagiste_Principale"
                    }],
                    "correction": False,
                    "identifications_bloc_reponse_activite": [{
                        "origine_bloc_reponse": "MANUEL",
                        "identifiant_bloc_reponse": "106949"
                    }],
                    "ordre": 1,
                    "scoring_qui_quoi": "FORT",
                    "libelle": "PAYSAGISTES, AMENAGEMENT DE PARCS ET JARDINS",
                    "identifiant": "ac1"
                }],
                "identifiant_de_bloc": "ac1"
            }],
            "mots_signifiants": ["paysagiste"],
            "id": "paysagiste",
            "requete": {
                "libelle": "paysagiste",
                "tx_fragile": "0.039009564",
                "frequence": "29637.0"
            }
        }

    b = {
            "auto_state": {
                "user": None,
                "comments": [],
                "status": None
            },
            "api_response": {
                "status_code": 200
            },
            "ambiguite": True,
            "creation_date": "2015-12-15T10:33:12.172772+00:00",
            "blocs_reponses": [{
                "identifiant_de_bloc": "ac1",
                "activites_affichage_immediat": [{
                    "forme_canonique": "paysagiste",
                    "suggestion_editoriale": False,
                    "machine_learning_source": "rr",
                    "rubriques": [{
                        "code_an8": "850008",
                        "code_an9": "00850008",
                        "libelle_rubrique": "paysagistes d'intérieur"
                    }, {
                        "code_an8": "850009",
                        "code_an9": "00850009",
                        "libelle_rubrique": "paysagistes conseils"
                    }, {
                        "principale": True,
                        "code_an8": "594420",
                        "code_an9": "30055800",
                        "libelle_rubrique": "paysagistes"
                    }, {
                        "code_an8": "447010",
                        "code_an9": "30455800",
                        "libelle_rubrique": "aménagement, entretien de jardins, de parcs"
                    }],
                    "identifications_bloc_reponse_activite": [{
                        "origine_bloc_reponse": "MANUEL",
                        "identifiant_bloc_reponse": "106949"
                    }],
                    "expressions": [{
                        "formes_normales": ["XXX"],
                        "formes_brutes": ["paysagiste"],
                        "chaine_saisie": "paysagiste",
                        "rubriques_fines": [],
                        "type_expression": "ACTIVITE",
                        "type_crc": "",
                        "libelle": "paysagiste",
                        "code": "Objet_paysagiste_Principale"
                    }],
                    "correction": False,
                    "machine_learning_etat": "valide",
                    "ordre": 1,
                    "scoring_qui_quoi": "FORT",
                    "libelle": "PAYSAGISTES, AMENAGEMENT DE PARCS ET JARDINS",
                    "type_bloc_activite": "IMMEDIAT",
                    "identifiant": "ac1"
                }],
                "type_interpretation": "QUOI"
            }],
            "mots_signifiants": ["paysagiste"],
            "id": "paysagiste",
            "requete": {
                "libelle": "paysagiste",
                "tx_fragile": "0.039009564",
                "frequence": "29637.0"
            }
        }

    mapping = [{'path': '', 'id': 'id'}, {'path': 'blocs_reponses', 'id': 'identifiant_de_bloc'}, {'path': 'blocs_reponses.activites_affichage_immediat', 'id': 'identifiant'}]
    ignored_field = ['creation_date', 'auto_state', 'user', 'status', 'comments']
    diff = get_diff(a, b, [], mapping, ignored_field)

    assert diff == []
예제 #5
0
def test_empty_diff():
    diff = []

    obj_a = {
        'id':
        'cabinetinfirmière',
        'blocs_reponses': [{
            'activites_affichage_immediat': [{
                'suggestion_editoriale':
                False,
                'machine_learning_etat':
                'valide',
                'correction':
                False,
                'machine_learning_source':
                'rr',
                'scoring_qui_quoi':
                'FORT',
                'identifiant':
                'ac1',
                'libelle':
                'INFIRMIERS(CABINETS,SOINSÀDOMICILE)',
                'expressions': [{
                    'formes_brutes': ['cabinet', 'infirmière'],
                    'code': 'Objet_cabinetinfirmier_Principale',
                    'formes_normales': ['XXX'],
                    'libelle': 'cabinetinfirmière',
                    'type_crc': '',
                    'rubriques_fines': [],
                    'chaine_saisie': 'cabinetinfirmière',
                    'type_expression': 'ACTIVITE'
                }],
                'type_bloc_activite':
                'IMMEDIAT',
                'rubriques': [{
                    'libelle_rubrique': 'infirmiers(cabinets,soinsàdomicile)',
                    'code_an8': '432240',
                    'code_an9': '58101800'
                }],
                'ordre':
                1,
                'identifications_bloc_reponse_activite': [{
                    'origine_bloc_reponse':
                    'MANUEL',
                    'identifiant_bloc_reponse':
                    '4124'
                }]
            }],
            'type_interpretation':
            'QUOI',
            'identifiant_de_bloc':
            'ac1'
        }],
        'mots_signifiants': ['infirmière'],
        'ambiguite':
        True,
        'mots_faibles': ['cabinet']
    }

    obj_b = {
        'id':
        'cabinetinfirmière',
        'blocs_reponses': [{
            'activites_affichage_immediat': [{
                'suggestion_editoriale':
                False,
                'machine_learning_etat':
                'valide',
                'correction':
                False,
                'machine_learning_source':
                'rr',
                'scoring_qui_quoi':
                'FORT',
                'identifiant':
                'ac1',
                'libelle':
                'INFIRMIERS(CABINETS,SOINSÀDOMICILE)',
                'expressions': [{
                    'formes_brutes': ['cabinet', 'infirmière'],
                    'code': 'Objet_cabinetinfirmier_Principale',
                    'formes_normales': ['XXX'],
                    'libelle': 'cabinetinfirmière',
                    'type_crc': '',
                    'rubriques_fines': [],
                    'chaine_saisie': 'cabinetinfirmière',
                    'type_expression': 'ACTIVITE'
                }],
                'type_bloc_activite':
                'IMMEDIAT',
                'rubriques': [{
                    'libelle_rubrique': 'infirmiers(cabinets,soinsàdomicile)',
                    'code_an8': '432240',
                    'code_an9': '58101800'
                }],
                'ordre':
                1,
                'identifications_bloc_reponse_activite': [{
                    'origine_bloc_reponse':
                    'MANUEL',
                    'identifiant_bloc_reponse':
                    '4124'
                }]
            }],
            'type_interpretation':
            'QUOI',
            'identifiant_de_bloc':
            'ac1'
        }],
        'mots_signifiants': ['infirmière'],
        'ambiguite':
        True,
        'mots_faibles': ['cabinet']
    }

    mapping = []

    diff.extend(get_diff(obj_a, obj_b, [], mapping, p_complex_details=True))

    expected_diff = []

    assert diff == expected_diff