@@ -126,7 +126,7 @@ def test_patch_datasets(self):
126126
127127 # Mock the post method of AlyxClient and assert that it was called during registration
128128 with mock .patch .object (self .one .alyx , 'post' ) as rest_mock :
129- rest_mock .side_effect = responses
129+ rest_mock .side_effect = [[ r ] for r in responses ]
130130 self .globus_patcher .patch_datasets (file_list )
131131 self .assertEqual (rest_mock .call_count , 2 )
132132 for call , file in zip (rest_mock .call_args_list , file_list ):
@@ -434,16 +434,20 @@ def test_registration_session(self):
434434 query_type = 'remote' )[0 ]
435435 ses_info = self .one .alyx .rest ('sessions' , 'read' , id = eid )
436436 self .assertTrue (ses_info ['procedures' ] == ['Behavior training/tasks' ])
437- self .one .alyx .rest ('sessions' , 'delete' , id = eid )
438- # re-register the session as unknown protocol this time
437+ # re-register the session as unknown protocol, this time without removing session first
439438 self .settings ['PYBPOD_PROTOCOL' ] = 'gnagnagna'
439+ # also add an end time
440+ start = datetime .datetime .fromisoformat (self .settings ['SESSION_DATETIME' ])
441+ self .settings ['SESSION_START_TIME' ] = rc .ensure_ISO8601 (start )
442+ self .settings ['SESSION_END_TIME' ] = rc .ensure_ISO8601 (start + datetime .timedelta (hours = 1 ))
440443 with open (settings_file , 'w' ) as fid :
441444 json .dump (self .settings , fid )
442445 rc .register_session (self .session_path )
443446 eid = self .one .search (subject = self .subject , date_range = ['2018-04-01' , '2018-04-01' ],
444447 query_type = 'remote' )[0 ]
445448 ses_info = self .one .alyx .rest ('sessions' , 'read' , id = eid )
446449 self .assertTrue (ses_info ['procedures' ] == [])
450+ self .assertEqual (self .settings ['SESSION_END_TIME' ], ses_info ['end_time' ])
447451 self .one .alyx .rest ('sessions' , 'delete' , id = eid )
448452
449453 def test_register_chained_session (self ):
@@ -462,12 +466,13 @@ def test_register_chained_session(self):
462466
463467 # Save experiment description
464468 session_params .write_params (self .session_path , experiment_description )
465-
469+ self . settings [ 'POOP_COUNT' ] = 10
466470 with open (behaviour_paths [1 ].joinpath ('_iblrig_taskSettings.raw.json' ), 'w' ) as fid :
467471 json .dump (self .settings , fid )
468472
469473 settings = self .settings .copy ()
470474 settings ['PYBPOD_PROTOCOL' ] = '_iblrig_tasks_passiveChoiceWorld'
475+ settings ['POOP_COUNT' ] = 53
471476 start_time = (datetime .datetime .fromisoformat (settings ['SESSION_DATETIME' ]) -
472477 datetime .timedelta (hours = 1 , minutes = 2 , seconds = 12 ))
473478 settings ['SESSION_DATETIME' ] = start_time .isoformat ()
@@ -480,7 +485,9 @@ def test_register_chained_session(self):
480485 ses_info = self .one .alyx .rest ('sessions' , 'read' , id = session ['id' ])
481486 self .assertCountEqual (experiment_description ['procedures' ], ses_info ['procedures' ])
482487 self .assertCountEqual (experiment_description ['projects' ], ses_info ['projects' ])
483- self .assertCountEqual ({'IS_MOCK' : False , 'IBLRIG_VERSION' : None }, ses_info ['json' ])
488+ # Poo count should be sum of values in both settings files
489+ expected = {'IS_MOCK' : False , 'IBLRIG_VERSION' : '5.4.1' , 'POOP_COUNT' : 63 }
490+ self .assertDictEqual (expected , ses_info ['json' ])
484491 self .assertEqual ('2018-04-01T11:46:14.795526' , ses_info ['start_time' ])
485492 # Test task protocol
486493 expected = '_iblrig_tasks_passiveChoiceWorld5.4.1/_iblrig_tasks_ephysChoiceWorld5.4.1'
0 commit comments