def test_conn_slave(self): conn_info = db.ConnectionInfo(self.username, self.password, self.master, self.slaves) self.assertEqual(self.master, conn_info.master_ip) self.assertIn(conn_info.slave_ip, self.slave_ips) self.assertEqual(self.slave_ips, conn_info.slave_ips) self.assertTrue(conn_info.replicating())
def test_conn_master(self): conn_info = db.ConnectionInfo(self.username, self.password, self.master, []) self.assertEqual(self.master, conn_info.master_ip) self.assertEqual(self.master, conn_info.slave_ip) self.assertEqual([self.master], conn_info.slave_ips) self.assertFalse(conn_info.replicating())
def get_db_config(self, _): """ We use this method to let test methods override the DB config in realtime We need to accept a path argument (the app will pass one to us), we ignore it. """ return db.ConnectionInfo(**self.db_config)
def load_config_from_env(): kwargs = {} try: for var, attr in ENV_CONFIG_STRUCTURE: kwargs[attr] = os.environ[var] except KeyError: return None return db.ConnectionInfo(**kwargs)
def parse_config(path): """ Parse config files at `path` with a structure as defined in CONFIG_STRUCTURE """ kwargs = {} for fname, attr in CONFIG_STRUCTURE: try: with open(os.path.join(path, fname)) as cnf_file: kwargs[attr] = cnf_file.read().strip() except IOError: raise exceptions.NoConnectionInfo() return db.ConnectionInfo(**kwargs)
def setUp(self): self.conn_info = db.ConnectionInfo(**TEST_DB_CONFIG)