def test_check_unmodifiable_strings(self): # This test case asserts that data migration updates unmodifiable l10n strings self._initStartDB(34) notification_l10n = NotificationL10NFactory(self.store) t0 = notification_l10n.get_val('export_template', 'it') notification_l10n.set_val('export_template', 'it', '') t1 = notification_l10n.get_val('export_template', 'it') self.assertEqual(t1, '') self.store.commit() # place a dummy version in the current db store = Store(create_database(GLSettings.db_uri)) prv = config.PrivateFactory(store) self.dummy_ver = '2.XX.XX' prv.set_val('version', self.dummy_ver) self.assertEqual(prv.get_val('version'), self.dummy_ver) store.commit() store.close() migration.perform_data_update(self.db_file) store = Store(create_database(GLSettings.db_uri)) notification_l10n = NotificationL10NFactory(store) t2 = notification_l10n.get_val('export_template', 'it') self.assertEqual(t2, t0) store.commit() store.close() shutil.rmtree(GLSettings.db_path)
def postconditions_34(self): store = Store(create_database(GLSettings.db_uri)) notification_l10n = NotificationL10NFactory(store) x = notification_l10n.get_val(u'export_template', u'it') self.assertNotEqual(x, 'unmodifiable') store.commit() store.close()
def preconditions_34(self): store = Store(create_database(self.start_db_uri)) notification_l10n = NotificationL10NFactory(store) notification_l10n.set_val(u'export_template', u'it', 'unmodifiable') x = notification_l10n.get_val(u'export_template', u'it') self.assertTrue(x, 'unmodifiable') store.commit() store.close()
def admin_serialize_notification(store, language): config_dict = NotificationFactory(store).admin_export() conf_l10n_dict = NotificationL10NFactory(store).localized_dict(language) cmd_flags = { 'reset_templates': False, 'exception_email_pgp_key_remove': False, 'smtp_password': '', } return merge_dicts(config_dict, cmd_flags, conf_l10n_dict)
def update_notification(session, tid, request, language): notif = ConfigFactory(session, tid, 'notification') if request['smtp_password'] == '': del request['smtp_password'] notif.update(request) notif_l10n = NotificationL10NFactory(session, tid) notif_l10n.update(request, language) if request.pop('reset_templates'): notif_l10n.reset_templates(load_appdata()) db_refresh_memory_variables(session, [tid]) return admin_serialize_notification(session, tid, language)
def update_notification(store, request, language): notif = NotificationFactory(store) notif.update(request) smtp_pw = request.pop('smtp_password', u'') if smtp_pw != u'': PrivateFactory(store).set_val(u'smtp_password', smtp_pw) notif_l10n = NotificationL10NFactory(store) notif_l10n.update(request, language) if request.pop('reset_templates'): notif_l10n.reset_templates(load_appdata()) # Since the Notification object has been changed refresh the global copy. db_refresh_memory_variables(store) return admin_serialize_notification(store, language)