def testInitGui(self): """Check that the plugin create the relative action and register self.test linked to the action.""" # preconditions testerPlugin = TesterPlugin(self.IFACE_Mock) self.assertNotIn('action', testerPlugin.__dict__) # do test testerPlugin.iface.reset_mock testerPlugin.initGui() self.assertIsNotNone(testerPlugin.action) self.assertTrue(isinstance(testerPlugin.action, QtGui.QAction)) self.assertTrue(testerPlugin.action.receivers( QtCore.SIGNAL('triggered()')) == 1) self.assertIn("call.addPluginToMenu(u'Tester'", str(testerPlugin.iface.mock_calls[-1]))
def testInitGui(self): """Check that the plugin UI initialised correctly""" testerPlugin = TesterPlugin(self.IFACE_Mock) self.assertNotIn('action', testerPlugin.__dict__) testerPlugin.iface.reset_mock() testerPlugin.initGui() self.assertIsNotNone(testerPlugin.action) self.assertTrue(isinstance(testerPlugin.action, QAction)) self.assertEqual( testerPlugin.action.receivers(testerPlugin.action.triggered), 1) # number of calls to addPluginToMenu should be equal to the number of actions in the plugin menu self.assertEqual( sum( map(lambda x: 'addPluginToMenu' in x, testerPlugin.iface.mock_calls)), 3)
def testInitGui(self): """Check that the plugin create the relative action and register self.test linked to the action.""" # preconditions testerPlugin = TesterPlugin(self.IFACE_Mock) self.assertNotIn('action', testerPlugin.__dict__) # do test testerPlugin.iface.reset_mock testerPlugin.initGui() self.assertIsNotNone(testerPlugin.action) self.assertTrue(isinstance(testerPlugin.action, QAction)) if isPyQt4: self.assertTrue(testerPlugin.action.receivers( SIGNAL('triggered()')) == 1) else: self.assertTrue(testerPlugin.action.receivers( testerPlugin.action.triggered) == 1) if isPyQt4: self.assertIn("call.addPluginToMenu(u'Tester'", str(testerPlugin.iface.mock_calls[-1])) else: self.assertIn("call.addPluginToMenu('Tester'", str(testerPlugin.iface.mock_calls[-1]))