Exemplo n.º 1
0
    def __init__(self, parent, afefuc):
        self.parent = parent

        self.can = QtGui.QWidget(self.parent)
        self.tab = Ui_ItemsTabGen()
        self.numRegEx = re.compile(r'(.*\()(\d+)(\))$')

        self.afefuc = afefuc
Exemplo n.º 2
0
	def __init__(self, parent, afefuc):
		self.parent = parent

		self.can = QtGui.QWidget(self.parent)
		self.tab = Ui_ItemsTabGen()
		self.numRegEx = re.compile(r'(.*\()(\d+)(\))$')

		self.afefuc = afefuc
Exemplo n.º 3
0
class TestCasesTabWrapper():
	def __init__(self, parent, afefuc):
		self.parent = parent

		self.can = QtGui.QWidget(self.parent)
		self.tab = Ui_ItemsTabGen()
		self.numRegEx = re.compile(r'(.*\()(\d+)(\))$')

		self.afefuc = afefuc

	def show(self):
		self.tab.setupUi(self.can)

		self.model = TestCasesTableModel(self.tab.itemsView, self.afefuc)
		self.tab.itemsView.setModel(self.model)
		self.tab.itemsView.horizontalHeader().setResizeMode(0, QtGui.QHeaderView.ResizeToContents)
		self.tab.itemsView.horizontalHeader().setResizeMode(1, QtGui.QHeaderView.Stretch)
		self.tab.itemsView.horizontalHeader().hide()
		self.tab.itemsView.verticalHeader().hide()
		self.tab.itemsView.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
		self.tab.itemsView.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)

		QtCore.QObject.connect(self.tab.generateButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedGenerateButton)
		QtCore.QObject.connect(self.tab.addButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedAddButton)
		QtCore.QObject.connect(self.tab.cloneButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedCloneButton)
		QtCore.QObject.connect(self.tab.deleteButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedDeleteButton)
		QtCore.QObject.connect(self.tab.editButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedEditButton)
		QtCore.QObject.connect(self.tab.moveUpButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedMoveUpButton)
		QtCore.QObject.connect(self.tab.moveDownButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.clickedMoveDownButton)

		self.parent.mainWindow.tabWidget.addTab(self.can, _fromUtf8("Test Cases"))

	def load(self):
		self.model.reset()

	def clickedGenerateButton(self):
		form = SelectUseCaseFormWrapper(self, self.afefuc)
		form.show()

	def clickedAddButton(self):
		tc = model.TestCase()
#       uc.setParent(self.afefuc['project'])
		TestCaseFormWrapper(self, self.afefuc, (None, tc)).show()
		pass

	def clickedCloneButton(self):
		if len(self.tab.itemsView.selectedIndexes()) == 2:
			position = self.tab.itemsView.selectedIndexes()[0].row()
			original = self.afefuc['project'].testcases.tests[position]
			tc = clone.testcase(original, self.afefuc['project'])

			matchTitle = self.numRegEx.match(tc.title)
			if matchTitle:
				n = int(matchTitle.group(2))
				n += 1
			else:
				n = 2
				tc.title = tc.title + ' (2)'
				matchTitle = self.numRegEx.match(tc.title)

			matchIdentifier = self.numRegEx.match(tc.identifier)
			if matchIdentifier:
				m = int(matchIdentifier.group(2))
				m += 1
			else:
				m = 2
				tc.identifier = tc.identifier + ' (2)'
				matchIdentifier = self.numRegEx.match(tc.identifier)

			num = max(n, m)

			ok = False
			while ok is False:
				ok = True
				for test in self.afefuc['project'].testcases.tests:
					newValue = r'\g<1>' + str(num) + r'\g<3>'
					newTitle = self.numRegEx.sub(newValue,tc.title) 
					newIdentifier = self.numRegEx.sub(newValue, tc.identifier)
					if test.title == newTitle or test.identifier == newIdentifier:
						num += 1
						ok = False
						break

			tc.title = self.numRegEx.sub(r'\g<1>' + str(num) + r'\g<3>', tc.title)
			tc.identifier = self.numRegEx.sub(r'\g<1>' + str(num) + r'\g<3>', tc.identifier)

			self.model.insertItem((None,tc), position+1)

	def clickedDeleteButton(self):
		if len(self.tab.itemsView.selectedIndexes()) == 2:
			position = self.tab.itemsView.selectedIndexes()[0].row()
			self.model.removeItem(position)

	def clickedEditButton(self):
		if len(self.tab.itemsView.selectedIndexes()) == 2:
			position = self.tab.itemsView.selectedIndexes()[0].row()
			original = self.afefuc['project'].testcases.tests[position]
			tc = clone.testcase(original, self.afefuc['project'])
			TestCaseFormWrapper(self, self.afefuc, item = (original, tc)).show()

	def clickedMoveUpButton(self):
		if len(self.tab.itemsView.selectedIndexes()) == 2:
			position = self.tab.itemsView.selectedIndexes()[0].row()

			self.model.movePositionUp(position)
			self.tab.itemsView.selectRow(position - 1)

	def clickedMoveDownButton(self):
		if len(self.tab.itemsView.selectedIndexes()) == 2:
			position = self.tab.itemsView.selectedIndexes()[0].row()

			self.model.movePositionUp(position + 1)
			self.tab.itemsView.selectRow(position + 1)
Exemplo n.º 4
0
class TestCasesTabWrapper():
    def __init__(self, parent, afefuc):
        self.parent = parent

        self.can = QtGui.QWidget(self.parent)
        self.tab = Ui_ItemsTabGen()
        self.numRegEx = re.compile(r'(.*\()(\d+)(\))$')

        self.afefuc = afefuc

    def show(self):
        self.tab.setupUi(self.can)

        self.model = TestCasesTableModel(self.tab.itemsView, self.afefuc)
        self.tab.itemsView.setModel(self.model)
        self.tab.itemsView.horizontalHeader().setResizeMode(
            0, QtGui.QHeaderView.ResizeToContents)
        self.tab.itemsView.horizontalHeader().setResizeMode(
            1, QtGui.QHeaderView.Stretch)
        self.tab.itemsView.horizontalHeader().hide()
        self.tab.itemsView.verticalHeader().hide()
        self.tab.itemsView.setSelectionBehavior(
            QtGui.QAbstractItemView.SelectRows)
        self.tab.itemsView.setSelectionMode(
            QtGui.QAbstractItemView.SingleSelection)

        QtCore.QObject.connect(self.tab.generateButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedGenerateButton)
        QtCore.QObject.connect(self.tab.addButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedAddButton)
        QtCore.QObject.connect(self.tab.cloneButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedCloneButton)
        QtCore.QObject.connect(self.tab.deleteButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedDeleteButton)
        QtCore.QObject.connect(self.tab.editButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedEditButton)
        QtCore.QObject.connect(self.tab.moveUpButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedMoveUpButton)
        QtCore.QObject.connect(self.tab.moveDownButton,
                               QtCore.SIGNAL(_fromUtf8("clicked()")),
                               self.clickedMoveDownButton)

        self.parent.mainWindow.tabWidget.addTab(self.can,
                                                _fromUtf8("Test Cases"))

    def load(self):
        self.model.reset()

    def clickedGenerateButton(self):
        form = SelectUseCaseFormWrapper(self, self.afefuc)
        form.show()

    def clickedAddButton(self):
        tc = model.TestCase()
        #       uc.setParent(self.afefuc['project'])
        TestCaseFormWrapper(self, self.afefuc, (None, tc)).show()
        pass

    def clickedCloneButton(self):
        if len(self.tab.itemsView.selectedIndexes()) == 2:
            position = self.tab.itemsView.selectedIndexes()[0].row()
            original = self.afefuc['project'].testcases.tests[position]
            tc = clone.testcase(original, self.afefuc['project'])

            matchTitle = self.numRegEx.match(tc.title)
            if matchTitle:
                n = int(matchTitle.group(2))
                n += 1
            else:
                n = 2
                tc.title = tc.title + ' (2)'
                matchTitle = self.numRegEx.match(tc.title)

            matchIdentifier = self.numRegEx.match(tc.identifier)
            if matchIdentifier:
                m = int(matchIdentifier.group(2))
                m += 1
            else:
                m = 2
                tc.identifier = tc.identifier + ' (2)'
                matchIdentifier = self.numRegEx.match(tc.identifier)

            num = max(n, m)

            ok = False
            while ok is False:
                ok = True
                for test in self.afefuc['project'].testcases.tests:
                    newValue = r'\g<1>' + str(num) + r'\g<3>'
                    newTitle = self.numRegEx.sub(newValue, tc.title)
                    newIdentifier = self.numRegEx.sub(newValue, tc.identifier)
                    if test.title == newTitle or test.identifier == newIdentifier:
                        num += 1
                        ok = False
                        break

            tc.title = self.numRegEx.sub(r'\g<1>' + str(num) + r'\g<3>',
                                         tc.title)
            tc.identifier = self.numRegEx.sub(r'\g<1>' + str(num) + r'\g<3>',
                                              tc.identifier)

            self.model.insertItem((None, tc), position + 1)

    def clickedDeleteButton(self):
        if len(self.tab.itemsView.selectedIndexes()) == 2:
            position = self.tab.itemsView.selectedIndexes()[0].row()
            self.model.removeItem(position)

    def clickedEditButton(self):
        if len(self.tab.itemsView.selectedIndexes()) == 2:
            position = self.tab.itemsView.selectedIndexes()[0].row()
            original = self.afefuc['project'].testcases.tests[position]
            tc = clone.testcase(original, self.afefuc['project'])
            TestCaseFormWrapper(self, self.afefuc, item=(original, tc)).show()

    def clickedMoveUpButton(self):
        if len(self.tab.itemsView.selectedIndexes()) == 2:
            position = self.tab.itemsView.selectedIndexes()[0].row()

            self.model.movePositionUp(position)
            self.tab.itemsView.selectRow(position - 1)

    def clickedMoveDownButton(self):
        if len(self.tab.itemsView.selectedIndexes()) == 2:
            position = self.tab.itemsView.selectedIndexes()[0].row()

            self.model.movePositionUp(position + 1)
            self.tab.itemsView.selectRow(position + 1)