def test_get_id(self): load_exp_id = Experiment.get_id(self.seed_tup[0], testing=True, postgresql=self.postgresql) load_fake_id = Experiment.get_id('Experiment Not Here', testing=True, postgresql=self.postgresql) self.assertTrue(len(load_exp_id) == 1) self.assertTrue(len(load_fake_id) == 0)
def list_participants(cls, experiment_name, testing=False, postgresql=None): def list_participants_main(a_cursor, exp_id): a_cursor.execute( "SELECT mouse_id FROM all_participants_all_experiments WHERE experiment_id = %s;", (exp_id, )) return utils.list_from_cursor(cursor.fetchall()) experiment_id = Experiment.get_id(experiment_name, testing, postgresql) if len(experiment_id) == 1: experiment_id = experiment_id[0] else: warnings.warn( "Multiple experiments in the database with the same name.") if testing: with TestingCursor(postgresql) as cursor: return list_participants_main(cursor, experiment_id) else: with Cursor() as cursor: return list_participants_main(cursor, experiment_id)