1313 PipelineConfig ,
1414 PipelineStudyResult ,
1515)
16+ from ..utils import ordered_note_keys
1617
1718
1819def _create_annotation_with_two_analyses (session , user ):
@@ -39,7 +40,7 @@ def _create_annotation_with_two_analyses(session, user):
3940 name = "Test Annotation" ,
4041 studyset = studyset ,
4142 user = user ,
42- note_keys = {"existing" : "string" },
43+ note_keys = ordered_note_keys ( {"existing" : "string" }) ,
4344 )
4445
4546 session .add (annotation )
@@ -92,7 +93,7 @@ def test_blank_annotation_populates_note_fields(
9293 auth_client , ingest_neurosynth , session
9394):
9495 dset = Studyset .query .first ()
95- note_keys = {"included" : "boolean" , "quality" : "string" }
96+ note_keys = ordered_note_keys ( {"included" : "boolean" , "quality" : "string" })
9697 payload = {
9798 "studyset" : dset .id ,
9899 "note_keys" : note_keys ,
@@ -121,7 +122,7 @@ def test_annotation_rejects_empty_note(auth_client, ingest_neurosynth, session):
121122 "note" : {},
122123 }
123124 ],
124- "note_keys" : {"included" : "boolean" },
125+ "note_keys" : ordered_note_keys ( {"included" : "boolean" }) ,
125126 "name" : "invalid annotation" ,
126127 }
127128
@@ -143,7 +144,7 @@ def test_post_annotation(auth_client, ingest_neurosynth, session):
143144 payload = {
144145 "studyset" : dset .id ,
145146 "notes" : data ,
146- "note_keys" : {"foo" : "string" },
147+ "note_keys" : ordered_note_keys ( {"foo" : "string" }) ,
147148 "name" : "mah notes" ,
148149 }
149150 resp = auth_client .post ("/api/annotations/" , data = payload )
@@ -280,7 +281,7 @@ def test_blank_slate_creation(auth_client, session):
280281 # create annotation
281282 annotation_data = {
282283 "studyset" : ss_id ,
283- "note_keys" : {"include" : "boolean" },
284+ "note_keys" : ordered_note_keys ( {"include" : "boolean" }) ,
284285 "name" : "mah notes" ,
285286 }
286287 annotation_post = auth_client .post ("/api/annotations/" , data = annotation_data )
@@ -342,7 +343,7 @@ def test_mismatched_notes(auth_client, ingest_neurosynth, session):
342343 for s in dset .studies
343344 for a in s .analyses
344345 ]
345- note_keys = {"foo" : "string" , "doo" : "string" }
346+ note_keys = ordered_note_keys ( {"foo" : "string" , "doo" : "string" })
346347 payload = {
347348 "studyset" : dset .id ,
348349 "notes" : data ,
@@ -377,7 +378,7 @@ def test_put_nonexistent_analysis(auth_client, ingest_neurosynth, session):
377378 for s in dset .studies
378379 for a in s .analyses
379380 ]
380- note_keys = {"foo" : "string" , "doo" : "string" }
381+ note_keys = ordered_note_keys ( {"foo" : "string" , "doo" : "string" })
381382 payload = {
382383 "studyset" : dset .id ,
383384 "notes" : data ,
@@ -412,7 +413,7 @@ def test_post_put_subset_of_analyses(auth_client, ingest_neurosynth, session):
412413 # remove last note
413414 data .pop ()
414415
415- note_keys = {"foo" : "string" , "doo" : "string" }
416+ note_keys = ordered_note_keys ( {"foo" : "string" , "doo" : "string" })
416417 payload = {
417418 "studyset" : dset .id ,
418419 "notes" : data ,
@@ -444,7 +445,7 @@ def test_correct_note_overwrite(auth_client, ingest_neurosynth, session):
444445 payload = {
445446 "studyset" : dset .id ,
446447 "notes" : data ,
447- "note_keys" : {"foo" : "string" , "doo" : "string" },
448+ "note_keys" : ordered_note_keys ( {"foo" : "string" , "doo" : "string" }) ,
448449 "name" : "mah notes" ,
449450 }
450451
@@ -514,10 +515,10 @@ def test_put_annotation_applies_pipeline_columns(auth_client, session):
514515 assert resp .status_code == 200
515516 body = resp .json ()
516517
517- assert body ["note_keys" ]["existing" ] == "string"
518- assert body ["note_keys" ]["string_field" ] == "string"
519- assert body ["note_keys" ]["numeric_field" ] == "number"
520- assert body ["note_keys" ]["name" ] == "string"
518+ assert body ["note_keys" ]["existing" ][ "type" ] == "string"
519+ assert body ["note_keys" ]["string_field" ][ "type" ] == "string"
520+ assert body ["note_keys" ]["numeric_field" ][ "type" ] == "number"
521+ assert body ["note_keys" ]["name" ][ "type" ] == "string"
521522
522523 notes = body ["notes" ]
523524 assert len (notes ) == 2
@@ -603,9 +604,9 @@ def test_put_annotation_pipeline_column_conflict_suffix(auth_client, session):
603604
604605 assert key_one in body ["note_keys" ]
605606 assert key_two in body ["note_keys" ]
606- assert body ["note_keys" ][key_one ] == "string"
607- assert body ["note_keys" ][key_two ] == "string"
608- assert body ["note_keys" ]["name" ] == "string"
607+ assert body ["note_keys" ][key_one ][ "type" ] == "string"
608+ assert body ["note_keys" ][key_two ][ "type" ] == "string"
609+ assert body ["note_keys" ]["name" ][ "type" ] == "string"
609610
610611 for entry in body ["notes" ]:
611612 note = entry ["note" ]
@@ -625,7 +626,7 @@ def test_annotation_analyses_post(auth_client, ingest_neurosynth, session):
625626 payload = {
626627 "studyset" : dset .id ,
627628 "notes" : data ,
628- "note_keys" : {"foo" : "string" , "doo" : "string" },
629+ "note_keys" : ordered_note_keys ( {"foo" : "string" , "doo" : "string" }) ,
629630 "name" : "mah notes" ,
630631 }
631632
0 commit comments