def test_from_db(self):
     load_session = Session.from_db(session_dir=self.session_dir, testing=True, postgresql=self.postgresql)
     self.assertEqual(self.mouse.mouse_id, load_session.mouse_id)
     self.assertEqual(self.experiment.experiment_id, load_session.experiment_id)
     self.assertEqual(utils.convert_date_int_yyyymmdd(self.session_date), load_session.session_date)
     self.assertEqual(self.session_dir, load_session.session_dir)
     self.assertFalse(load_session.session_id is None)
 def setUp(self):
     self.postgresql = Postgresql()
     database.handlers.handlers.handler_seed_sessions_table(self.postgresql)
     self.session = Session.from_db(
         session_dir='/exp/one/dir/9990/20200503_S2',
         testing=True,
         postgresql=self.postgresql)
     self.folder_dir = '/exp/one/dir/9990/20200503_S2/Reaches02'
 def setUp(self):
     self.postgresql = Postgresql()
     database.handlers.handlers.handler_seed_folders_table(self.postgresql)
     seed_sessions = list(test_session_table_seed.keys())
     seed_eartag, seed_experiment = seed_sessions.pop()
     all_sessions = test_session_table_seed[seed_eartag, seed_experiment]
     session_date, session_dir = all_sessions.pop()
     self.session = Session.from_db(session_dir=session_dir,
                                    testing=True,
                                    postgresql=self.postgresql)
     self.folder_dir = '/'.join([session_dir, 'Reaches01'])
Exemple #4
0
 def setUp(self):
     self.postgresql = Postgresql()
     database.handlers.handlers.handler_seed_trials_table(self.postgresql)
     with TestingCursor(self.postgresql) as cursor:
         cursor.execute("SELECT session_dir from sessions;")
         all_session_dir = cursor.fetchall()
     session_dir = all_session_dir.pop()
     self.session = Session.from_db(session_dir=session_dir,
                                    testing=True,
                                    postgresql=self.postgresql)
     folder_dir = '/'.join([self.session.session_dir, 'Reaches02'])
     self.folder = Folder.from_db(folder_dir,
                                  testing=True,
                                  postgresql=self.postgresql)
     self.trial_dir = '/'.join([self.folder.folder_dir, 'trial_1.txt'])
Exemple #5
0
    def test_add_new_trial(self):
        test_folder_dir = '/exp/two/dir/9993/20200516_S1/Reaches01'
        test_trial = 'trial_2.txt'

        trial_dir = '/'.join([test_folder_dir, test_trial])

        test_folder = Folder.from_db(folder_dir=test_folder_dir,
                                     testing=True,
                                     postgresql=self.postgresql)
        test_session = Session.from_db(test_folder.session_id,
                                       testing=True,
                                       postgresql=self.postgresql)
        test_trial = Trial(test_session.experiment_id, test_folder.folder_id,
                           trial_dir, test_session.session_date).save_to_db(
                               testing=True, postgresql=self.postgresql)

        self.assertEqual(test_session.experiment_id, test_trial.experiment_id)
        self.assertEqual(test_folder.folder_id, test_trial.folder_id)
        self.assertEqual(trial_dir, test_trial.trial_dir)
        self.assertEqual(test_session.session_date, test_trial.trial_date)
        self.assertFalse(test_trial.trial_id is None)
def handler_seed_trials_table(postgresql):
    handler_seed_folders_table(postgresql)

    all_trials = [
        'trial_1.txt', 'trial_2.txt', 'trial_3.txt', 'trial_4.txt',
        'trial_5.txt'
    ]
    with TestingCursor(postgresql) as cursor:
        cursor.execute("SELECT * from folders_all_upstream_ids;")
        all_ids = cursor.fetchall()
        for [_, experiment_id, session_id, folder_id] in all_ids:
            folder = Folder.from_db(folder_id=folder_id,
                                    testing=True,
                                    postgresql=postgresql)
            session = Session.from_db(session_id,
                                      testing=True,
                                      postgresql=postgresql)
            for trial in all_trials:
                trial_dir = '/'.join([folder.folder_dir, trial])
                database.seed_tables.seed_tables.seed_trials_table(
                    cursor, experiment_id, folder_id, trial_dir,
                    session.session_date)
 def test_duplicate_session(self):
     test_session = Session(self.mouse.mouse_id, self.experiment.experiment_id,
                            self.session_dir, self.session_date).save_to_db(testing=True, postgresql=self.postgresql)
     dup_session = test_session.save_to_db(testing=True, postgresql=self.postgresql)
     self.assertFalse(dup_session.session_id is None)