def test_copy_button_is_working_properly(self): """testing if the copy button is working properly """ # Select Task4 in from_task_tree_view selection_model = self.dialog.from_task_tree_view.selectionModel() model = self.dialog.from_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.from_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.from_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select(task4_item.index(), QtGui.QItemSelectionModel.Select) # Select Task8 in to_task_tree_view selection_model = self.dialog.to_task_tree_view.selectionModel() model = self.dialog.to_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.to_task_tree_view.expand(project1_item.index()) task2_item = project1_item.child(1, 0) self.dialog.to_task_tree_view.expand(task2_item.index()) task8_item = task2_item.child(1, 0) selection_model.select(task8_item.index(), QtGui.QItemSelectionModel.Select) # before copying anything # check if there are no versions under Task8 self.assertTrue(self.test_task8.versions == []) self.assertEqual(len(self.test_task4.versions), 9) take_name_count = DBSession\ .query(distinct(Version.take_name))\ .filter(Version.task == self.test_task4)\ .count() self.assertEqual(take_name_count, 3) # for testing purposes set question result to QtGui.QMessageBox.Yes PatchedMessageBox.Yes = self.original_message_box.Yes PatchedMessageBox.No = self.original_message_box.No PatchedMessageBox.question_return_value = self.original_message_box.Yes # copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) # and expect as many versions under task8 as the task4 take_names # check if it still has 9 versions self.assertEqual(len(self.test_task4.versions), 9) self.assertEqual(len(self.test_task8.versions), take_name_count) # check if files are copied there for version in self.test_task8.versions: self.assertTrue(os.path.exists(version.absolute_full_path))
def test_clicking_picker_button_opens_picker_window(self): QTest.mouseClick(self.controller.add_button, Qt.LeftButton) picker_window_open = False for widget in QApplication.topLevelWidgets(): if isinstance(widget, lyrical.LyricalPicker): picker_window_open = True self.assertTrue(picker_window_open)
def test_place_item(self): """ Tests the workflow of placing an item """ # Make sure the dockwidget is out of the way self.mw.history_dock_widget.hide() # Select insertion mode QTest.keyClick(self.mw, QtCore.Qt.Key_F2) self.app.processEvents() # Place item QTest.mouseClick( self.mw._view.viewport(), QtCore.Qt.LeftButton, pos=self.mw._view.geometry().center() ) self.app.processEvents() logic_item_count = 0 for item in self.mw._view.scene().items(): if isinstance(item, logicitems.LogicItem): logic_item_count += 1 self.assertEqual(1, logic_item_count)
def test_send_pushButton_will_warn_the_user_to_set_the_media_files_path_if_it_is_not_set_before(self): """testing if send_pushButton will warn the user to set the media files path in preferences if it is not set before """ # set a proper EDL file edl_path = os.path.abspath('../previs/test_data/test_v001.edl') self.dialog.edl_path_lineEdit.setText(edl_path) # patch QMessageBox.critical method original = QtGui.QMessageBox.critical QtGui.QMessageBox = PatchedMessageBox self.assertEqual(PatchedMessageBox.called_function, '') self.assertEqual(PatchedMessageBox.title, '') self.assertEqual(PatchedMessageBox.message, '') # now hit it QTest.mouseClick(self.dialog.send_pushButton, Qt.LeftButton) # restore QMessageBox.critical QtGui.QMessageBox.critical = original self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual( "Media path doesn't exists", PatchedMessageBox.message )
def test_copy_button_clicked_with_no_selection_on_to_task_tree_view(self): """testing if a QMessageDialog will be displayed when the copy button selected and no selection is made in to_task_tree_vie """ # select one task in from_task_tree_view # Select Task4 in from_task_tree_view selection_model = self.dialog.from_task_tree_view.selectionModel() model = self.dialog.from_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.from_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.from_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select( task4_item.index(), QtGui.QItemSelectionModel.Select ) self.assertEqual(PatchedMessageBox.called_function, '') # now try to copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual(PatchedMessageBox.message, 'Please select a task from <b>To Task</b> list')
def test_copy_button_clicked_with_no_selection_on_to_task_tree_view(self): """testing if a QMessageDialog will be displayed when the copy button selected and no selection is made in to_task_tree_vie """ # select one task in from_task_tree_view # Select Task4 in from_task_tree_view selection_model = self.dialog.from_task_tree_view.selectionModel() model = self.dialog.from_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.from_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.from_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select(task4_item.index(), QtGui.QItemSelectionModel.Select) self.assertEqual(PatchedMessageBox.called_function, '') # now try to copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual(PatchedMessageBox.message, 'Please select a task from <b>To Task</b> list')
def test_add_task_with_description(self): itemsBefore = self.form.listWidget.count() '''ensures AddTaskEdit contains text''' QTest.keyClicks(self.form.AddTaskEdit, "task one") addButton = self.form.AddTaskButton QTest.mouseClick(addButton, Qt.LeftButton) '''assert there is one more item''' self.assertEqual(self.form.listWidget.count(), itemsBefore+1)
def test_add_task_without_description(self): itemsBefore = self.form.listWidget.count() '''ensures AddTaskEdit is empty''' QTest.keyClicks(self.form.AddTaskEdit, "") addButton = self.form.AddTaskButton QTest.mouseClick(addButton, Qt.LeftButton) '''assert no items were added''' self.assertEqual(self.form.listWidget.count(), itemsBefore)
def mouseClick(widget, button, modifier=None, pos=None, delay=-1): """Simulate clicking a mouse button. See QTest.mouseClick for details. """ if modifier is None: modifier = qt.Qt.KeyboardModifiers() pos = qt.QPoint(pos[0], pos[1]) if pos is not None else qt.QPoint() QTest.mouseClick(widget, button, modifier, pos, delay)
def test_close_button_closes_ui(self): """testing if the close button is closing the ui """ self.dialog.show() self.assertEqual(self.dialog.isVisible(), True) # now run the UI QTest.mouseClick(self.dialog.close_pushButton, Qt.LeftButton) self.assertEqual(self.dialog.isVisible(), False)
def mouseClick(self, widget, button, modifier=None, pos=None, delay=-1): """Simulate clicking a mouse button. See QTest.mouseClick for details. """ if modifier is None: modifier = qt.Qt.KeyboardModifiers() pos = qt.QPoint(pos[0], pos[1]) if pos is not None else qt.QPoint() QTest.mouseClick(widget, button, modifier, pos, delay) self.qWait(20)
def test_send_pushButton_will_copy_mxf_files_to_media_files_folder(self): """testing if send_pushButton will copy the mxf files to media files folder """ # create a proper edl file with proper files in a temp location # there should be MXF files tempdir = tempfile.gettempdir() media_files_path = os.path.join(tempdir, 'avid_media_file_path') try: os.mkdir(media_files_path) except OSError: pass self.remove_files.append(media_files_path) mxf_file_names = [ 'SEQ001_HSNI_003_0010_v001.mxf', 'SEQ001_HSNI_003_0020_v001.mxf', 'SEQ001_HSNI_003_0030_v001.mxf' ] edl_path = os.path.abspath('../previs/test_data/test_v001.edl') for mxf_file_name in mxf_file_names: media_file_full_path = os.path.join(tempdir, mxf_file_name) with open(media_file_full_path, 'w') as f: f.write('') self.remove_files.append(media_file_full_path) # set the avid media files folder path self.dialog.media_files_path_lineEdit.setText(media_files_path) # set the edl path self.dialog.edl_path_lineEdit.setText(edl_path) # now check before the files are not there self.assertFalse( os.path.exists(os.path.join(media_files_path, mxf_file_names[0]))) self.assertFalse( os.path.exists(os.path.join(media_files_path, mxf_file_names[1]))) self.assertFalse( os.path.exists(os.path.join(media_files_path, mxf_file_names[2]))) # self.show_dialog(self.dialog) # now hit it QTest.mouseClick(self.dialog.send_pushButton, Qt.LeftButton) # now check if the files are there self.assertTrue( os.path.exists(os.path.join(media_files_path, mxf_file_names[0]))) self.assertTrue( os.path.exists(os.path.join(media_files_path, mxf_file_names[1]))) self.assertTrue( os.path.exists(os.path.join(media_files_path, mxf_file_names[2])))
def testBasic(self): '''QTest.mouseClick with QCheckBox''' button = QPushButton() button.setCheckable(True) button.setChecked(False) QTest.mouseClick(button, Qt.LeftButton) self.assert_(button.isChecked()) QTest.mouseClick(button, Qt.LeftButton) self.assertFalse(button.isChecked())
def test_app_should_write_text_when_sample_button_click(simple_app, capsys): """ Given: A running app. When: The init test button is clicked. Then: A welcome test should return. """ button = simple_app.button QTest.mouseClick(button, QtCore.Qt.LeftButton) out, err = capsys.readouterr() assert "Start coding for {{ cookiecutter.repo_name }}" in str(out)
def test_copy_button_clicked_with_no_selection_on_from_task_tree_view(self): """testing if a QMessageDialog will be displayed when the copy button selected and no selection is made in from_task_tree_view """ self.assertEqual(PatchedMessageBox.called_function, '') # now try to copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual(PatchedMessageBox.message, 'Please select a task from <b>From Task</b> list')
def test_copy_button_clicked_with_no_selection_on_from_task_tree_view( self): """testing if a QMessageDialog will be displayed when the copy button selected and no selection is made in from_task_tree_view """ self.assertEqual(PatchedMessageBox.called_function, '') # now try to copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual(PatchedMessageBox.message, 'Please select a task from <b>From Task</b> list')
def test_add_two_tasks_correct_size(self): itemsBefore = self.form.listWidget.count() currentHeight = self.form.listWidget.parentWidget().size().height() '''ensures AddTaskEdit contains text''' QTest.keyClicks(self.form.AddTaskEdit, "task one") addButton = self.form.AddTaskButton QTest.mouseClick(addButton, Qt.LeftButton) QTest.mouseClick(addButton, Qt.LeftButton) '''assert there is two more items, and size grew''' self.assertEqual(self.form.listWidget.count(), itemsBefore+2) newHeight = self.form.listWidget.parentWidget().size().height() twoLines = 2*21 twoSpaces = 2*2 self.assertEqual(currentHeight+twoLines+twoSpaces, newHeight)
def test_copy_button_clicked_with_same_task_is_selected_in_both_sides(self): """testing if a QMessageDialog will warn the user about he/she selected the same task in both tree views """ # select one task in from_task_tree_view # Select Task4 in from_task_tree_view selection_model = self.dialog.from_task_tree_view.selectionModel() model = self.dialog.from_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.from_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.from_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select( task4_item.index(), QtGui.QItemSelectionModel.Select ) # Select Task4 in to_task_tree_view selection_model = self.dialog.to_task_tree_view.selectionModel() model = self.dialog.to_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.to_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.to_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select( task4_item.index(), QtGui.QItemSelectionModel.Select ) self.assertEqual(PatchedMessageBox.called_function, '') # now try to copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual(PatchedMessageBox.message, 'Please select two different tasks')
def test_lulu_about_qt_box(self): """ Tests whether the about Qt dialog opens correctly via the menu """ # Make sure the dock widget is out of the way self.mw.history_dock_widget.hide() # Open file menu QTest.mouseClick( self.mw.menu_bar, QtCore.Qt.LeftButton, pos=self.mw.menu_bar.actionGeometry( self.mw.menu_help.menuAction()).center()) self.assertTrue(self.mw.menu_help.isVisible()) # As the modal about dialog will block in it's event queue, # queue the check itself. called = False def check_open_and_dismiss(window): nonlocal called self.assertIsInstance(window, QtGui.QMessageBox) QTest.keyClick(window, QtCore.Qt.Key_Escape) QtGui.QApplication.instance().processEvents() called = True delayed_perform_on_modal(check_open_and_dismiss) # Click about QTest.mouseClick( self.mw.menu_help, QtCore.Qt.LeftButton, pos=self.mw.menu_help.actionGeometry( self.mw.action_about_qt).center()) # # Modal event queue running here until dialog is dismissed # self.assertTrue(called) def is_main_window_active_yet(): self.app.processEvents() return self.app.activeWindow() == self.mw try_repeatedly(is_main_window_active_yet) self.assertEqual(self.app.activeWindow(), self.mw)
def test_update_pushButton_will_call_environment_update_versions_method( self): """testing if update_pushButton will call Test_Environment.update_versions method """ self.assertRaises(KeyError, self.test_environment.test_data.__getitem__, 'update_versions') # self.show_dialog(self.dialog) QTest.mouseClick(self.dialog.update_pushButton, Qt.LeftButton) #print self.test_environment.test_data self.assertEqual( 1, self.test_environment.test_data['update_versions']['call_count'])
def test_update_pushButton_will_call_environment_update_versions_method(self): """testing if update_pushButton will call Test_Environment.update_versions method """ self.assertRaises( KeyError, self.test_environment.test_data.__getitem__, 'update_versions' ) # self.show_dialog(self.dialog) QTest.mouseClick(self.dialog.update_pushButton, Qt.LeftButton) #print self.test_environment.test_data self.assertEqual( 1, self.test_environment.test_data['update_versions']['call_count'] )
def test_copy_button_clicked_with_same_task_is_selected_in_both_sides( self): """testing if a QMessageDialog will warn the user about he/she selected the same task in both tree views """ # select one task in from_task_tree_view # Select Task4 in from_task_tree_view selection_model = self.dialog.from_task_tree_view.selectionModel() model = self.dialog.from_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.from_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.from_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select(task4_item.index(), QtGui.QItemSelectionModel.Select) # Select Task4 in to_task_tree_view selection_model = self.dialog.to_task_tree_view.selectionModel() model = self.dialog.to_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.to_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.to_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select(task4_item.index(), QtGui.QItemSelectionModel.Select) self.assertEqual(PatchedMessageBox.called_function, '') # now try to copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) self.assertEqual(PatchedMessageBox.called_function, 'critical') self.assertEqual(PatchedMessageBox.title, 'Error') self.assertEqual(PatchedMessageBox.message, 'Please select two different tasks')
def test_select_all_pushButton_will_select_all_check_boxes_when_clicked(self): """testing if select all pushButton will select all the check boxes when clicked """ # check if all are selected version_tree_model = self.dialog.versions_treeView.model() # check if we have all items index = version_tree_model.index(0, 0) version_item1 = version_tree_model.itemFromIndex(index) version_item1.setCheckState(QtCore.Qt.Unchecked) index = version_tree_model.index(1, 0) version_item2 = version_tree_model.itemFromIndex(index) version_item2.setCheckState(QtCore.Qt.CheckState.Unchecked) QTest.mouseClick(self.dialog.selectAll_pushButton, Qt.LeftButton) self.assertEqual(version_item1.checkState(), QtCore.Qt.Checked) self.assertEqual(version_item2.checkState(), QtCore.Qt.Checked)
def test_exit(self): """ Tests exiting the application via File->Exit """ # Open file menu QTest.mouseClick( self.mw.menu_bar, QtCore.Qt.LeftButton, pos=self.mw.menu_bar.actionGeometry( self.mw.menu_file.menuAction()).center()) self.assertTrue(self.mw.menu_file.isVisible()) # Click exit QTest.mouseClick( self.mw.menu_file, QtCore.Qt.LeftButton, pos=self.mw.menu_view.actionGeometry(self.mw.action_exit).center()) self.app.processEvents() self.assertFalse(self.mw.isVisible())
def test_campusLinkLastYears(self): self.ui.tabWid.setCurrentIndex(2) gear = tests.mkGear('J', 10) tests.enterGearInfo(self, gear) QTest.mouseClick(self.tGear.updtBut, QtCore.Qt.LeftButton) self.ui.tabWid.setCurrentIndex(1) self.tMemb.nameSearch.clear() memb = tests.mkMember('A', 1, forms=True, campusLink=True, formsDate=Util.convert_date('Qt2DB', QtCore.QDate.currentDate().addDays(1)), campusDate=Util.convert_date('Qt2DB', QtCore.QDate.currentDate().addDays(-10))) QTest.keyClicks(self.tMemb.nameSearch, memb['FirstName'] + ' ' + memb['LastName']) tests.enterMemberInfo(self, memb) self.assertTrue(self.tMemb.Button_addUpdButClick()) self.ui.tabWid.setCurrentIndex(0) setTransGear(self, gear, 'Name') setTransMemb(self, memb) QTest.mouseClick(self.tTran.payBut, QtCore.Qt.LeftButton) QTest.mouseClick(self.tTran.payWind.payBut, QtCore.Qt.LeftButton) self.tTran.payWind.close() self.tTran.radioOut.click() self.assertTrue(self.tTran.trans())
def setUp(self): self.app = QtGui.QApplication.instance() if self.app is None: self.app = QtGui.QApplication(sys.argv) self.app.setQuitOnLastWindowClosed(True) if os.path.isfile(tests.dBName): os.remove(tests.dBName) self.ui = GearManager.MainUI(tests.dBName) self.ui.defDueDateWin.okBut.click() self.tTran = self.ui.tabWid.widget(0) self.tMemb = self.ui.tabWid.widget(1) self.tGear = self.ui.tabWid.widget(2) self.tAdmn = self.ui.tabWid.widget(3) self.ui.tabWid.setCurrentIndex(3) self.tAdmn.semFalStr.setDate(QtCore.QDate.currentDate().addDays(1)) self.tAdmn.semFalStr.setDate(QtCore.QDate.currentDate().addDays(-1)) self.tAdmn.semSprStr.setDate(QtCore.QDate.currentDate().addDays(7)) self.tAdmn.amountBox.setValue(20) self.ui.tabWid.setCurrentIndex(1) for memb in membList: self.tMemb.nameSearch.clear() tests.enterMemberInfo(self, memb) self.tMemb.Button_addUpdButClick() self.ui.tabWid.setCurrentIndex(0) for memb in membList: setTransMemb(self, memb) QTest.mouseClick(self.tTran.payBut, QtCore.Qt.LeftButton) QTest.mouseClick(self.tTran.payWind.payBut, QtCore.Qt.LeftButton) self.tTran.payWind.close() for gear in gearList: self.tGear.gNameIDSearch.clear() tests.enterGearInfo(self, gear) QTest.mouseClick(self.tGear.updtBut, QtCore.Qt.LeftButton) self.ui.tabWid.setCurrentIndex(1) self.tMemb.nameSearch.clear() self.tMemb.clear_fields() self.ui.tabWid.setCurrentIndex(2) self.tGear.gNameIDSearch.clear() self.tGear.clear_fields() self.ui.tabWid.setCurrentIndex(0) self.tTran.nameSearch.clear() self.tTran.gNameIDSearch.clear() setTransMemb(self, membList[0]) setTransGear(self, gearList[0], 'Name')
def test_hiding_history_widget_from_menu(self): """ Tests hiding and showing the history widget from the view menu. """ self.assertTrue(self.mw.history_dock_widget.isVisible()) # Open view menu QTest.mouseClick( self.mw.menu_bar, QtCore.Qt.LeftButton, pos=self.mw.menu_bar.actionGeometry( self.mw.menu_view.menuAction()).center()) self.assertTrue(self.mw.menu_view.isVisible()) # Toggle visibility action to hide it QTest.mouseClick( self.mw.menu_view, QtCore.Qt.LeftButton, pos=self.mw.menu_view.actionGeometry( self.mw.toggle_history_dock_widget_view_qaction).center()) self.assertFalse(self.mw.history_dock_widget.isVisible()) # Open view menu again QTest.mouseClick( self.mw.menu_bar, QtCore.Qt.LeftButton, pos=self.mw.menu_bar.actionGeometry( self.mw.menu_view.menuAction()).center()) self.assertTrue(self.mw.menu_view.isVisible()) # Toggle visibility action to show it again QTest.mouseClick( self.mw.menu_view, QtCore.Qt.LeftButton, pos=self.mw.menu_view.actionGeometry( self.mw.toggle_history_dock_widget_view_qaction).center()) self.assertTrue(self.mw.history_dock_widget.isVisible())
def test_send_pushButton_will_copy_mxf_files_to_media_files_folder(self): """testing if send_pushButton will copy the mxf files to media files folder """ # create a proper edl file with proper files in a temp location # there should be MXF files tempdir = tempfile.gettempdir() media_files_path = os.path.join(tempdir, 'avid_media_file_path') try: os.mkdir(media_files_path) except OSError: pass self.remove_files.append(media_files_path) mxf_file_names = [ 'SEQ001_HSNI_003_0010_v001.mxf', 'SEQ001_HSNI_003_0020_v001.mxf', 'SEQ001_HSNI_003_0030_v001.mxf' ] edl_path = os.path.abspath('../previs/test_data/test_v001.edl') for mxf_file_name in mxf_file_names: media_file_full_path = os.path.join(tempdir, mxf_file_name) with open(media_file_full_path, 'w') as f: f.write('') self.remove_files.append(media_file_full_path) # set the avid media files folder path self.dialog.media_files_path_lineEdit.setText(media_files_path) # set the edl path self.dialog.edl_path_lineEdit.setText(edl_path) # now check before the files are not there self.assertFalse( os.path.exists(os.path.join(media_files_path, mxf_file_names[0])) ) self.assertFalse( os.path.exists(os.path.join(media_files_path, mxf_file_names[1])) ) self.assertFalse( os.path.exists(os.path.join(media_files_path, mxf_file_names[2])) ) # self.show_dialog(self.dialog) # now hit it QTest.mouseClick(self.dialog.send_pushButton, Qt.LeftButton) # now check if the files are there self.assertTrue( os.path.exists(os.path.join(media_files_path, mxf_file_names[0])) ) self.assertTrue( os.path.exists(os.path.join(media_files_path, mxf_file_names[1])) ) self.assertTrue( os.path.exists(os.path.join(media_files_path, mxf_file_names[2])) )
def test_copy_button_is_working_properly(self): """testing if the copy button is working properly """ # Select Task4 in from_task_tree_view selection_model = self.dialog.from_task_tree_view.selectionModel() model = self.dialog.from_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.from_task_tree_view.expand(project1_item.index()) task1_item = project1_item.child(0, 0) self.dialog.from_task_tree_view.expand(task1_item.index()) task4_item = task1_item.child(0, 0) selection_model.select( task4_item.index(), QtGui.QItemSelectionModel.Select ) # Select Task8 in to_task_tree_view selection_model = self.dialog.to_task_tree_view.selectionModel() model = self.dialog.to_task_tree_view.model() project1_item = model.item(0, 0) self.dialog.to_task_tree_view.expand(project1_item.index()) task2_item = project1_item.child(1, 0) self.dialog.to_task_tree_view.expand(task2_item.index()) task8_item = task2_item.child(1, 0) selection_model.select( task8_item.index(), QtGui.QItemSelectionModel.Select ) # before copying anything # check if there are no versions under Task8 self.assertTrue(self.test_task8.versions == []) self.assertEqual(len(self.test_task4.versions), 9) take_name_count = db.DBSession\ .query(distinct(Version.take_name))\ .filter(Version.task == self.test_task4)\ .count() self.assertEqual(take_name_count, 3) # for testing purposes set question result to QtGui.QMessageBox.Yes PatchedMessageBox.Yes = self.original_message_box.Yes PatchedMessageBox.No = self.original_message_box.No PatchedMessageBox.question_return_value = self.original_message_box.Yes # copy it QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton) # and expect as many versions under task8 as the task4 take_names # check if it still has 9 versions self.assertEqual(len(self.test_task4.versions), 9) self.assertEqual( len(self.test_task8.versions), take_name_count ) # check if files are copied there for version in self.test_task8.versions: self.assertTrue(os.path.exists(version.absolute_full_path))