def setup_config(self): self.storage_path = self.tempdir.makedir('repo') self.config_path = self.tempdir.getpath(self.CONFIG_FILE) self.log_file = self.tempdir.getpath('bbpgsql.log') self.config_dict = { 'WAL': { 'driver': 'filesystem', 'path': self.storage_path, }, 'General': { 'pgsql_data_directory': self.tempdir.path, }, 'Logging': { 'logfile': self.log_file, 'level': 'DEBUG', }, } write_config_to_filename(self.config_dict, self.config_path) #print '----' #print open(self.config_path, 'rb').read() #print '----' self.pg_xlog_path = 'pg_xlog' self.tempdir.makedir(self.pg_xlog_path) self.wal_basename = '00001' self.wal_filename = os.path.join(self.pg_xlog_path, self.wal_basename) self.tempdir.write(self.wal_filename, '') print 'TEMPDIR', self.tempdir.listdir(recursive=True)
def setUp(self): self.tempdir = TempDirectory() self.config_dict = { 'General': { 'pgsql_data_directory': self.tempdir.path, }, } self.config_file = os.path.join(self.tempdir.path, 'config_file') write_config_to_filename(self.config_dict, self.config_file)
def test_write_config_to_filename(self): with TempDirectory() as d: config_filename = os.path.join(d.path, 'config.ini') write_config_to_filename(self.test_configuration, config_filename) config = get_config_from_filename_and_set_up_logging( config_filename ) self.assertEqual('Test_value', config.get('Test Section', 'Test_key'))
def test_file_written_with_closed_permissions(self): with TempDirectory() as d: config_filename = os.path.join(d.path, 'config.ini') write_config_to_filename(self.test_configuration, config_filename) file_stats = os.stat(config_filename) self.assertFalse(file_stats.st_mode & stat.S_ISUID) self.assertFalse(file_stats.st_mode & stat.S_ISGID) self.assertFalse(file_stats.st_mode & stat.S_ISVTX) self.assertFalse(file_stats.st_mode & stat.S_IRWXG) self.assertFalse(file_stats.st_mode & stat.S_IRWXO)
def setUp(self): self.tempdir = TempDirectory() self.config_dict = { 'General': { 'pgsql_data_directory': self.tempdir.path, }, } self.config_file = os.path.join(self.tempdir.path, 'config_file') write_config_to_filename(self.config_dict, self.config_file) parser, self.options, self.args = archivewal_parse_args(['-c', self.config_file])
def setup_config(self): self.config_path = os.path.join(self.tempdir.path, self.CONFIG_FILE) self.config_dict = { 'General': { 'pgsql_data_directory': self.data_dir, }, 'Snapshot': { 'driver': 'memory', }, } write_config_to_filename(self.config_dict, self.config_path) self.config = get_config_from_filename_and_set_up_logging( self.config_path )
def write_config_to_disk(self): self.config_path = os.path.join(self.tempdir.path, self.CONFIG_FILE) write_config_to_filename(self.setup_config(), self.config_path) self.config = get_config_from_filename_and_set_up_logging( self.config_path )
def setUp(self): self.tempdir = TempDirectory() self.config_dict = { } self.config_path = os.path.join(self.tempdir.path, 'config.ini') write_config_to_filename(self.config_dict, self.config_path)