def testFinishedSession(self): gui_mock = pgm.PsychoPyGuiMock() experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.numsessions = 1 experiment.settings.blockprepN = 5 experiment.settings.blocklengthN = 80 experiment.settings.block_in_epochN = 5 experiment.settings.epochN = 5 experiment.stim_sessionN = {} experiment.stimepoch = {} experiment.stimblock = {} experiment.last_N = experiment.settings.get_maxtrial() for i in range(1, experiment.settings.get_maxtrial() + 1): experiment.stim_sessionN[i] = 1 experiment.stimepoch[i] = i / 5 experiment.stimblock[i] = i / (experiment.settings.blockprepN + experiment.settings.blocklengthN) with self.assertRaises(SystemExit): experiment.show_subject_continuation_dialog() list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 2) self.assertEqual(list_of_texts[0], "A személy adatait beolvastam.") self.assertEqual(list_of_texts[1], "A személy végigcsinálta a feladatot.")
def testDefault(self): asrt.g_tobii_available = False gui_mock = pgm.PsychoPyGuiMock() exp_settings = asrt.ExperimentSettings("", "") numgroups = exp_settings.show_basic_settings_dialog() self.assertEqual(numgroups, 2) self.assertEqual(exp_settings.numsessions, 2) list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 3) self.assertEqual( list_of_texts[0], "Még nincsenek beállítások mentve ehhez a kísérlethez...") self.assertEqual( list_of_texts[1], "A logfile optimalizálása érdekében kérjük add meg, hányféle csoporttal tervezed az adatfelvételt." ) self.assertEqual(list_of_texts[2], "Hány ülés (session) lesz a kísérletben?") list_of_fields = gui_mock.getListOfFields() self.assertEqual(len(list_of_fields), 3) self.assertEqual(list_of_fields[0].label, "Kísérlet típusa:") self.assertEqual(list_of_fields[0].initial, "reakció idő") self.assertEqual(list_of_fields[1].label, "Kiserleti + Kontrollcsoportok szama osszesen") self.assertEqual(list_of_fields[1].initial, 2) self.assertEqual(list_of_fields[2].label, "Ulesek szama") self.assertEqual(list_of_fields[2].initial, 2)
def testCancel(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.setReturnValue(False) exp_settings = asrt.ExperimentSettings("", "") with self.assertRaises(SystemExit): exp_settings.show_basic_settings_dialog()
def testDefaults(self): gui_mock = pgm.PsychoPyGuiMock() experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.numsessions = 1 experiment.settings.asrt_types = {} experiment.settings.asrt_types[1] = "implicit" experiment.show_subject_attributes_dialog() self.assertEqual(len(experiment.PCodes), experiment.settings.numsessions) self.assertEqual(experiment.PCodes[1], "1st - 1234") self.assertEqual(experiment.subject_sex, "male") self.assertEqual(experiment.subject_age, "25") list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 1) self.assertEqual(list_of_texts[0], "") list_of_fields = gui_mock.getListOfFields() self.assertEqual(len(list_of_fields), 3) self.assertEqual(list_of_fields[0].label, "Nem") self.assertEqual(list_of_fields[0].initial, '') self.assertEqual(list_of_fields[1].label, "Életkor") self.assertEqual(list_of_fields[1].initial, '25') self.assertEqual(list_of_fields[2].label, "Session 1 PCode")
def testDefaults(self): gui_mock = pgm.PsychoPyGuiMock() experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.groups = ["kontrol", "exp1"] experiment.show_subject_identification_dialog() self.assertEqual(experiment.subject_name, "alattomos-aladar") self.assertEqual(experiment.subject_number, 0) self.assertEqual(experiment.subject_group, 'kontrol') list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 2) self.assertEqual(list_of_texts[0], "") self.assertEqual(list_of_texts[1], "") list_of_fields = gui_mock.getListOfFields() self.assertEqual(len(list_of_fields), 3) self.assertEqual(list_of_fields[0].label, "Nev") self.assertEqual(list_of_fields[0].initial, 'Alattomos Aladar') self.assertEqual(list_of_fields[1].label, "Sorszam") self.assertEqual(list_of_fields[1].initial, '0') self.assertEqual(list_of_fields[2].label, "Csoport") self.assertEqual(list_of_fields[2].initial, '')
def testInnerTrial(self): gui_mock = pgm.PsychoPyGuiMock() experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.numsessions = 1 experiment.settings.blockprepN = 5 experiment.settings.blocklengthN = 80 experiment.settings.block_in_epochN = 5 experiment.settings.epochN = 5 experiment.stim_sessionN = {} experiment.stimepoch = {} experiment.stimblock = {} experiment.stimtrial = {} experiment.last_N = experiment.settings.get_maxtrial() // 2 for i in range(1, experiment.settings.get_maxtrial() + 1): experiment.stim_sessionN[i] = 1 experiment.stimepoch[i] = i // ( (experiment.settings.blockprepN + experiment.settings.blocklengthN) * experiment.settings.block_in_epochN) + 1 experiment.stimblock[i] = i // ( experiment.settings.blockprepN + experiment.settings.blocklengthN) + 1 experiment.show_subject_continuation_dialog() list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 5) self.assertEqual(list_of_texts[0], "A személy adatait beolvastam.") self.assertEqual(list_of_texts[1], "Folytatás innen...") self.assertEqual(list_of_texts[2], "Session: 1") self.assertEqual(list_of_texts[3], "Epoch: 3") self.assertEqual(list_of_texts[4], "Block: 13")
def testNoSessions(self): gui_mock = pgm.PsychoPyGuiMock() exp_settings = asrt.ExperimentSettings("", "") exp_settings.numsessions = 0 exp_settings.show_epoch_and_block_settings_dialog() self.assertEqual(exp_settings.blockprepN, 5) self.assertEqual(exp_settings.blocklengthN, 80) self.assertEqual(exp_settings.block_in_epochN, 5) self.assertEqual(exp_settings.epochN, 0) self.assertEqual(len(exp_settings.epochs), 0) self.assertEqual(len(exp_settings.asrt_types), 0) list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 1) self.assertEqual(list_of_texts[0], "Kísérlet felépítése ") list_of_fields = gui_mock.getListOfFields() self.assertEqual(len(list_of_fields), 3) self.assertEqual(list_of_fields[0].label, "Randomok gyakorlaskent a blokk elejen (ennyi db):") self.assertEqual(list_of_fields[0].initial, 5) self.assertEqual(list_of_fields[1].label, "Eles probak a blokkban:") self.assertEqual(list_of_fields[1].initial, 80) self.assertEqual(list_of_fields[2].label, "Blokkok szama egy epochban:") self.assertEqual(list_of_fields[2].initial, 5)
def testCancelDialog(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.setReturnValue(False) experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.numsessions = 1 experiment.settings.blockprepN = 5 experiment.settings.blocklengthN = 80 experiment.settings.block_in_epochN = 5 experiment.settings.epochN = 5 experiment.stim_sessionN = {} experiment.stimepoch = {} experiment.stimblock = {} experiment.stimtrial = {} experiment.last_N = 0 for i in range(1, experiment.settings.get_maxtrial() + 1): experiment.stim_sessionN[i] = 1 experiment.stimepoch[i] = i // 5 + 1 experiment.stimblock[i] = i // ( experiment.settings.blockprepN + experiment.settings.blocklengthN) + 1 with self.assertRaises(SystemExit): experiment.show_subject_continuation_dialog()
def testExistingSettingsFile(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues( ['Tóth Béla', 10, 'kontrol', 'nő', 30, '3rd', '2nd', 'Tóth Béla', 10, 'kontrol']) thispath = self.constructFilePath("NoSettingsFile") experiment = asrt.Experiment(thispath) experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.groups = ["kontrol", "exp1"] experiment.settings.numsessions = 2 experiment.settings.epochN = 2 experiment.settings.epochs = [1, 1] experiment.settings.block_in_epochN = 2 experiment.settings.blockprepN = 5 experiment.settings.blocklengthN = 20 experiment.settings.asrt_rcolor = "Orange" experiment.settings.asrt_pcolor = "Green" experiment.settings.asrt_types = {} experiment.settings.asrt_types[1] = "implicit" experiment.settings.asrt_types[2] = "implicit" asrt.ensure_dir(os.path.join(thispath, "settings")) # call once to get the participant settings experiment.participant_id() # let save participant settings after the first block experiment.last_N = 25 experiment.person_data.save_person_settings(experiment) experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.groups = ["kontrol", "exp1"] experiment.settings.epochN = 2 experiment.settings.block_in_epochN = 2 experiment.settings.blockprepN = 5 experiment.settings.blocklengthN = 20 # now load back the participant's settings with participant id function experiment.participant_id() self.assertEqual(experiment.subject_group, 'kontrol') self.assertEqual(experiment.subject_number, 10) self.assertEqual(experiment.subject_name, "toth-bela") self.assertEqual(experiment.PCodes, {1: '3rd - 1324', 2: '2nd - 1243'}) self.assertEqual(experiment.stim_output_line, 0) self.assertEqual(experiment.stim_sessionN, {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 1, 27: 1, 28: 1, 29: 1, 30: 1, 31: 1, 32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 47: 1, 48: 1, 49: 1, 50: 1, 51: 2, 52: 2, 53: 2, 54: 2, 55: 2, 56: 2, 57: 2, 58: 2, 59: 2, 60: 2, 61: 2, 62: 2, 63: 2, 64: 2, 65: 2, 66: 2, 67: 2, 68: 2, 69: 2, 70: 2, 71: 2, 72: 2, 73: 2, 74: 2, 75: 2, 76: 2, 77: 2, 78: 2, 79: 2, 80: 2, 81: 2, 82: 2, 83: 2, 84: 2, 85: 2, 86: 2, 87: 2, 88: 2, 89: 2, 90: 2, 91: 2, 92: 2, 93: 2, 94: 2, 95: 2, 96: 2, 97: 2, 98: 2, 99: 2, 100: 2}) self.assertEqual(experiment.stimepoch, {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 1, 27: 1, 28: 1, 29: 1, 30: 1, 31: 1, 32: 1, 33: 1, 34: 1, 35: 1, 36: 1, 37: 1, 38: 1, 39: 1, 40: 1, 41: 1, 42: 1, 43: 1, 44: 1, 45: 1, 46: 1, 47: 1, 48: 1, 49: 1, 50: 1, 51: 2, 52: 2, 53: 2, 54: 2, 55: 2, 56: 2, 57: 2, 58: 2, 59: 2, 60: 2, 61: 2, 62: 2, 63: 2, 64: 2, 65: 2, 66: 2, 67: 2, 68: 2, 69: 2, 70: 2, 71: 2, 72: 2, 73: 2, 74: 2, 75: 2, 76: 2, 77: 2, 78: 2, 79: 2, 80: 2, 81: 2, 82: 2, 83: 2, 84: 2, 85: 2, 86: 2, 87: 2, 88: 2, 89: 2, 90: 2, 91: 2, 92: 2, 93: 2, 94: 2, 95: 2, 96: 2, 97: 2, 98: 2, 99: 2, 100: 2}) self.assertEqual(experiment.stimblock, {1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1, 10: 1, 11: 1, 12: 1, 13: 1, 14: 1, 15: 1, 16: 1, 17: 1, 18: 1, 19: 1, 20: 1, 21: 1, 22: 1, 23: 1, 24: 1, 25: 1, 26: 2, 27: 2, 28: 2, 29: 2, 30: 2, 31: 2, 32: 2, 33: 2, 34: 2, 35: 2, 36: 2, 37: 2, 38: 2, 39: 2, 40: 2, 41: 2, 42: 2, 43: 2, 44: 2, 45: 2, 46: 2, 47: 2, 48: 2, 49: 2, 50: 2, 51: 3, 52: 3, 53: 3, 54: 3, 55: 3, 56: 3, 57: 3, 58: 3, 59: 3, 60: 3, 61: 3, 62: 3, 63: 3, 64: 3, 65: 3, 66: 3, 67: 3, 68: 3, 69: 3, 70: 3, 71: 3, 72: 3, 73: 3, 74: 3, 75: 3, 76: 4, 77: 4, 78: 4, 79: 4, 80: 4, 81: 4, 82: 4, 83: 4, 84: 4, 85: 4, 86: 4, 87: 4, 88: 4, 89: 4, 90: 4, 91: 4, 92: 4, 93: 4, 94: 4, 95: 4, 96: 4, 97: 4, 98: 4, 99: 4, 100: 4}) self.assertEqual(experiment.stimtrial, {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 7: 7, 8: 8, 9: 9, 10: 10, 11: 11, 12: 12, 13: 13, 14: 14, 15: 15, 16: 16, 17: 17, 18: 18, 19: 19, 20: 20, 21: 21, 22: 22, 23: 23, 24: 24, 25: 25, 26: 1, 27: 2, 28: 3, 29: 4, 30: 5, 31: 6, 32: 7, 33: 8, 34: 9, 35: 10, 36: 11, 37: 12, 38: 13, 39: 14, 40: 15, 41: 16, 42: 17, 43: 18, 44: 19, 45: 20, 46: 21, 47: 22, 48: 23, 49: 24, 50: 25, 51: 1, 52: 2, 53: 3, 54: 4, 55: 5, 56: 6, 57: 7, 58: 8, 59: 9, 60: 10, 61: 11, 62: 12, 63: 13, 64: 14, 65: 15, 66: 16, 67: 17, 68: 18, 69: 19, 70: 20, 71: 21, 72: 22, 73: 23, 74: 24, 75: 25, 76: 1, 77: 2, 78: 3, 79: 4, 80: 5, 81: 6, 82: 7, 83: 8, 84: 9, 85: 10, 86: 11, 87: 12, 88: 13, 89: 14, 90: 15, 91: 16, 92: 17, 93: 18, 94: 19, 95: 20, 96: 21, 97: 22, 98: 23, 99: 24, 100: 25}) self.assertEqual(len(experiment.stimlist), 100) self.assertEqual(experiment.last_N, 25) self.assertEqual(experiment.end_at, {1: 51, 2: 51, 3: 51, 4: 51, 5: 51, 6: 51, 7: 51, 8: 51, 9: 51, 10: 51, 11: 51, 12: 51, 13: 51, 14: 51, 15: 51, 16: 51, 17: 51, 18: 51, 19: 51, 20: 51, 21: 51, 22: 51, 23: 51, 24: 51, 25: 51, 26: 51, 27: 51, 28: 51, 29: 51, 30: 51, 31: 51, 32: 51, 33: 51, 34: 51, 35: 51, 36: 51, 37: 51, 38: 51, 39: 51, 40: 51, 41: 51, 42: 51, 43: 51, 44: 51, 45: 51, 46: 51, 47: 51, 48: 51, 49: 51, 50: 51, 51: 101, 52: 101, 53: 101, 54: 101, 55: 101, 56: 101, 57: 101, 58: 101, 59: 101, 60: 101, 61: 101, 62: 101, 63: 101, 64: 101, 65: 101, 66: 101, 67: 101, 68: 101, 69: 101, 70: 101, 71: 101, 72: 101, 73: 101, 74: 101, 75: 101, 76: 101, 77: 101, 78: 101, 79: 101, 80: 101, 81: 101, 82: 101, 83: 101, 84: 101, 85: 101, 86: 101, 87: 101, 88: 101, 89: 101, 90: 101, 91: 101, 92: 101, 93: 101, 94: 101, 95: 101, 96: 101, 97: 101, 98: 101, 99: 101, 100: 101}) self.assertEqual(experiment.stimpr, {1: 'random', 2: 'random', 3: 'random', 4: 'random', 5: 'random', 6: 'pattern', 7: 'random', 8: 'pattern', 9: 'random', 10: 'pattern', 11: 'random', 12: 'pattern', 13: 'random', 14: 'pattern', 15: 'random', 16: 'pattern', 17: 'random', 18: 'pattern', 19: 'random', 20: 'pattern', 21: 'random', 22: 'pattern', 23: 'random', 24: 'pattern', 25: 'random', 26: 'random', 27: 'random', 28: 'random', 29: 'random', 30: 'random', 31: 'pattern', 32: 'random', 33: 'pattern', 34: 'random', 35: 'pattern', 36: 'random', 37: 'pattern', 38: 'random', 39: 'pattern', 40: 'random', 41: 'pattern', 42: 'random', 43: 'pattern', 44: 'random', 45: 'pattern', 46: 'random', 47: 'pattern', 48: 'random', 49: 'pattern', 50: 'random', 51: 'random', 52: 'random', 53: 'random', 54: 'random', 55: 'random', 56: 'pattern', 57: 'random', 58: 'pattern', 59: 'random', 60: 'pattern', 61: 'random', 62: 'pattern', 63: 'random', 64: 'pattern', 65: 'random', 66: 'pattern', 67: 'random', 68: 'pattern', 69: 'random', 70: 'pattern', 71: 'random', 72: 'pattern', 73: 'random', 74: 'pattern', 75: 'random', 76: 'random', 77: 'random', 78: 'random', 79: 'random', 80: 'random', 81: 'pattern', 82: 'random', 83: 'pattern', 84: 'random', 85: 'pattern', 86: 'random', 87: 'pattern', 88: 'random', 89: 'pattern', 90: 'random', 91: 'pattern', 92: 'random', 93: 'pattern', 94: 'random', 95: 'pattern', 96: 'random', 97: 'pattern', 98: 'random', 99: 'pattern', 100: 'random'})
def testETMissingDependency(self): asrt.g_tobii_available = False gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['eye-tracking', 4, 5]) exp_settings = asrt.ExperimentSettings("", "") with self.assertRaises(SystemExit): exp_settings.show_basic_settings_dialog()
def testCancel(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.setReturnValue(False) exp_settings = asrt.ExperimentSettings("", "") exp_settings.numsessions = 1 with self.assertRaises(SystemExit): exp_settings.show_epoch_and_block_settings_dialog()
def testCancel(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.setReturnValue(False) experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.groups = ["kontrol", "exp1"] with self.assertRaises(SystemExit): experiment.show_subject_identification_dialog()
def testWithoutPrepTrials(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'férfi', 25, '3rd']) self.visual_mock = pvm.PsychoPyVisualMock() self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile()
def testCustomValuesET(self): asrt.g_tobii_available = True gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['eye-tracking', 4, 5]) exp_settings = asrt.ExperimentSettings("", "") numgroups = exp_settings.show_basic_settings_dialog() self.assertEqual(exp_settings.experiment_type, 'eye-tracking') self.assertEqual(numgroups, 4) self.assertEqual(exp_settings.numsessions, 5)
def testCustomValues(self): asrt.g_tobii_available = False gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['reakció idő', 3, 3]) exp_settings = asrt.ExperimentSettings("", "") numgroups = exp_settings.show_basic_settings_dialog() self.assertEqual(exp_settings.experiment_type, 'reaction-time') self.assertEqual(numgroups, 3) self.assertEqual(exp_settings.numsessions, 3)
def testSimpleTestCase(self): # for setting participant data gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'férfi', 25, '3rd']) self.visual_mock = pvm.PsychoPyVisualMock() self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile(True)
def testAccentCharacters(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(["áaéeíióoőöúuűüÁAÉEÍIÓOŐÖÚUŰÜ", "kontrol"]) numgroups = 2 exp_settings = asrt.ExperimentSettings("", "") exp_settings.show_group_settings_dialog(numgroups) self.assertEqual(len(exp_settings.groups), numgroups) self.assertEqual(exp_settings.groups[0], "aaeeiioooouuuuaaeeiioooouuuu") self.assertEqual(exp_settings.groups[1], "kontrol")
def testRSIInterval(self): # reset StaticPeriod core.StaticPeriod = self.StaticPeriod gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'férfi', 25, '3rd']) self.visual_mock = pvm.PsychoPyVisualMock() self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile()
def testGazeDataAveraging(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'férfi', 25, '3rd']) self.experiment.wait_for_eye_response = self.wait_for_eye_response_override_averaging_data self.visual_mock = pvm.PsychoPyVisualMock() self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile(True)
def testSpecialCharacters(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['áaée íióoőö úuűüÁA ÉEÍIÓOŐÖ ÚUŰÜ', 10, 'kontrol']) experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.groups = ["kontrol", "exp1"] experiment.show_subject_identification_dialog() self.assertEqual(experiment.subject_name, "aaee-iioooo-uuuuaa-eeiioooo-uuuu") self.assertEqual(experiment.subject_number, 10) self.assertEqual(experiment.subject_group, 'kontrol')
def testCustomValues(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'kontrol', 'férfi', '25']) experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.groups = ["kontrol", "exp1"] subject_settings = experiment.show_subject_identification_dialog() self.assertEqual(experiment.subject_name, "toth-bela") self.assertEqual(experiment.subject_number, 10) self.assertEqual(experiment.subject_group, 'kontrol')
def testRT(self): self.experiment.calculate_stim_properties = self.calculate_stim_properties_override_RT # for setting participant data gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'férfi', 25, '3rd']) self.visual_mock = pvm.PsychoPyVisualMock() self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile(True)
def testCancel(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.setReturnValue(False) experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.numsessions = 1 experiment.settings.asrt_types = {} experiment.settings.asrt_types[1] = "implicit" with self.assertRaises(SystemExit): experiment.show_subject_attributes_dialog()
def testQuitInsideABlock(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['Tóth Béla', 10, 'férfi', 25, '3rd']) self.visual_mock = pvm.PsychoPyVisualMock() self.visual_mock.setReturnKeyList( ['c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'c', 'q']) with self.assertRaises(SystemExit): self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile(True)
def testRandomBlocks(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues([ 'Tóth Béla', 10, 'férfi', 25, '3rd', 'noPattern', 'Tóth Béla', 10 ]) self.visual_mock = pvm.PsychoPyVisualMock() self.experiment.run(window_gammaErrorPolicy='ignore') self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile()
def testDefaultsET(self): gui_mock = pgm.PsychoPyGuiMock() exp_settings = asrt.ExperimentSettings("", "") exp_settings.experiment_type = 'eye-tracking' exp_settings.show_computer_and_display_settings_dialog() self.assertEqual(exp_settings.monitor_width, 34.2) self.assertEqual(exp_settings.computer_name, "Laposka") self.assertEqual(exp_settings.asrt_distance, 10) self.assertEqual(exp_settings.asrt_size, 1) self.assertEqual(exp_settings.asrt_rcolor, "Orange") self.assertEqual(exp_settings.asrt_pcolor, "Green") self.assertEqual(exp_settings.asrt_background, "Ivory") self.assertEqual(exp_settings.RSI_time, 0.5) self.assertEqual(exp_settings.AOI_size, 3.0) self.assertEqual(exp_settings.stim_fixation_threshold, 12) self.assertEqual(exp_settings.instruction_fixation_threshold, 36) self.assertEqual(exp_settings.dispersion_threshold, 2.0) list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 3) self.assertEqual(list_of_texts[0], "A számítógépről...") self.assertEqual(list_of_texts[1], "Megjelenés..") self.assertEqual(list_of_texts[2], "Eye-tracking paraméterek...") list_of_fields = gui_mock.getListOfFields() self.assertEqual(len(list_of_fields), 12) self.assertEqual(list_of_fields[0].label, "Hasznos kepernyo szelessege (cm)") self.assertEqual(list_of_fields[0].initial, 34.2) self.assertEqual(list_of_fields[1].label, "Szamitogep fantazianeve (ekezet nelkul)") self.assertEqual(list_of_fields[1].initial, "Laposka") self.assertEqual(list_of_fields[2].label, "Ingerek tavolsaga (kozeppontok kozott) (cm)") self.assertEqual(list_of_fields[2].initial, 10.0) self.assertEqual(list_of_fields[3].label, "Ingerek sugara (cm)") self.assertEqual(list_of_fields[3].initial, 1) self.assertEqual(list_of_fields[4].label, "ASRT inger szine (elsodleges, R)") self.assertEqual(list_of_fields[4].initial, "Orange") self.assertEqual(list_of_fields[5].label, "ASRT inger szine (masodlagos, P, explicit asrtnel)") self.assertEqual(list_of_fields[5].initial, "Green") self.assertEqual(list_of_fields[6].label, "Hatter szine") self.assertEqual(list_of_fields[6].initial, "Ivory") self.assertEqual(list_of_fields[7].label, "RSI (ms)") self.assertEqual(list_of_fields[7].initial, 500) self.assertEqual(list_of_fields[8].label, "AOI négyzetek oldahossza (cm):") self.assertEqual(list_of_fields[8].initial, 3.0) self.assertEqual(list_of_fields[9].label, "Stimulusnál használt fixációs küszöbérték (mintavételek száma):") self.assertEqual(list_of_fields[9].initial, 12) self.assertEqual(list_of_fields[10].label, "Instrukcióknál használt fixációs küszöbérték (mintavételek száma):") self.assertEqual(list_of_fields[10].initial, 36) self.assertEqual(list_of_fields[11].label, "Diszperzió küszöbérték (cm):") self.assertEqual(list_of_fields[11].initial, 2.0)
def testWrongSubjectNumber(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['férfi', "alma", '1st']) experiment = asrt.Experiment("") experiment.settings = asrt.ExperimentSettings("", "") experiment.settings.numsessions = 1 experiment.settings.asrt_types = {} experiment.settings.asrt_types[1] = "implicit" with self.assertRaises(SystemExit): experiment.show_subject_attributes_dialog()
def testMoreSessionsSubsequently(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues([ 'Tóth Béla', 10, 'férfi', 25, '3rd', '5th', 'noPattern', '1st', 'Tóth Béla', 10, 'Tóth Béla', 10, 'Tóth Béla', 10 ]) self.visual_mock = pvm.PsychoPyVisualMock() for i in range(1, 5): self.experiment.run(window_gammaErrorPolicy='ignore') self.checkOutputFile()
def testNoGroup(self): gui_mock = pgm.PsychoPyGuiMock() numgroups = 0 exp_settings = asrt.ExperimentSettings("", "") exp_settings.show_group_settings_dialog(numgroups) self.assertEqual(len(exp_settings.groups), 1) self.assertEqual(exp_settings.groups[0], "nincsenek csoportok") list_of_texts = gui_mock.getListOfTexts() self.assertEqual(len(list_of_texts), 0) list_of_fields = gui_mock.getListOfFields() self.assertEqual(len(list_of_fields), numgroups)
def testCustomValues(self): gui_mock = pgm.PsychoPyGuiMock() gui_mock.addFieldValues(['a', 's', 'd', 'w', 'k', False, 80, 70]) exp_settings = asrt.ExperimentSettings("", "") exp_settings.experiment_type = 'reaction-time' exp_settings.show_key_and_feedback_settings_dialog() self.assertEqual(exp_settings.key1, 'a') self.assertEqual(exp_settings.key2, 's') self.assertEqual(exp_settings.key3, 'd') self.assertEqual(exp_settings.key4, 'w') self.assertEqual(exp_settings.key_quit, 'k') self.assertEqual(exp_settings.whether_warning, False) self.assertEqual(exp_settings.speed_warning, 80) self.assertEqual(exp_settings.acc_warning, 70)