Ejemplo n.º 1
0
 def test_warn_about_old_database(self, mock_messagebar,
                                  mock_latest_version):
     mock_latest_version.return_value = '999.999.999'
     utils.warn_about_old_database()
     print(str(mock_messagebar.mock_calls))
     assert call.info(
         bar_msg=
         'The database version appears to be older than 999.999.999. An upgrade is suggested! See https://github.com/jkall/qgis-midvatten-plugin/wiki/6.-Database-management#upgrade-database',
         duration=5) in mock_messagebar.mock_calls
 def test_warn_about_view_obs_lines_missing(self, mock_messagebar,
                                            mock_latest_version):
     mock_latest_version.return_value = '0.0.1'
     db_utils.sql_alter_db('''DROP VIEW view_obs_lines;''')
     utils.warn_about_old_database()
     print(str(mock_messagebar.mock_calls))
     assert call.warning(
         bar_msg=
         'Database is missing view_obs_points or view_obs_lines! Add these using Midvatten>Database Management>Add view_obs_points as workaround for qgis bug #20633.',
         duration=60) in mock_messagebar.mock_calls
 def set_db(self):
     if self.connection:
         self.midvsettingsdialogdock.ms.settingsdict[
             'database'] = utils.anything_to_string_representation(
                 {'postgis': {
                     'connection': self.connection
                 }})
         self.midvsettingsdialogdock.ms.save_settings('database')
         self.midvsettingsdialogdock.load_plot_settings()
         warn_about_old_database()
 def select_file(self):
     """ Open a dialog to locate the sqlite file and some more..."""
     dbpath, __ = QFileDialog.getOpenFileName(None, str("Select database:"), "*.sqlite")
     if dbpath:  # Only get new db name if not cancelling the FileDialog
         self.dbpath = dbpath
         self.midvsettingsdialogdock.ms.settingsdict['database'] = utils.anything_to_string_representation({'spatialite': {'dbpath': dbpath}})
         self.midvsettingsdialogdock.ms.save_settings('database')
         self.midvsettingsdialogdock.load_plot_settings()
         warn_about_old_database()
     else:  # debug
         utils.MessagebarAndLog.info(log_msg=ru(QCoreApplication.translate('SpatialiteSettings', "DB selection cancelled and still using database path %s"))%utils.returnunicode(self.midvsettingsdialogdock.ms.settingsdict['database']))
 def select_file(self):
     """ Open a dialog to locate the sqlite file and some more..."""
     dbpath, __ = QFileDialog.getOpenFileName(None, str("Select database:"),
                                              "*.sqlite")
     if dbpath:  # Only get new db name if not cancelling the FileDialog
         self.dbpath = dbpath
         self.midvsettingsdialogdock.ms.settingsdict[
             'database'] = utils.anything_to_string_representation(
                 {'spatialite': {
                     'dbpath': dbpath
                 }})
         self.midvsettingsdialogdock.ms.save_settings('database')
         self.midvsettingsdialogdock.load_plot_settings()
         warn_about_old_database()
     else:  # debug
         utils.MessagebarAndLog.info(log_msg=ru(
             QCoreApplication.translate(
                 'SpatialiteSettings',
                 "DB selection cancelled and still using database path %s")
         ) % utils.returnunicode(
             self.midvsettingsdialogdock.ms.settingsdict['database']))
 def set_db(self):
     if self.connection:
         self.midvsettingsdialogdock.ms.settingsdict['database'] = utils.anything_to_string_representation({'postgis': {'connection': self.connection}})
         self.midvsettingsdialogdock.ms.save_settings('database')
         self.midvsettingsdialogdock.load_plot_settings()
         warn_about_old_database()
Ejemplo n.º 7
0
 def test_warn_about_old_database_not_old(self, mock_messagebar,
                                          mock_latest_version):
     mock_latest_version.return_value = '0.0.1'
     utils.warn_about_old_database()
     assert not mock_messagebar.mock_calls
Ejemplo n.º 8
0
 def test_warn_about_view_obs_lines_missing_assert_no_msg(
         self, mock_messagebar, mock_latest_version):
     mock_latest_version.return_value = '0.0.1'
     utils.warn_about_old_database()
     assert not mock_messagebar.mock_calls
 def test_warn_about_view_obs_points_missing_assert_no_msg(self, mock_messagebar, mock_latest_version):
     mock_latest_version.return_value = '0.0.1'
     utils.warn_about_old_database()
     assert not mock_messagebar.mock_calls
 def test_warn_about_old_database_not_old(self, mock_messagebar, mock_latest_version):
     mock_latest_version.return_value = '0.0.1'
     utils.warn_about_old_database()
     assert not mock_messagebar.mock_calls
 def test_warn_about_old_database(self, mock_messagebar, mock_latest_version):
     mock_latest_version.return_value = '999.999.999'
     utils.warn_about_old_database()
     print(str(mock_messagebar.mock_calls))
     assert call.info(bar_msg='The database version appears to be older than 999.999.999. An upgrade is suggested! See https://github.com/jkall/qgis-midvatten-plugin/wiki/6.-Database-management#upgrade-database', duration=120) in mock_messagebar.mock_calls
 def test_warn_about_view_obs_lines_missing(self, mock_messagebar, mock_latest_version):
     mock_latest_version.return_value = '0.0.1'
     db_utils.sql_alter_db('''DROP VIEW view_obs_lines;''')
     utils.warn_about_old_database()
     print(str(mock_messagebar.mock_calls))
     assert call.warning(bar_msg='Database is missing view_obs_points or view_obs_lines! Add these using Midvatten>Database Management>Add view_obs_points as workaround for qgis bug #20633.', duration=60) in mock_messagebar.mock_calls