Esempio n. 1
0
    def _test_missing_config(self, store):
        self.assertEqual(True, config.is_cfg_valid(store))

        p = config.Config('private', 'smtp_password', 'XXXX')
        p.var_group = u'outside'
        store.add(p)

        self.assertEqual(False, config.is_cfg_valid(store))

        node = config.NodeFactory(store)
        c = node.get_cfg('public_site')
        store.remove(c)
        store.commit()

        self.assertEqual(False, node.db_corresponds())

        # Delete all of the vars in Private Factory
        prv = config.PrivateFactory(store)

        store.execute('DELETE FROM config WHERE var_group = "private"')

        self.assertEqual(False, prv.db_corresponds())

        ntfn = config.NotificationFactory(store)

        c = config.Config('notification', 'server', 'guarda.giochi.con.occhi')
        c.var_name = u'anextravar'
        store.add(c)

        self.assertEqual(False, ntfn.db_corresponds())

        config.update_defaults(store)

        self.assertEqual(True, config.is_cfg_valid(store))
Esempio n. 2
0
    def _test_missing_config(self, store):
        self.assertEqual(True, config.is_cfg_valid(store))

        p = config.Config('private', 'smtp_password', 'XXXX')
        p.var_group = u'outside'
        store.add(p)

        self.assertEqual(False, config.is_cfg_valid(store))

        node = config.NodeFactory(store)
        c = node.get_cfg(u'hostname')
        store.remove(c)
        store.commit()

        self.assertEqual(False, node.db_corresponds())

        # Delete all of the vars in Private Factory
        prv = config.PrivateFactory(store)

        store.execute('DELETE FROM config WHERE var_group = "private"')

        self.assertEqual(False, prv.db_corresponds())

        ntfn = config.NotificationFactory(store)

        c = config.Config('notification', 'server', 'guarda.giochi.con.occhi')
        c.var_name = u'anextravar'
        store.add(c)

        self.assertEqual(False, ntfn.db_corresponds())

        config.update_defaults(store)

        self.assertEqual(True, config.is_cfg_valid(store))
Esempio n. 3
0
    def test_detect_and_fix_cfg_change(self):
        store = Store(create_database(GLSettings.db_uri))
        ret = config.is_cfg_valid(store)
        self.assertFalse(ret)
        store.close()

        migration.perform_data_update(self.db_file)

        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.assertEqual(prv.get_val('version'), __version__)
        self.assertEqual(prv.get_val('xx_smtp_password'), self.dp)
        ret = config.is_cfg_valid(store)
        self.assertTrue(ret)
        store.close()
Esempio n. 4
0
    def test_detect_and_fix_cfg_change(self):
        store = Store(create_database(GLSettings.db_uri))
        ret = config.is_cfg_valid(store)
        self.assertFalse(ret)
        store.close()

        migration.perform_data_update(self.db_file)

        store = Store(create_database(GLSettings.db_uri))
        prv = config.PrivateFactory(store)
        self.assertEqual(prv.get_val(u'version'), __version__)
        self.assertEqual(prv.get_val(u'xx_smtp_password'), self.dp)
        ret = config.is_cfg_valid(store)
        self.assertTrue(ret)
        store.close()
Esempio n. 5
0
def db_perform_data_update(store):
    prv = PrivateFactory(store)

    stored_ver = prv.get_val('version')
    t = (stored_ver, __version__)

    # Catch all failures
    if stored_ver != __version__:
        prv.set_val('version', __version__)

        appdata = db_update_appdata(store)
        config.update_defaults(store)
        l10n.update_defaults(store, appdata)
        db_fix_fields_attrs(store)

    ok = config.is_cfg_valid(store)
    if not ok:
        m = 'Error: the system is not stable, update failed from %s to %s' % t
        raise DatabaseIntegrityError(m)
Esempio n. 6
0
def db_perform_data_update(store):
    prv = PrivateFactory(store)

    stored_ver = prv.get_val('version')
    t = (stored_ver, __version__)

    if stored_ver != __version__:
        prv.set_val('version', __version__)

        # The below commands can change the current store based on the what is
        # currently stored in the DB.
        appdata = db_update_appdata(store)
        l10n.update_defaults(store, appdata)
        config.update_defaults(store)
        db_fix_fields_attrs(store)

    ok = config.is_cfg_valid(store)
    if not ok:
        m = 'Error: the system is not stable, update failed from %s to %s' % t
        raise Exception(m)
Esempio n. 7
0
def db_perform_data_update(store):
    prv = PrivateFactory(store)

    stored_ver = prv.get_val('version')
    t = (stored_ver, __version__)

    if stored_ver != __version__:
        prv.set_val('version', __version__)

        # The below commands can change the current store based on the what is
        # currently stored in the DB.
        appdata = db_update_appdata(store)
        l10n.update_defaults(store, appdata)
        config.update_defaults(store)
        db_fix_fields_attrs(store)

    ok = config.is_cfg_valid(store)
    if not ok:
        m = 'Error: the system is not stable, update failed from %s to %s' % t
        raise Exception(m)
Esempio n. 8
0
 def _test_valid_cfg(self, store):
     self.assertEqual(True, config.is_cfg_valid(store))
Esempio n. 9
0
 def _test_valid_cfg(self, store):
     self.assertEqual(True, config.is_cfg_valid(store))