示例#1
0
    def show_batch_runner(self):
        """Show the batch runner dialog."""
        from safe.gui.tools.batch.batch_dialog import BatchDialog

        dialog = BatchDialog(parent=self.iface.mainWindow(),
                             iface=self.iface,
                             dock=self.dock_widget)
        dialog.exec_()  # modal
示例#2
0
 def test_run_all_scenario(self):
     """Test run all scenarii."""
     scenarios_dir = standard_data_path('control', 'scenarios')
     dialog = BatchDialog(PARENT, IFACE, self.dock)
     dialog.show_results_popup = False
     dialog.scenario_directory_radio.setChecked(False)
     dialog.source_directory.setText(scenarios_dir)
     dialog.source_directory.textChanged.emit(scenarios_dir)
     out_path = temp_dir()
     dialog.output_directory.setText(out_path)
     button = dialog.run_all_button
     button.click()
     status0 = dialog.table.item(0, 1).text()
     status1 = dialog.table.item(1, 1).text()
     self.assertEquals(status0, 'Analysis Fail')
     self.assertEquals(status1, 'Report Ok')
示例#3
0
 def test_run_single_scenario(self):
     """Test run single scenario."""
     scenarios_dir = test_data_path('control', 'scenarios')
     dialog = BatchDialog(PARENT, IFACE, DOCK)
     dialog.show_results_popup = False
     dialog.scenario_directory_radio.setChecked(False)
     dialog.source_directory.setText(scenarios_dir)
     dialog.source_directory.textChanged.emit(scenarios_dir)
     out_path = temp_dir()
     dialog.output_directory.setText(out_path)
     dialog.table.selectRow(1)
     button = dialog.run_selected_button
     button.click()
     status = dialog.table.item(1, 1).text()
     expected_status = 'Report Ok'
     message = 'Expected %s but got %s' % (expected_status, status)
     self.assertEqual(status, expected_status, message)
示例#4
0
 def test_load_batch_dialog(self):
     """Test for BatchDialog behaviour.
     """
     scenarios_dir = standard_data_path('control', 'scenarios')
     dialog = BatchDialog(PARENT, IFACE, self.dock)
     dialog.show_results_popup = False
     dialog.scenario_directory_radio.setChecked(True)
     dialog.source_directory.setText(scenarios_dir)
     dialog.source_directory.textChanged.emit(scenarios_dir)
     number_row = dialog.table.rowCount()
     self.assertEquals(number_row, 2,
                       'Num scenario should be 2, but got %s' % number_row)
     out_path = dialog.output_directory.text()
     self.assertEquals(out_path, scenarios_dir)
     dialog.scenario_directory_radio.setChecked(False)
     dialog.output_directory.setText('not a dir')
     out_path = dialog.output_directory.text()
     dialog.scenario_directory_radio.setText(scenarios_dir + 'a')
     dialog.scenario_directory_radio.setText(scenarios_dir)
     self.assertNotEqual(out_path, scenarios_dir)
示例#5
0
 def test_load_batch_dialog(self):
     """Test for BatchDialog behaviour.
     """
     scenarios_dir = test_data_path('control', 'scenarios')
     dialog = BatchDialog(PARENT, IFACE, DOCK)
     dialog.show_results_popup = False
     dialog.scenario_directory_radio.setChecked(True)
     dialog.source_directory.setText(scenarios_dir)
     dialog.source_directory.textChanged.emit(scenarios_dir)
     print "Testing using : %s" % scenarios_dir
     number_row = dialog.table.rowCount()
     self.assertTrue(number_row == 2,
                     'Num scenario is wrong. I got %s' % number_row)
     out_path = dialog.output_directory.text()
     self.assertTrue(out_path == scenarios_dir,
                     'Output directory is %s' % out_path)
     dialog.scenario_directory_radio.setChecked(False)
     dialog.output_directory.setText('not a dir')
     out_path = dialog.output_directory.text()
     dialog.scenario_directory_radio.setText(scenarios_dir + 'a')
     dialog.scenario_directory_radio.setText(scenarios_dir)
     self.assertTrue(out_path != scenarios_dir,
                     'Output directory is %s' % out_path)