|
14 | 14 | # See the License for the specific language governing permissions and |
15 | 15 | # limitations under the License. |
16 | 16 |
|
17 | | -from http import HTTPStatus |
18 | | -from pathlib import Path |
19 | | - |
20 | | -import tika.parser |
21 | 17 | import tika.tika |
22 | | - |
23 | | -TEST_FILE_PATH = Path(__file__).parent / "files" / "rwservlet.pdf" |
24 | | - |
25 | | - |
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)) |
| 18 | +from tika import parser |
63 | 19 |
|
64 | 20 |
|
65 | | -def test_kill_server(): |
| 21 | +def test_kill_server(test_file_path): |
66 | 22 | """parse some file then kills server""" |
67 | | - with open(TEST_FILE_PATH, "rb") as file_obj: |
| 23 | + with open(test_file_path, "rb") as file_obj: |
68 | 24 | tika.parser.from_file(file_obj) |
69 | 25 | assert tika.tika.killServer() is None |
0 commit comments