/
test_get_true_diff.py
137 lines (132 loc) · 5.49 KB
/
test_get_true_diff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
"""
Test of get_diff function
"""
from pydeepdiff.diff import get_diff
def test_empty_diff():
a = {
'blocs_reponses': [{
'activites_affichage_immediat': [{
'machine_learning_source': 'rr',
'ordre': 1,
'rubriques': [{
'code_an9': '54053000',
'libelle_rubrique': 'restaurants',
'code_an8': '693780'
}, {
'code_an9': '00000706',
'libelle_rubrique': 'restaurants asiatiques',
'code_an8': '000706'
}],
'type_bloc_activite': 'IMMEDIAT',
'identifications_bloc_reponse_activite': [{
'origine_bloc_reponse': 'MANUEL',
'identifiant_bloc_reponse': '130749'
}],
'libelle': 'RESTAURANTS THAÏLANDAIS',
'correction': False,
'identifiant': 'ac1_2',
'machine_learning_etat': 'valide',
'forme_canonique': 'restaurant thaïlandais',
'expressions': [{
'rubriques': [{
'code_an9': '54053000',
'libelle_rubrique': '',
'code_an8': '693780'
}, {
'code_an9': '00000706',
'libelle_rubrique': '',
'code_an8': '000706'
}],
'rubriques_fines': [{
'code_an9': '00000796',
'libelle_rubrique': '',
'code_an8': '000796'
}],
'formes_brutes': ['restaurant', 'thaïlandais'],
'type_crc': 'C',
'chaine_saisie': 'restaurant thaïlandais',
'type_expression': 'RESTRICTION_FAIBLE',
'libelle': 'thaïlandaise',
'code': 'ObjetCrc_restaurant thaïlandais_5825-693780-50693780-000706-789300-789350-680700_Principale',
'formes_normales': ['RESTAURANT :: THAILANDAIS']
}],
'suggestion_editoriale': False,
'scoring_qui_quoi': 'FORT'
}],
'type_interpretation': 'QUOI',
'identifiant_de_bloc': 'ac1'
}],
'id': 'restaurant thaïlandais',
'ambiguite': True,
'creation_date': '2015-12-10T15:04:08.046092+00:00',
'user': 'fabio',
'status': 'OK',
'mots_signifiants': ['restaurant', 'thaïlandais']
}
b = {
'auto_state': {
'user': None,
'comments': [],
'status': None
},
'id': 'restaurant thaïlandais',
'ambiguite': True,
'creation_date': '2015-12-10T15:04:28.028229+00:00',
'blocs_reponses': [{
'activites_affichage_immediat': [{
'machine_learning_source': 'rr',
'ordre': 1,
'rubriques': [{
'code_an9': '54053000',
'libelle_rubrique': 'restaurants',
'code_an8': '693780'
}, {
'code_an9': '00000706',
'libelle_rubrique': 'restaurants asiatiques',
'code_an8': '000706'
}],
'type_bloc_activite': 'IMMEDIAT',
'identifications_bloc_reponse_activite': [{
'origine_bloc_reponse': 'MANUEL',
'identifiant_bloc_reponse': '130749'
}],
'libelle': 'RESTAURANTS THAÏLANDAIS',
'correction': False,
'identifiant': 'ac1_2',
'machine_learning_etat': 'valide',
'forme_canonique': 'restaurant thaïlandais',
'expressions': [{
'formes_normales': ['RESTAURANT :: THAILANDAIS'],
'rubriques': [{
'code_an9': '54053000',
'libelle_rubrique': '',
'code_an8': '693780'
}, {
'code_an9': '00000706',
'libelle_rubrique': '',
'code_an8': '000706'
}],
'rubriques_fines': [{
'code_an9': '00000796',
'libelle_rubrique': '',
'code_an8': '000796'
}],
'formes_brutes': ['restaurant', 'thaïlandais'],
'type_crc': 'C',
'type_expression': 'RESTRICTION_FAIBLE',
'libelle': 'thaïlandaise',
'code': 'ObjetCrc_restaurant thaïlandais_5825-693780-50693780-000706-789300-789350-680700_Principale',
'chaine_saisie': 'restaurant thaïlandais'
}],
'suggestion_editoriale': False,
'scoring_qui_quoi': 'FORT'
}],
'type_interpretation': 'QUOI',
'identifiant_de_bloc': 'ac1'
}],
'mots_signifiants': ['restaurant', 'thaïlandais']
}
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 == []