def show_welcome_message(self): """Show the welcome message.""" # import here only so that it is AFTER i18n set up from safe.gui.tools.options_dialog import OptionsDialog # Do not show by default show_message = False previous_version = StrictVersion(setting('previous_version')) current_version = StrictVersion(inasafe_version) # Set previous_version to the current inasafe_version set_setting('previous_version', inasafe_version) if setting('always_show_welcome_message', expected_type=bool): # Show if it the setting said so show_message = True elif previous_version < current_version: # Always show if the user installed new version show_message = True # Allow to disable welcome message when running automated tests if os.environ.get('INASAFE_DISABLE_WELCOME_MESSAGE', False): show_message = False if show_message: dialog = OptionsDialog(iface=self.iface, parent=self.iface.mainWindow()) dialog.show_welcome_dialog() if dialog.exec_(): # modal self.dock_widget.read_settings()
def test_mode(self): """Test for checking that the state is correct for the mode. If your test is failed, perhaps one the following is the cause: 1. You add / remove tab in the options. 2. You rename the tab's name. 3. The function show_welcome_dialog or show_option_dialog is changed """ # Welcome mode dialog = OptionsDialog(parent=PARENT, iface=IFACE) dialog.show_welcome_dialog() expected_tabs = [ dialog.welcome_tab, dialog.organisation_profile_tab, dialog.preference_tab ] message = 'Tab count should be %d in welcome dialog.' % len( expected_tabs) self.assertEqual(dialog.tabWidget.count(), len(expected_tabs), message) message = 'Current tab index should be 0.' self.assertEqual(dialog.tabWidget.currentIndex(), 0, message) for index, expected_tab in enumerate(expected_tabs): dialog.tabWidget.setCurrentIndex(index) message = 'Current tab should be %s.' % expected_tab.objectName() current_tab = dialog.tabWidget.currentWidget() self.assertEqual(current_tab, expected_tab, message) # Usual option mode dialog = OptionsDialog(parent=PARENT, iface=IFACE) dialog.show_option_dialog() expected_tabs = [ dialog.organisation_profile_tab, dialog.preference_tab, dialog.gis_environment_tab, dialog.earthquake_tab, dialog.template_option_tab, dialog.demographic_defaults_tab, dialog.advanced_tab ] message = 'Tab count should be %d in welcome dialog.' % len( expected_tabs) self.assertEqual(dialog.tabWidget.count(), len(expected_tabs), message) message = 'Current tab index should be 0.' self.assertEqual(dialog.tabWidget.currentIndex(), 0, message) for index, expected_tab in enumerate(expected_tabs): dialog.tabWidget.setCurrentIndex(index) message = 'Current tab should be %s.' % expected_tab.objectName() current_tab = dialog.tabWidget.currentWidget() self.assertEqual(current_tab, expected_tab, message)