diff --git a/swh/loader/package/pubdev/loader.py b/swh/loader/package/pubdev/loader.py --- a/swh/loader/package/pubdev/loader.py +++ b/swh/loader/package/pubdev/loader.py @@ -61,6 +61,8 @@ class PubDevLoader(PackageLoader[PubDevPackageInfo]): visit_type = "pubdev" + PUBDEV_BASE_URL = "https://pub.dev/" + def __init__( self, storage: StorageInterface, @@ -70,9 +72,13 @@ super().__init__(storage=storage, url=url, **kwargs) self.url = url + assert url.startswith(self.PUBDEV_BASE_URL) + self.package_info_url = url.replace( + self.PUBDEV_BASE_URL, f"{self.PUBDEV_BASE_URL}api/" + ) def _raw_info(self) -> bytes: - return api_info(self.url) + return api_info(self.package_info_url) @cached_method def info(self) -> Dict: diff --git a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_Autolinker b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_Autolinker --- a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_Autolinker +++ b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_Autolinker @@ -1,2 +1,29 @@ -{"name":"Autolinker","latest":{"version":"0.1.1","pubspec":{"version":"0.1.1","homepage":"https://github.com/hackcave","description":"Port of Autolinker.js to dart","name":"Autolinker","author":"hackcave "},"archive_url":"https://pub.dartlang.org/packages/Autolinker/versions/0.1.1.tar.gz","published":"2014-12-24T22:34:02.534090Z"},"versions":[{"version":"0.1.1","pubspec":{"version":"0.1.1","homepage":"https://github.com/hackcave","description":"Port of Autolinker.js to dart","name":"Autolinker","author":"hackcave "},"archive_url":"https://pub.dartlang.org/packages/Autolinker/versions/0.1.1.tar.gz","published":"2014-12-24T22:34:02.534090Z"}]} - +{ + "name": "Autolinker", + "latest": { + "version": "0.1.1", + "pubspec": { + "version": "0.1.1", + "homepage": "https://github.com/hackcave", + "description": "Port of Autolinker.js to dart", + "name": "Autolinker", + "author": "hackcave " + }, + "archive_url": "https://pub.dartlang.org/packages/Autolinker/versions/0.1.1.tar.gz", + "published": "2014-12-24T22:34:02.534090Z" + }, + "versions": [ + { + "version": "0.1.1", + "pubspec": { + "version": "0.1.1", + "homepage": "https://github.com/hackcave", + "description": "Port of Autolinker.js to dart", + "name": "Autolinker", + "author": "hackcave " + }, + "archive_url": "https://pub.dartlang.org/packages/Autolinker/versions/0.1.1.tar.gz", + "published": "2014-12-24T22:34:02.534090Z" + } + ] +} \ No newline at end of file diff --git a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_abstract_io b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_abstract_io --- a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_abstract_io +++ b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_abstract_io @@ -1,2 +1,93 @@ -{"name":"abstract_io","latest":{"version":"0.1.2+6","pubspec":{"name":"abstract_io","description":"Abstract IO is designed to simplify and generalize saving data both localy and externaly","version":"0.1.2+6","author":"Anders Groeschel","repository":"https://github.com/AndersGroeschel/abstract_io","homepage":"https://github.com/AndersGroeschel/abstract_io","environment":{"sdk":">=2.7.0 <3.0.0"},"dependencies":{"flutter":{"sdk":"flutter"}}},"archive_url":"https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B6.tar.gz","archive_sha256":"9557fd384730d92a046cfccdff9625f2d646657219d5a0e447cb7eb0fdf90f18","published":"2020-08-03T21:31:05.764846Z"},"versions":[{"version":"0.1.2+4","pubspec":{"name":"abstract_io","description":"Abstract IO is designed to simplify and generalize saving data both localy and externaly","version":"0.1.2+4","author":"Anders Groeschel","repository":"https://github.com/AndersGroeschel/abstract_io","homepage":"https://github.com/AndersGroeschel/abstract_io","environment":{"sdk":">=2.7.0 <3.0.0"},"dependencies":{"flutter":{"sdk":"flutter"}}},"archive_url":"https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B4.tar.gz","archive_sha256":"df687ff2a92774db04a28167ccddbfe9c2fc1ea63c6ae05c3236552fe350bb68","published":"2020-08-03T20:14:38.116237Z"},{"version":"0.1.2+5","pubspec":{"name":"abstract_io","description":"Abstract IO is designed to simplify and generalize saving data both localy and externaly","version":"0.1.2+5","author":"Anders Groeschel","repository":"https://github.com/AndersGroeschel/abstract_io","homepage":"https://github.com/AndersGroeschel/abstract_io","environment":{"sdk":">=2.7.0 <3.0.0"},"dependencies":{"flutter":{"sdk":"flutter"}}},"archive_url":"https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B5.tar.gz","archive_sha256":"fc9199c2f9879d3c0d140c05a2f8c537561af256d98d209b4ee102e8107ec2b9","published":"2020-08-03T21:09:20.329418Z"},{"version":"0.1.2+6","pubspec":{"name":"abstract_io","description":"Abstract IO is designed to simplify and generalize saving data both localy and externaly","version":"0.1.2+6","author":"Anders Groeschel","repository":"https://github.com/AndersGroeschel/abstract_io","homepage":"https://github.com/AndersGroeschel/abstract_io","environment":{"sdk":">=2.7.0 <3.0.0"},"dependencies":{"flutter":{"sdk":"flutter"}}},"archive_url":"https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B6.tar.gz","archive_sha256":"9557fd384730d92a046cfccdff9625f2d646657219d5a0e447cb7eb0fdf90f18","published":"2020-08-03T21:31:05.764846Z"}]} - +{ + "name": "abstract_io", + "latest": { + "version": "0.1.2+6", + "pubspec": { + "name": "abstract_io", + "description": "Abstract IO is designed to simplify and generalize saving data both localy and externaly", + "version": "0.1.2+6", + "author": "Anders Groeschel", + "repository": "https://github.com/AndersGroeschel/abstract_io", + "homepage": "https://github.com/AndersGroeschel/abstract_io", + "environment": { + "sdk": ">=2.7.0 <3.0.0" + }, + "dependencies": { + "flutter": { + "sdk": "flutter" + } + } + }, + "archive_url": "https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B6.tar.gz", + "archive_sha256": "9557fd384730d92a046cfccdff9625f2d646657219d5a0e447cb7eb0fdf90f18", + "published": "2020-08-03T21:31:05.764846Z" + }, + "versions": [ + { + "version": "0.1.2+4", + "pubspec": { + "name": "abstract_io", + "description": "Abstract IO is designed to simplify and generalize saving data both localy and externaly", + "version": "0.1.2+4", + "author": "Anders Groeschel", + "repository": "https://github.com/AndersGroeschel/abstract_io", + "homepage": "https://github.com/AndersGroeschel/abstract_io", + "environment": { + "sdk": ">=2.7.0 <3.0.0" + }, + "dependencies": { + "flutter": { + "sdk": "flutter" + } + } + }, + "archive_url": "https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B4.tar.gz", + "archive_sha256": "df687ff2a92774db04a28167ccddbfe9c2fc1ea63c6ae05c3236552fe350bb68", + "published": "2020-08-03T20:14:38.116237Z" + }, + { + "version": "0.1.2+5", + "pubspec": { + "name": "abstract_io", + "description": "Abstract IO is designed to simplify and generalize saving data both localy and externaly", + "version": "0.1.2+5", + "author": "Anders Groeschel", + "repository": "https://github.com/AndersGroeschel/abstract_io", + "homepage": "https://github.com/AndersGroeschel/abstract_io", + "environment": { + "sdk": ">=2.7.0 <3.0.0" + }, + "dependencies": { + "flutter": { + "sdk": "flutter" + } + } + }, + "archive_url": "https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B5.tar.gz", + "archive_sha256": "fc9199c2f9879d3c0d140c05a2f8c537561af256d98d209b4ee102e8107ec2b9", + "published": "2020-08-03T21:09:20.329418Z" + }, + { + "version": "0.1.2+6", + "pubspec": { + "name": "abstract_io", + "description": "Abstract IO is designed to simplify and generalize saving data both localy and externaly", + "version": "0.1.2+6", + "author": "Anders Groeschel", + "repository": "https://github.com/AndersGroeschel/abstract_io", + "homepage": "https://github.com/AndersGroeschel/abstract_io", + "environment": { + "sdk": ">=2.7.0 <3.0.0" + }, + "dependencies": { + "flutter": { + "sdk": "flutter" + } + } + }, + "archive_url": "https://pub.dartlang.org/packages/abstract_io/versions/0.1.2%2B6.tar.gz", + "archive_sha256": "9557fd384730d92a046cfccdff9625f2d646657219d5a0e447cb7eb0fdf90f18", + "published": "2020-08-03T21:31:05.764846Z" + } + ] +} \ No newline at end of file diff --git a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_authentication b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_authentication --- a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_authentication +++ b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_authentication @@ -1,2 +1,77 @@ -{"name":"authentication","latest":{"version":"0.0.1","pubspec":{"name":"authentication","description":"Persistent user authentication for Flutter with optional backend API integration.","version":"0.0.1","author":null,"homepage":null,"environment":{"sdk":">=2.7.0 <3.0.0","flutter":">=1.17.0 <2.0.0"},"dependencies":{"flutter":{"sdk":"flutter"}},"dev_dependencies":{"flutter_test":{"sdk":"flutter"}},"flutter":{"plugin":{"platforms":{"some_platform":{"pluginClass":"somePluginClass"}}}}},"archive_url":"https://pub.dartlang.org/packages/authentication/versions/0.0.1.tar.gz","archive_sha256":"0179334b346cb67e4e6e3c905e5cc5c8e488a45ebd99fd2be3a7e0476d620d99","published":"2020-08-13T04:53:34.134687Z"},"versions":[{"version":"0.0.1","pubspec":{"name":"authentication","description":"Persistent user authentication for Flutter with optional backend API integration.","version":"0.0.1","author":null,"homepage":null,"environment":{"sdk":">=2.7.0 <3.0.0","flutter":">=1.17.0 <2.0.0"},"dependencies":{"flutter":{"sdk":"flutter"}},"dev_dependencies":{"flutter_test":{"sdk":"flutter"}},"flutter":{"plugin":{"platforms":{"some_platform":{"pluginClass":"somePluginClass"}}}}},"archive_url":"https://pub.dartlang.org/packages/authentication/versions/0.0.1.tar.gz","archive_sha256":"0179334b346cb67e4e6e3c905e5cc5c8e488a45ebd99fd2be3a7e0476d620d99","published":"2020-08-13T04:53:34.134687Z"}]} - +{ + "name": "authentication", + "latest": { + "version": "0.0.1", + "pubspec": { + "name": "authentication", + "description": "Persistent user authentication for Flutter with optional backend API integration.", + "version": "0.0.1", + "author": null, + "homepage": null, + "environment": { + "sdk": ">=2.7.0 <3.0.0", + "flutter": ">=1.17.0 <2.0.0" + }, + "dependencies": { + "flutter": { + "sdk": "flutter" + } + }, + "dev_dependencies": { + "flutter_test": { + "sdk": "flutter" + } + }, + "flutter": { + "plugin": { + "platforms": { + "some_platform": { + "pluginClass": "somePluginClass" + } + } + } + } + }, + "archive_url": "https://pub.dartlang.org/packages/authentication/versions/0.0.1.tar.gz", + "archive_sha256": "0179334b346cb67e4e6e3c905e5cc5c8e488a45ebd99fd2be3a7e0476d620d99", + "published": "2020-08-13T04:53:34.134687Z" + }, + "versions": [ + { + "version": "0.0.1", + "pubspec": { + "name": "authentication", + "description": "Persistent user authentication for Flutter with optional backend API integration.", + "version": "0.0.1", + "author": null, + "homepage": null, + "environment": { + "sdk": ">=2.7.0 <3.0.0", + "flutter": ">=1.17.0 <2.0.0" + }, + "dependencies": { + "flutter": { + "sdk": "flutter" + } + }, + "dev_dependencies": { + "flutter_test": { + "sdk": "flutter" + } + }, + "flutter": { + "plugin": { + "platforms": { + "some_platform": { + "pluginClass": "somePluginClass" + } + } + } + } + }, + "archive_url": "https://pub.dartlang.org/packages/authentication/versions/0.0.1.tar.gz", + "archive_sha256": "0179334b346cb67e4e6e3c905e5cc5c8e488a45ebd99fd2be3a7e0476d620d99", + "published": "2020-08-13T04:53:34.134687Z" + } + ] +} \ No newline at end of file diff --git a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_bezier b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_bezier --- a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_bezier +++ b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_bezier @@ -1,4 +1,55 @@ -{"name":"bezier","latest":{"version":"1.1.5","pubspec":{"name":"bezier","version":"1.1.5","authors":["Aaron Barrett ","Isaac Barrett "],"description":"A 2D Bézier curve math library. Based heavily on the work of @TheRealPomax . -Live examples can be found at .","homepage":"https://github.com/aab29/bezier.dart","environment":{"sdk":">=2.0.0 <3.0.0"},"dependencies":{"vector_math":"^2.0.0"},"dev_dependencies":{"test":"^1.0.0"}},"archive_url":"https://pub.dartlang.org/packages/bezier/versions/1.1.5.tar.gz","archive_sha256":"cc5da2fa927b5d347550f78d456cd984b7df78a7f0405119cdab12111e2f9ee8","published":"2019-12-22T03:17:30.805225Z"},"versions":[{"version":"1.1.5","pubspec":{"name":"bezier","version":"1.1.5","authors":["Aaron Barrett ","Isaac Barrett "],"description":"A 2D Bézier curve math library. Based heavily on the work of @TheRealPomax . -Live examples can be found at .","homepage":"https://github.com/aab29/bezier.dart","environment":{"sdk":">=2.0.0 <3.0.0"},"dependencies":{"vector_math":"^2.0.0"},"dev_dependencies":{"test":"^1.0.0"}},"archive_url":"https://pub.dartlang.org/packages/bezier/versions/1.1.5.tar.gz","archive_sha256":"cc5da2fa927b5d347550f78d456cd984b7df78a7f0405119cdab12111e2f9ee8","published":"2019-12-22T03:17:30.805225Z"}]} - +{ + "name": "bezier", + "latest": { + "version": "1.1.5", + "pubspec": { + "name": "bezier", + "version": "1.1.5", + "authors": [ + "Aaron Barrett ", + "Isaac Barrett " + ], + "description": "A 2D Bézier curve math library. Based heavily on the work of @TheRealPomax .\nLive examples can be found at .", + "homepage": "https://github.com/aab29/bezier.dart", + "environment": { + "sdk": ">=2.0.0 <3.0.0" + }, + "dependencies": { + "vector_math": "^2.0.0" + }, + "dev_dependencies": { + "test": "^1.0.0" + } + }, + "archive_url": "https://pub.dartlang.org/packages/bezier/versions/1.1.5.tar.gz", + "archive_sha256": "cc5da2fa927b5d347550f78d456cd984b7df78a7f0405119cdab12111e2f9ee8", + "published": "2019-12-22T03:17:30.805225Z" + }, + "versions": [ + { + "version": "1.1.5", + "pubspec": { + "name": "bezier", + "version": "1.1.5", + "authors": [ + "Aaron Barrett ", + "Isaac Barrett " + ], + "description": "A 2D Bézier curve math library. Based heavily on the work of @TheRealPomax .\nLive examples can be found at .", + "homepage": "https://github.com/aab29/bezier.dart", + "environment": { + "sdk": ">=2.0.0 <3.0.0" + }, + "dependencies": { + "vector_math": "^2.0.0" + }, + "dev_dependencies": { + "test": "^1.0.0" + } + }, + "archive_url": "https://pub.dartlang.org/packages/bezier/versions/1.1.5.tar.gz", + "archive_sha256": "cc5da2fa927b5d347550f78d456cd984b7df78a7f0405119cdab12111e2f9ee8", + "published": "2019-12-22T03:17:30.805225Z" + } + ] +} \ No newline at end of file diff --git a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_pdf b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_pdf --- a/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_pdf +++ b/swh/loader/package/pubdev/tests/data/https_pub.dev/api_packages_pdf @@ -1,2 +1,88 @@ -{"name":"pdf","latest":{"version":"3.8.2","pubspec":{"name":"pdf","description":"A pdf producer for Dart. It can create pdf files for both web or flutter.","homepage":"https://github.com/DavBfr/dart_pdf/tree/master/pdf","repository":"https://github.com/DavBfr/dart_pdf","issue_tracker":"https://github.com/DavBfr/dart_pdf/issues","version":"3.8.2","environment":{"sdk":">=2.12.0 <3.0.0"},"dependencies":{"archive":"^3.1.0","barcode":">=2.2.0 <3.0.0","crypto":"^3.0.0","image":">=3.0.1 <4.0.0","meta":">=1.3.0 <2.0.0","path_parsing":">=0.2.0 <2.0.0","vector_math":"^2.1.0","xml":">=5.1.0 <7.0.0"},"dev_dependencies":{"flutter_lints":"^1.0.4","test":">=1.16.0 <2.0.0"}},"archive_url":"https://pub.dartlang.org/packages/pdf/versions/3.8.2.tar.gz","published":"2022-07-25T11:38:25.983876Z"},"versions":[{"version":"1.0.0","pubspec":{"version":"1.0.0","name":"pdf","dependencies":{"ttf_parser":"^1.0.0","vector_math":"^2.0.7","meta":"^1.1.5"},"author":"David PHAM-VAN ","description":"A pdf producer for Dart","homepage":"https://github.com/davbfr/dart_pdf","environment":{"sdk":">=1.8.0 <2.0.0"},"dev_dependencies":{"test":"any"}},"archive_url":"https://pub.dartlang.org/packages/pdf/versions/1.0.0.tar.gz","published":"2018-07-16T21:12:28.894137Z"},{"version":"3.8.2","pubspec":{"name":"pdf","description":"A pdf producer for Dart. It can create pdf files for both web or flutter.","homepage":"https://github.com/DavBfr/dart_pdf/tree/master/pdf","repository":"https://github.com/DavBfr/dart_pdf","issue_tracker":"https://github.com/DavBfr/dart_pdf/issues","version":"3.8.2","environment":{"sdk":">=2.12.0 <3.0.0"},"dependencies":{"archive":"^3.1.0","barcode":">=2.2.0 <3.0.0","crypto":"^3.0.0","image":">=3.0.1 <4.0.0","meta":">=1.3.0 <2.0.0","path_parsing":">=0.2.0 <2.0.0","vector_math":"^2.1.0","xml":">=5.1.0 <7.0.0"},"dev_dependencies":{"flutter_lints":"^1.0.4","test":">=1.16.0 <2.0.0"}},"archive_url":"https://pub.dartlang.org/packages/pdf/versions/3.8.2.tar.gz","published":"2022-07-25T11:38:25.983876Z"}]} - +{ + "name": "pdf", + "latest": { + "version": "3.8.2", + "pubspec": { + "name": "pdf", + "description": "A pdf producer for Dart. It can create pdf files for both web or flutter.", + "homepage": "https://github.com/DavBfr/dart_pdf/tree/master/pdf", + "repository": "https://github.com/DavBfr/dart_pdf", + "issue_tracker": "https://github.com/DavBfr/dart_pdf/issues", + "version": "3.8.2", + "environment": { + "sdk": ">=2.12.0 <3.0.0" + }, + "dependencies": { + "archive": "^3.1.0", + "barcode": ">=2.2.0 <3.0.0", + "crypto": "^3.0.0", + "image": ">=3.0.1 <4.0.0", + "meta": ">=1.3.0 <2.0.0", + "path_parsing": ">=0.2.0 <2.0.0", + "vector_math": "^2.1.0", + "xml": ">=5.1.0 <7.0.0" + }, + "dev_dependencies": { + "flutter_lints": "^1.0.4", + "test": ">=1.16.0 <2.0.0" + } + }, + "archive_url": "https://pub.dartlang.org/packages/pdf/versions/3.8.2.tar.gz", + "published": "2022-07-25T11:38:25.983876Z" + }, + "versions": [ + { + "version": "1.0.0", + "pubspec": { + "version": "1.0.0", + "name": "pdf", + "dependencies": { + "ttf_parser": "^1.0.0", + "vector_math": "^2.0.7", + "meta": "^1.1.5" + }, + "author": "David PHAM-VAN ", + "description": "A pdf producer for Dart", + "homepage": "https://github.com/davbfr/dart_pdf", + "environment": { + "sdk": ">=1.8.0 <2.0.0" + }, + "dev_dependencies": { + "test": "any" + } + }, + "archive_url": "https://pub.dartlang.org/packages/pdf/versions/1.0.0.tar.gz", + "published": "2018-07-16T21:12:28.894137Z" + }, + { + "version": "3.8.2", + "pubspec": { + "name": "pdf", + "description": "A pdf producer for Dart. It can create pdf files for both web or flutter.", + "homepage": "https://github.com/DavBfr/dart_pdf/tree/master/pdf", + "repository": "https://github.com/DavBfr/dart_pdf", + "issue_tracker": "https://github.com/DavBfr/dart_pdf/issues", + "version": "3.8.2", + "environment": { + "sdk": ">=2.12.0 <3.0.0" + }, + "dependencies": { + "archive": "^3.1.0", + "barcode": ">=2.2.0 <3.0.0", + "crypto": "^3.0.0", + "image": ">=3.0.1 <4.0.0", + "meta": ">=1.3.0 <2.0.0", + "path_parsing": ">=0.2.0 <2.0.0", + "vector_math": "^2.1.0", + "xml": ">=5.1.0 <7.0.0" + }, + "dev_dependencies": { + "flutter_lints": "^1.0.4", + "test": ">=1.16.0 <2.0.0" + } + }, + "archive_url": "https://pub.dartlang.org/packages/pdf/versions/3.8.2.tar.gz", + "published": "2022-07-25T11:38:25.983876Z" + } + ] +} \ No newline at end of file diff --git a/swh/loader/package/pubdev/tests/test_pubdev.py b/swh/loader/package/pubdev/tests/test_pubdev.py --- a/swh/loader/package/pubdev/tests/test_pubdev.py +++ b/swh/loader/package/pubdev/tests/test_pubdev.py @@ -2,6 +2,9 @@ # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information + +import pytest + from swh.loader.package.pubdev.loader import PubDevLoader from swh.loader.package.utils import EMPTY_AUTHOR from swh.loader.tests import assert_last_visit_matches, check_snapshot, get_stats @@ -18,19 +21,19 @@ EXPECTED_PACKAGES = [ { - "url": "https://pub.dev/api/packages/Autolinker", # one version + "url": "https://pub.dev/packages/Autolinker", # one version }, { - "url": "https://pub.dev/api/packages/pdf", # multiple versions + "url": "https://pub.dev/packages/pdf", # multiple versions }, { - "url": "https://pub.dev/api/packages/bezier", # multiple authors + "url": "https://pub.dev/packages/bezier", # multiple authors }, { - "url": "https://pub.dev/api/packages/authentication", # empty author + "url": "https://pub.dev/packages/authentication", # empty author }, { - "url": "https://pub.dev/api/packages/abstract_io", # loose versions names + "url": "https://pub.dev/packages/abstract_io", # loose versions names }, ] @@ -260,11 +263,10 @@ assert release.author == EMPTY_AUTHOR -def test_pubdev_invalid_origin(swh_storage, requests_mock_datadir): - loader = PubDevLoader( - swh_storage, - "http://nowhere/api/packages/42", - ) +def test_pubdev_invalid_origin(swh_storage): - load_status = loader.load() - assert load_status["status"] == "failed" + with pytest.raises(AssertionError): + PubDevLoader( + swh_storage, + "http://nowhere/api/packages/42", + ) diff --git a/swh/loader/package/pubdev/tests/test_tasks.py b/swh/loader/package/pubdev/tests/test_tasks.py --- a/swh/loader/package/pubdev/tests/test_tasks.py +++ b/swh/loader/package/pubdev/tests/test_tasks.py @@ -13,7 +13,7 @@ res = swh_scheduler_celery_app.send_task( "swh.loader.package.pubdev.tasks.LoadPubDev", kwargs=dict( - url="some-url/api/packages/some-package", + url="https://pub.dev/packages/some-package", ), ) assert res