File tree Expand file tree Collapse file tree 3 files changed +53
-41
lines changed
Expand file tree Collapse file tree 3 files changed +53
-41
lines changed Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+
3+ import pytest
4+
5+
6+ @pytest .fixture
7+ def test_file_path ():
8+ return Path (__file__ ).parent / "files" / "rwservlet.pdf"
9+
Original file line number Diff line number Diff line change 1+ from http import HTTPStatus
2+
3+ from tika import parser
4+
5+
6+ def test_remote_pdf ():
7+ """parse remote PDF"""
8+ assert parser .from_file (
9+ "https://upload.wikimedia.org/wikipedia/commons/4/42/Article_feedback_flow_B_-_Thank_editors.pdf" )
10+
11+
12+ def test_remote_html ():
13+ """parse remote HTML"""
14+ assert parser .from_file ("http://nossl.sh" )
15+
16+
17+ def test_remote_mp3 ():
18+ """parse remote mp3"""
19+ assert parser .from_file (
20+ "https://archive.org/download/Ainst-Spaceshipdemo.mp3/Ainst-Spaceshipdemo.mp3" )
21+
22+
23+ def test_remote_jpg ():
24+ """parse remote jpg"""
25+ assert parser .from_file (
26+ "https://upload.wikimedia.org/wikipedia/commons/b/b7/X_logo.jpg" )
27+
28+
29+ def test_local_binary (test_file_path ):
30+ """parse file binary"""
31+ with open (test_file_path , "rb" ) as file_obj :
32+ assert parser .from_file (file_obj )
33+
34+
35+ def test_local_buffer ():
36+ response = parser .from_buffer ("Good evening, Dave" )
37+ assert response ["status" ] == HTTPStatus .OK
38+
39+
40+ def test_local_path (test_file_path ):
41+ """parse file path"""
42+ assert parser .from_file (str (test_file_path ))
43+
Original file line number Diff line number Diff line change 1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17- from http import HTTPStatus
1817from pathlib import Path
1918
20- import tika .parser
2119import tika .tika
20+ from tika import parser
2221
2322TEST_FILE_PATH = Path (__file__ ).parent / "files" / "rwservlet.pdf"
2423
2524
26- def test_remote_pdf ():
27- """parse remote PDF"""
28- assert tika .parser .from_file (
29- "https://upload.wikimedia.org/wikipedia/commons/4/42/Article_feedback_flow_B_-_Thank_editors.pdf" )
30-
31-
32- def test_remote_html ():
33- """parse remote HTML"""
34- assert tika .parser .from_file ("http://nossl.sh" )
35-
36-
37- def test_remote_mp3 ():
38- """parse remote mp3"""
39- assert tika .parser .from_file (
40- "https://archive.org/download/Ainst-Spaceshipdemo.mp3/Ainst-Spaceshipdemo.mp3" )
41-
42-
43- def test_remote_jpg ():
44- """parse remote jpg"""
45- assert tika .parser .from_file (
46- "https://upload.wikimedia.org/wikipedia/commons/b/b7/X_logo.jpg" )
47-
48-
49- def test_local_binary ():
50- """parse file binary"""
51- with open (TEST_FILE_PATH , "rb" ) as file_obj :
52- assert tika .parser .from_file (file_obj )
53-
54-
55- def test_local_buffer ():
56- response = tika .parser .from_buffer ("Good evening, Dave" )
57- assert response ["status" ] == HTTPStatus .OK
58-
59-
60- def test_local_path ():
61- """parse file path"""
62- assert tika .parser .from_file (str (TEST_FILE_PATH ))
63-
64-
6525def test_kill_server ():
6626 """parse some file then kills server"""
6727 with open (TEST_FILE_PATH , "rb" ) as file_obj :
You can’t perform that action at this time.
0 commit comments