def test_behaviour(self): """Test behaviour of elements in the dialog """ myDialog = ConverterDialog(PARENT) myDialog.cBDefaultOutputLocation.setEnabled(True) my_grid_path = os.path.join(TESTDATA, 'grid.xml') myDialog.leInputPath.setText(my_grid_path) input_path = myDialog.leInputPath.text() output_path = myDialog.leOutputPath.text() assert myDialog.isEnabled(), 'Output location should be disabled' expected_output_path = input_path[:-3] + 'tif' assert output_path == expected_output_path, \ 'Expected %s got %s' % (expected_output_path, output_path)
def test_initDialog(self): """Test for showing table in the first.""" myDialog = ConverterDialog(PARENT) assert myDialog is not None, 'Dialog is failed to created' # testing populate algorithm expected_algorithms = ['Nearest', 'Invdist'] assert myDialog.cboAlgorithm.count() == len(expected_algorithms), \ 'Number of algorithm is not same' for i in list(xrange(len(expected_algorithms))): assert expected_algorithms[i] == str( myDialog.cboAlgorithm.itemText(i)), \ ('Algorithm is not same, expect %s got %s') % \ (expected_algorithms[i], myDialog.cboAlgorithm.itemText(i))
def Xtest_Converting(self): """Test converting a file """ myDialog = ConverterDialog(PARENT) myDialog.test_mode = True myDialog.cBDefaultOutputLocation.setEnabled(False) my_grid_path = os.path.join(TESTDATA, 'grid.xml') my_output_raster = unique_filename(prefix='result_grid', suffix='.tif', dir=temp_dir('test')) myDialog.cBLoadLayer.setEnabled(True) myDialog.leInputPath.setText(my_grid_path) myDialog.leOutputPath.setText(my_output_raster) myButton = myDialog.buttonBox.button(QDialogButtonBox.Ok) QTest.mouseClick(myButton, Qt.LeftButton) assert os.path.exists(my_output_raster), 'Raster is not created'
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # i18n support override_locale = QSettings().value('locale/overrideFlag', False, type=bool) if not override_locale: locale_full_name = QLocale.system().name() else: locale_full_name = QSettings().value('locale/userLocale', '', type=unicode) self.locale_path = '%s/i18n/rugeocoder_%s.qm' % (_current_path, locale_full_name[0:2]) if QFileInfo(self.locale_path).exists(): self.translator = QTranslator() self.translator.load(self.locale_path) QCoreApplication.installTranslator(self.translator) # menu && toolbars self.menu_name = self.tr(u'&RuGeocoder') self.toolbar = self.iface.addToolBar(self.menu_name) self.toolbar.setObjectName(u'RuGeocoderToolbar') # instances self.__converter_dlg = ConverterDialog() self.__geocoder_dlg = BatchGeocodingDialog() # Dock tree panel self.__quick_tlb = QuickGeocodingToolbox(self.iface) self.iface.addDockWidget(PluginSettings.dock_area(), self.__quick_tlb) self.__quick_tlb.setFloating(PluginSettings.dock_floating()) self.__quick_tlb.resize(PluginSettings.dock_size()) self.__quick_tlb.move(PluginSettings.dock_pos()) self.__quick_tlb.setVisible(PluginSettings.dock_visibility()) self.__quick_tlb.set_active_geocoder( PluginSettings.dock_geocoder_name()) self.__quick_tlb.setWindowIcon( QIcon(path.join(_current_path, 'edit-find-project.png')))
def run_convert(self): if not self.__converter_dlg.isVisible(): self.__converter_dlg = ConverterDialog() self.__converter_dlg.show() self.__converter_dlg.exec_()