def test_retrieve_normal_file_obj(self, tmpdir): """ Test the retrieve_file_obj method with an uncompressed file """ # Setup the WAL file source = tmpdir.join("wal_dir/000000080000ABFF000000C1") source.write("something".encode("utf-8"), ensure=True) # Create a simple CloudWalUploader obj uploader = CloudWalUploader(mock.MagicMock(), "test-server") open_file = uploader.retrieve_file_obj(source.strpath) # Check the file received assert open_file # Check content assert open_file.read() == "something".encode("utf-8")
def test_retrieve_bz2_file_obj(self, tmpdir): """ Test the retrieve_file_obj method with a bz2 file """ # Setup the WAL source = tmpdir.join("wal_dir/000000080000ABFF000000C1") source.write("something".encode("utf-8"), ensure=True) # Create a simple CloudWalUploader obj uploader = CloudWalUploader(mock.MagicMock(), "test-server", compression="bzip2") open_file = uploader.retrieve_file_obj(source.strpath) # Check the in memory file received assert open_file # Decompress on the fly to check content assert bz2.decompress(open_file.read()) == "something".encode("utf-8")