コード例 #1
0
 def test_gz_reader_non_gz(self):
     """S3Payload - GZ Reader, Non-gzip"""
     record = {'key': 'value'}
     json_line = (json.dumps(record, separators=(',', ':')) + '\n').encode()
     with tempfile.SpooledTemporaryFile(max_size=10 * 1024) as reader:
         reader.writelines([json_line, json_line])
         reader.seek(0)
         non_gz_reader = S3Payload._gz_reader(reader)
         assert_equal(reader == non_gz_reader, True)
コード例 #2
0
 def test_gz_reader(self):
     """S3Payload - GZ Reader"""
     record = {'key': 'value'}
     json_line = (json.dumps(record, separators=(',', ':')) + '\n').encode()
     with tempfile.SpooledTemporaryFile(max_size=10 * 1024) as reader:
         writer = gzip.GzipFile(filename='test', fileobj=reader)
         writer.writelines([json_line, json_line])
         writer.close()
         reader.seek(0)
         gz_reader = S3Payload._gz_reader(reader)
         assert_equal(isinstance(gz_reader, gzip.GzipFile), True)
         assert_equal(gz_reader.read(), json_line + json_line)