コード例 #1
0
    def testShowPopupMenu(self):
        """check if a menu popup is opened if issue url is present."""
        # test1
        # preconditions
        r = Report()
        for test in self.allTests:
            tr = TestResult(test)
            r.addTestResult(tr)
        dlg = ReportDialog(r)  # dlg.resultsTree is a QTreeWidget
        dlg.resultsTree.topLevelItem(0).child(1).setSelected(
            True)  # select 'Test that fails' that does NOT have url
        # do test
        point = QtCore.QPoint(0, 0)
        qmenuMock = mock.Mock(spec=QtGui.QMenu)
        qactionMock = mock.Mock(spec=QtGui.QAction)
        with mock.patch('PyQt4.QtGui.QMenu', qmenuMock):
            with mock.patch('PyQt4.QtGui.QAction', qactionMock):
                dlg.showPopupMenu(point)
        self.assertTrue(qmenuMock.mock_calls == [])
        self.assertTrue(qactionMock.mock_calls == [])

        # test2
        # preconditions
        r = Report()
        for test in self.allTests:
            tr = TestResult(test)
            r.addTestResult(tr)
        dlg = ReportDialog(r)  # dlg.resultsTree is a QTreeWidget
        dlg.resultsTree.topLevelItem(0).child(0).setSelected(
            True)  # select 'Functional tests' that does have url
        # do test
        point = QtCore.QPoint(0, 0)
        qmenuMock = mock.Mock(spec=QtGui.QMenu)
        qactionMock = mock.Mock(spec=QtGui.QAction)
        with mock.patch('qgistester.reportdialog.QMenu', qmenuMock):
            with mock.patch('qgistester.reportdialog.QAction', qactionMock):
                self.assertEquals(
                    dlg.resultsTree.selectedItems()[0].result.test.issueUrl,
                    'http://www.example.com')
                dlg.showPopupMenu(point)
        self.assertIn('call()', str(qmenuMock.mock_calls[0]))
        self.assertIn('call().addAction', str(qmenuMock.mock_calls[1]))
        self.assertIn('call().exec_(PyQt4.QtCore.QPoint())',
                      str(qmenuMock.mock_calls[2]))
        self.assertIn("call('Open issue page', None)",
                      str(qactionMock.mock_calls[0]))
        self.assertIn("call().triggered.connect",
                      str(qactionMock.mock_calls[1]))
コード例 #2
0
    def testShowPopupMenu(self):
        """Check if a context menu is opened when issue url is present"""
        # check with 'Test that fails' item which does NOT have an url
        r = Report()
        for test in self.allTests:
            tr = TestResult(test)
            r.addTestResult(tr)
        dlg = ReportDialog(r)
        dlg.resultsTree.topLevelItem(0).child(1).setSelected(True)
        point = QPoint(0, 0)
        qmenuMock = mock.Mock(spec=QMenu)
        qactionMock = mock.Mock(spec=QAction)
        with mock.patch('PyQt5.QtWidgets.QMenu', qmenuMock):
            with mock.patch('PyQt5.QtWidgets.QAction', qactionMock):
                dlg.showPopupMenu(point)

        self.assertEqual(qmenuMock.mock_calls, [])
        self.assertEqual(qactionMock.mock_calls, [])

        # check with 'Functional tests' that does have an url
        r = Report()
        for test in self.allTests:
            tr = TestResult(test)
            r.addTestResult(tr)
        dlg = ReportDialog(r)
        dlg.resultsTree.topLevelItem(0).child(0).setSelected(True)
        point = QPoint(0, 0)
        qmenuMock = mock.Mock(spec=QMenu)
        qactionMock = mock.Mock(spec=QAction)
        with mock.patch('qgistester.reportdialog.QMenu', qmenuMock):
            with mock.patch('qgistester.reportdialog.QAction', qactionMock):
                self.assertEqual(
                    dlg.resultsTree.selectedItems()[0].result.test.issueUrl,
                    'http://www.example.com')
                dlg.showPopupMenu(point)
        self.assertIn('call()', str(qmenuMock.mock_calls[0]))
        self.assertIn('call().addAction', str(qmenuMock.mock_calls[1]))
        self.assertIn('call().exec_(PyQt5.QtCore.QPoint())',
                      str(qmenuMock.mock_calls[2]))
        self.assertIn("call('Open issue page', None)",
                      str(qactionMock.mock_calls[0]))
        self.assertIn("call().triggered.connect",
                      str(qactionMock.mock_calls[1]))
コード例 #3
0
    def testShowPopupMenu(self):
        """check if a menu popup is opened if issue url is present."""
        # test1
        # preconditions
        r = Report()
        for test in self.allTests:
            tr = TestResult(test)
            r.addTestResult(tr)
        dlg = ReportDialog(r)  # dlg.resultsTree is a QTreeWidget
        dlg.resultsTree.topLevelItem(0).child(1).setSelected(True)  # select 'Test that fails' that does NOT have url
        # do test
        point = QPoint(0, 0)
        qmenuMock = mock.Mock(spec=QMenu)
        qactionMock = mock.Mock(spec=QAction)
        if isPyQt4:
            with mock.patch("PyQt4.QtGui.QMenu", qmenuMock):
                with mock.patch("PyQt4.QtGui.QAction", qactionMock):
                    dlg.showPopupMenu(point)
        else:
            with mock.patch("PyQt5.QtWidgets.QMenu", qmenuMock):
                with mock.patch("PyQt5.QtWidgets.QAction", qactionMock):
                    dlg.showPopupMenu(point)

        self.assertTrue(qmenuMock.mock_calls == [])
        self.assertTrue(qactionMock.mock_calls == [])

        # test2
        # preconditions
        r = Report()
        for test in self.allTests:
            tr = TestResult(test)
            r.addTestResult(tr)
        dlg = ReportDialog(r)  # dlg.resultsTree is a QTreeWidget
        dlg.resultsTree.topLevelItem(0).child(0).setSelected(True)  # select 'Functional tests' that does have url
        # do test
        point = QPoint(0, 0)
        qmenuMock = mock.Mock(spec=QMenu)
        qactionMock = mock.Mock(spec=QAction)
        with mock.patch("qgistester.reportdialog.QMenu", qmenuMock):
            with mock.patch("qgistester.reportdialog.QAction", qactionMock):
                self.assertEqual(dlg.resultsTree.selectedItems()[0].result.test.issueUrl, "http://www.example.com")
                dlg.showPopupMenu(point)
        self.assertIn("call()", str(qmenuMock.mock_calls[0]))
        self.assertIn("call().addAction", str(qmenuMock.mock_calls[1]))
        if isPyQt4:
            self.assertIn("call().exec_(PyQt4.QtCore.QPoint())", str(qmenuMock.mock_calls[2]))
        else:
            self.assertIn("call().exec_(PyQt5.QtCore.QPoint())", str(qmenuMock.mock_calls[2]))

        self.assertIn("call('Open issue page', None)", str(qactionMock.mock_calls[0]))
        self.assertIn("call().triggered.connect", str(qactionMock.mock_calls[1]))