2020import os
2121import unittest
2222import zlib
23+ import gzip
24+ from http import HTTPStatus
2325
2426import tika .parser
25- import tika .tika
26- from tika .tests .utils import HTTPStatusOk , gzip_compress
2727
2828
2929def test_local_binary (benchmark ):
3030 """parse file binary"""
3131 file = os .path .join (os .path .dirname (__file__ ), 'files' , 'rwservlet.pdf' )
3232 response = benchmark (tika_from_binary , file )
3333
34- assert response ['status' ] == HTTPStatusOk
34+ assert response ['status' ] == HTTPStatus . OK
3535
3636
3737def test_parser_buffer (benchmark ):
3838 """example how to send gzip file"""
3939 file = os .path .join (os .path .dirname (__file__ ), 'files' , 'rwservlet.pdf' )
4040 response = benchmark (tika_from_buffer , file )
4141
42- assert response ['status' ] == HTTPStatusOk
42+ assert response ['status' ] == HTTPStatus . OK
4343
4444
4545def test_parser_buffer_zlib_input (benchmark ):
@@ -48,31 +48,31 @@ def test_parser_buffer_zlib_input(benchmark):
4848
4949 response = benchmark (tika_from_buffer_zlib , file )
5050
51- assert response ['status' ] == HTTPStatusOk
51+ assert response ['status' ] == HTTPStatus . OK
5252
5353
5454def test_parser_buffer_gzip_input (benchmark ):
5555 """parse file binary"""
5656 file = os .path .join (os .path .dirname (__file__ ), 'files' , 'rwservlet.pdf' )
5757 response = benchmark (tika_from_buffer_gzip , file )
5858
59- assert response ['status' ] == HTTPStatusOk
59+ assert response ['status' ] == HTTPStatus . OK
6060
6161
6262def test_local_binary_with_gzip_output (benchmark ):
6363 """parse file binary"""
6464 file = os .path .join (os .path .dirname (__file__ ), 'files' , 'rwservlet.pdf' )
6565 response = benchmark (tika_from_binary , file , headers = {'Accept-Encoding' : 'gzip, deflate' })
6666
67- assert response ['status' ] == HTTPStatusOk
67+ assert response ['status' ] == HTTPStatus . OK
6868
6969
7070def test_parser_buffer_with_gzip_output (benchmark ):
7171 """example how to send gzip file"""
7272 file = os .path .join (os .path .dirname (__file__ ), 'files' , 'rwservlet.pdf' )
7373 response = benchmark (tika_from_buffer , file , headers = {'Accept-Encoding' : 'gzip, deflate' })
7474
75- assert response ['status' ] == HTTPStatusOk
75+ assert response ['status' ] == HTTPStatus . OK
7676
7777
7878def test_parser_buffer_zlib_input_and_gzip_output (benchmark ):
@@ -81,15 +81,15 @@ def test_parser_buffer_zlib_input_and_gzip_output(benchmark):
8181
8282 response = benchmark (tika_from_buffer_zlib , file , headers = {'Accept-Encoding' : 'gzip, deflate' })
8383
84- assert response ['status' ] == HTTPStatusOk
84+ assert response ['status' ] == HTTPStatus . OK
8585
8686
8787def test_parser_buffer_gzip_input_and_gzip_output (benchmark ):
8888 """parse file binary"""
8989 file = os .path .join (os .path .dirname (__file__ ), 'files' , 'rwservlet.pdf' )
9090 response = benchmark (tika_from_buffer_gzip , file , headers = {'Accept-Encoding' : 'gzip, deflate' })
9191
92- assert response ['status' ] == HTTPStatusOk
92+ assert response ['status' ] == HTTPStatus . OK
9393
9494
9595def tika_from_buffer_zlib (file , headers = None ):
@@ -99,7 +99,7 @@ def tika_from_buffer_zlib(file, headers=None):
9999
100100def tika_from_buffer_gzip (file , headers = None ):
101101 with open (file , 'rb' ) as file_obj :
102- return tika .parser .from_buffer (gzip_compress (file_obj .read ()), headers = headers )
102+ return tika .parser .from_buffer (gzip . compress (file_obj .read ()), headers = headers )
103103
104104
105105def tika_from_buffer (file , headers = None ):
0 commit comments