File tree Expand file tree Collapse file tree 3 files changed +26
-1
lines changed
parser/openfoodfacts_taxonomy_parser Expand file tree Collapse file tree 3 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ async def create_entry_node(
40
40
f"tags_{ language_code } " : [name ],
41
41
f"tags_ids_{ language_code } " : [normalized_name ],
42
42
"modified" : datetime .datetime .now ().timestamp (),
43
+ "is_external" : False ,
43
44
}
44
45
params = {"entry_node" : entry_node_data }
45
46
Original file line number Diff line number Diff line change @@ -167,6 +167,30 @@ async def test_no_comment_repeat(taxonomy_test):
167
167
background_tasks .run ()
168
168
169
169
170
+ @pytest .mark .anyio
171
+ async def test_add_bare_child (taxonomy_test ):
172
+ async with graph_db .TransactionCtx ():
173
+ # add a children to "en:yogurts", without any other properties
174
+ children = await taxonomy_test .get_children ("en:yogurts" )
175
+ children_ids = [record ["child.id" ] for record in children ]
176
+ children_ids .append ("en:sweet yogurts" )
177
+ await taxonomy_test .update_node_children ("en:yogurts" , children_ids )
178
+ background_tasks = FakeBackgroundTask ()
179
+ file_path = taxonomy_test .dump_taxonomy (background_tasks )
180
+ result = list (open (file_path ))
181
+ # expected output
182
+ expected = list (open ("tests/data/test.txt" ))
183
+ # new entry inserted just after yogurts, the parent
184
+ expected [16 :16 ] = [
185
+ "< en:yogurts\n " ,
186
+ "en: sweet yogurts\n " ,
187
+ "\n " ,
188
+ ]
189
+ assert result == expected
190
+ # clean files
191
+ background_tasks .run ()
192
+
193
+
170
194
@pytest .mark .anyio
171
195
async def test_add_new_entry_as_child (taxonomy_test ):
172
196
async with graph_db .TransactionCtx ():
Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ def get_all_nodes(self, project_label):
23
23
MATCH (n:({ project_label } |REMOVED_{ project_label } ))
24
24
WHERE
25
25
// no external node
26
- n.is_external = false
26
+ ( n.is_external = false OR n.is_external IS NULL)
27
27
AND (
28
28
// modified nodes
29
29
((n:TEXT OR n:SYNONYMS OR n:STOPWORDS OR n:ENTRY) AND n.modified IS NOT NULL)
You can’t perform that action at this time.
0 commit comments