class GeobricksQgisPluginWorldBankDialogTest(unittest.TestCase): """Test dialog works.""" def setUp(self): """Runs before each test.""" self.dialog = GeobricksQgisPluginWorldBankDialog(None) def tearDown(self): """Runs after each test.""" self.dialog = None def test_dialog_ok(self): """Test we can click OK.""" button = self.dialog.button_box.button(QDialogButtonBox.Ok) button.click() result = self.dialog.result() self.assertEqual(result, QDialog.Accepted) def test_dialog_cancel(self): """Test we can click cancel.""" button = self.dialog.button_box.button(QDialogButtonBox.Cancel) button.click() result = self.dialog.result() self.assertEqual(result, QDialog.Rejected)
def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QSettings().value('locale/userLocale')[0:2] locale_path = os.path.join( self.plugin_dir, 'i18n', 'GeobricksQgisPluginWorldBank_{}.qm'.format(locale)) if os.path.exists(locale_path): self.translator = QTranslator() self.translator.load(locale_path) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) # Create the dialog (after translation) and keep reference self.dlg = GeobricksQgisPluginWorldBankDialog() # Declare instance attributes self.actions = [] self.menu = self.tr(u'Download Data') # TODO: We are going to let the user set this up in a future iteration self.toolbar = self.iface.addToolBar(u'World Bank') self.toolbar.setObjectName(u'GeobricksQgisPluginWorldBank') # TODO: check if there is a better way to handle inizialition self.initialized = False # ID used for the messagebar self.QGSMESSAGEBAR_ID = 'GeobricksWorldBankPlugin'
def setUp(self): """Runs before each test.""" self.dialog = GeobricksQgisPluginWorldBankDialog(None)