Page MenuHomeSoftware Heritage

D5178.id18514.diff
No OneTemporary

D5178.id18514.diff

diff --git a/swh/scanner/scanner.py b/swh/scanner/scanner.py
--- a/swh/scanner/scanner.py
+++ b/swh/scanner/scanner.py
@@ -100,24 +100,26 @@
"""
- def swhid_of(path):
+ def swhid_of(path: Path) -> str:
if path.is_dir():
if exclude_patterns:
- def dir_filter(dirpath, *args):
+ def dir_filter(dirpath: str, *args) -> bool:
return directory_filter(dirpath, exclude_patterns)
else:
- dir_filter = accept_all_directories
+ dir_filter = accept_all_directories # type: ignore
obj = Directory.from_disk(
path=bytes(path), dir_filter=dir_filter
).get_data()
- return CoreSWHID(object_type=ObjectType.DIRECTORY, object_id=obj["id"])
+ return str(CoreSWHID(object_type=ObjectType.DIRECTORY, object_id=obj["id"]))
else:
obj = Content.from_file(path=bytes(path)).get_data()
- return Content(object_type=ObjectType.CONTENT, object_id=obj["sha1_git"])
+ return str(
+ CoreSWHID(object_type=ObjectType.CONTENT, object_id=obj["sha1_git"])
+ )
dirpath, dnames, fnames = next(os.walk(path))
for node in itertools.chain(dnames, fnames):
diff --git a/swh/scanner/tests/flask_api.py b/swh/scanner/tests/flask_api.py
--- a/swh/scanner/tests/flask_api.py
+++ b/swh/scanner/tests/flask_api.py
@@ -13,6 +13,10 @@
def create_app():
app = Flask(__name__)
+ @app.route("/")
+ def index():
+ return "SWH scanner API"
+
@app.route("/known/", methods=["POST"])
def known():
swhids = request.get_json()
diff --git a/swh/scanner/tests/test_scanner.py b/swh/scanner/tests/test_scanner.py
--- a/swh/scanner/tests/test_scanner.py
+++ b/swh/scanner/tests/test_scanner.py
@@ -5,6 +5,7 @@
import json
+from flask import url_for
import pytest
from swh.scanner.exceptions import APIError, InvalidDirectoryPath
@@ -54,7 +55,7 @@
def test_scanner_raise_apierror_input_size_limit(event_loop, aiosession, live_server):
- api_url = live_server.url() + "/"
+ api_url = url_for("index", _external=True)
request = [
"swh:1:cnt:7c4c57ba9ff496ad179b8f65b1d286edbda34c9a" for i in range(901)
] # /known/ is limited at 900
@@ -82,7 +83,7 @@
def test_scanner_result(live_server, event_loop, test_sample_folder):
- api_url = live_server.url() + "/"
+ api_url = url_for("index", _external=True)
config = {"web-api": {"url": api_url, "auth-token": None}}
source_tree = Tree(test_sample_folder)
@@ -99,7 +100,7 @@
def test_scanner_result_with_exclude_patterns(
live_server, event_loop, test_sample_folder
):
- api_url = live_server.url() + "/"
+ api_url = url_for("index", _external=True)
config = {"web-api": {"url": api_url, "auth-token": None}}
patterns = (str(test_sample_folder) + "/toexclude",)

File Metadata

Mime Type
text/plain
Expires
Wed, Dec 18, 10:51 AM (1 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3232618

Event Timeline