File tree Expand file tree Collapse file tree
docs/source/_static/test-files Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ <!doctype html>
2+ < html lang ="en ">
3+ < head > < meta charset ="utf-8 "> < title > Tika Python Remote HTML Fixture</ title > </ head >
4+ < body > < main > < h1 > Tika Python Remote HTML Fixture</ h1 > < p > This deterministic file is hosted by the tika-python documentation site for parser remote URL tests.</ p > </ main > </ body >
5+ </ html >
Original file line number Diff line number Diff line change 11# SPDX-License-Identifier: Apache-2.0
22
3+ from functools import partial
4+ from http .server import SimpleHTTPRequestHandler , ThreadingHTTPServer
5+ import os
36from pathlib import Path
7+ import threading
48
59import pytest
610
11+ GITHUB_PAGES_REMOTE_FIXTURE_BASE_URL = (
12+ "https://chrismattmann.github.io/tika-python/_static/test-files"
13+ )
14+
715
816@pytest .fixture
917def test_file_path ():
1018 return Path (__file__ ).parent / "files" / "rwservlet.pdf"
19+
20+
21+ @pytest .fixture (scope = "session" )
22+ def remote_fixture_base_url ():
23+ configured_url = os .getenv ("TIKA_REMOTE_TEST_BASE_URL" )
24+ if configured_url :
25+ yield configured_url .rstrip ("/" )
26+ return
27+
28+ if not os .getenv ("CI" ):
29+ yield GITHUB_PAGES_REMOTE_FIXTURE_BASE_URL
30+ return
31+
32+ static_dir = Path (__file__ ).parents [1 ] / "docs" / "source" / "_static" / "test-files"
33+ handler = partial (SimpleHTTPRequestHandler , directory = static_dir )
34+
35+ with ThreadingHTTPServer (("127.0.0.1" , 0 ), handler ) as httpd :
36+ thread = threading .Thread (target = httpd .serve_forever , daemon = True )
37+ thread .start ()
38+ yield f"http://127.0.0.1:{ httpd .server_port } "
39+ httpd .shutdown ()
Original file line number Diff line number Diff line change 55from tika import parser
66
77
8- def test_remote_pdf ():
8+ def test_remote_pdf (remote_fixture_base_url ):
99 """parse remote PDF"""
10- assert parser .from_file (
11- "https://upload.wikimedia.org/wikipedia/commons/4/42/Article_feedback_flow_B_-_Thank_editors.pdf" )
10+ assert parser .from_file (f"{ remote_fixture_base_url } /remote.pdf" )
1211
1312
14- def test_remote_html ():
13+ def test_remote_html (remote_fixture_base_url ):
1514 """parse remote HTML"""
16- assert parser .from_file ("http://nossl.sh " )
15+ assert parser .from_file (f" { remote_fixture_base_url } /remote.html " )
1716
1817
19- def test_remote_mp3 ():
18+ def test_remote_mp3 (remote_fixture_base_url ):
2019 """parse remote mp3"""
21- assert parser .from_file (
22- "https://archive.org/download/Ainst-Spaceshipdemo.mp3/Ainst-Spaceshipdemo.mp3" )
20+ assert parser .from_file (f"{ remote_fixture_base_url } /remote.mp3" )
2321
2422
25- def test_remote_jpg ():
23+ def test_remote_jpg (remote_fixture_base_url ):
2624 """parse remote jpg"""
27- assert parser .from_file (
28- "https://upload.wikimedia.org/wikipedia/commons/b/b7/X_logo.jpg" )
25+ assert parser .from_file (f"{ remote_fixture_base_url } /remote.jpg" )
2926
3027
3128def test_local_binary (test_file_path ):
Original file line number Diff line number Diff line change 1313# See the License for the specific language governing permissions and
1414# limitations under the License.
1515
16- __version__ = "3.1.0 "
16+ __version__ = "3.3.2 "
1717
1818from pkgutil import extend_path
1919
Original file line number Diff line number Diff line change @@ -152,7 +152,7 @@ def make_content_disposition_header(fn):
152152log .setLevel (logging .INFO )
153153
154154Windows = True if platform .system () == "Windows" else False
155- TikaVersion = os .getenv ('TIKA_VERSION' , '3.1.0 ' )
155+ TikaVersion = os .getenv ('TIKA_VERSION' , '3.3.2 ' )
156156TikaJarPath = os .getenv ('TIKA_PATH' , tempfile .gettempdir ())
157157TikaFilesPath = tempfile .gettempdir ()
158158TikaServerLogFilePath = log_path
You can’t perform that action at this time.
0 commit comments