def test_reset(self):
     # reset() removes any overrides.
     dbc = DatabaseConfig()
     self.assertEqual('launchpad_main', dbc.dbuser)
     dbc.override(dbuser='******')
     self.assertEqual('not_launchpad', dbc.dbuser)
     dbc.reset()
     self.assertEqual('launchpad_main', dbc.dbuser)
    def test_override(self):
        # dbuser and isolation_level can be overridden at runtime.
        dbc = DatabaseConfig()
        self.assertEqual('launchpad_main', dbc.dbuser)
        self.assertEqual('repeatable_read', dbc.isolation_level)

        # dbuser and isolation_level overrides both work.
        dbc.override(dbuser='******', isolation_level='autocommit')
        self.assertEqual('not_launchpad', dbc.dbuser)
        self.assertEqual('autocommit', dbc.isolation_level)

        # Overriding dbuser again preserves the isolation_level override.
        dbc.override(dbuser='******')
        self.assertEqual('also_not_launchpad', dbc.dbuser)
        self.assertEqual('autocommit', dbc.isolation_level)

        # Overriding with None removes the override.
        dbc.override(dbuser=None, isolation_level=None)
        self.assertEqual('launchpad_main', dbc.dbuser)
        self.assertEqual('repeatable_read', dbc.isolation_level)