From 848d3da6d6cb5e71781c0d523f78f2f7b3c1ac11 Mon Sep 17 00:00:00 2001 From: Heinz-Alexander Fuetterer Date: Sat, 17 Aug 2024 12:39:29 +0200 Subject: [PATCH] style: apply pre-commit hooks --- pyproject.toml | 149 +++++++----------- src/oaipmh_scythe/client.py | 7 +- tests/conftest.py | 2 +- tests/integration/test_get_record.py | 10 +- tests/integration/test_identify.py | 8 +- tests/integration/test_list_identifiers.py | 28 ++-- .../integration/test_list_metadata_formats.py | 6 +- tests/integration/test_list_records.py | 28 ++-- tests/integration/test_list_sets.py | 6 +- tests/unit/test_iterator.py | 8 +- tests/unit/test_models.py | 24 +-- tests/unit/test_response.py | 2 +- tests/unit/test_utils.py | 4 +- 13 files changed, 120 insertions(+), 162 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 22bdb2e..372caa1 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,6 +2,12 @@ # Ref: https://hatch.pypa.io/latest/config/metadata/ # ------------------------------------------------------------------------------ +[build-system] +build-backend = "hatchling.build" +requires = [ + "hatchling", +] + [project] name = "oaipmh-scythe" description = "A Scythe for harvesting OAI-PMH repositories." @@ -11,7 +17,7 @@ keywords = [ "oai-pmh", "oai-pmh-client", ] -license = {text = "BSD-3-Clause"} +license = { text = "BSD-3-Clause" } authors = [ { name = "Heinz-Alexander Fütterer" }, ] @@ -36,18 +42,17 @@ dependencies = [ "httpx>=0.25", "lxml>=5.1", ] -[project.optional-dependencies] -dev = [ +optional-dependencies.dev = [ "pre-commit~=3.6", ] -docs = [ +optional-dependencies.docs = [ "mike~=2.0", "mkdocs~=1.5", "mkdocs-include-markdown-plugin~=6.0", "mkdocs-material~=9.5", "mkdocstrings[python]~=0.24", ] -test = [ +optional-dependencies.test = [ "pytest~=8.0", "pytest-cov~=5.0", "pytest-mock~=3.12", @@ -56,17 +61,10 @@ test = [ "pytest-xdist~=3.5", "respx~=0.20", ] -[project.urls] -Changelog = "https://github.com/afuetterer/oaipmh-scythe/blob/main/CHANGELOG.md" -Documentation = "https://afuetterer.github.io/oaipmh-scythe" -Issues = "https://github.com/afuetterer/oaipmh-scythe/issues" -Repository = "https://github.com/afuetterer/oaipmh-scythe.git" - -[build-system] -build-backend = "hatchling.build" -requires = [ - "hatchling", -] +urls.Changelog = "https://github.com/afuetterer/oaipmh-scythe/blob/main/CHANGELOG.md" +urls.Documentation = "https://afuetterer.github.io/oaipmh-scythe" +urls.Issues = "https://github.com/afuetterer/oaipmh-scythe/issues" +urls.Repository = "https://github.com/afuetterer/oaipmh-scythe.git" [tool.hatch.build.targets.sdist] include = [ @@ -75,17 +73,17 @@ include = [ ] [tool.hatch.build.targets.wheel] -packages = ["src/oaipmh_scythe"] +packages = [ "src/oaipmh_scythe" ] [tool.hatch.version] path = "src/oaipmh_scythe/__about__.py" [tool.hatch.envs.default] installer = "uv" -features = ["dev", "test"] -post-install-commands = ["pre-commit install"] +features = [ "dev", "test" ] +post-install-commands = [ "pre-commit install" ] [tool.hatch.envs.default.scripts] -check = ["lint", "typecheck"] +check = [ "lint", "typecheck" ] lint = "SKIP=mypy pre-commit run --all-files --color=always --show-diff-on-failure" typecheck = "pre-commit run --all-files --color=always --show-diff-on-failure mypy" test = "pytest {args:tests}" @@ -97,34 +95,26 @@ cov-total = """ """ [tool.hatch.envs.docs] -features = ["docs"] +features = [ "docs" ] template = "docs" [tool.hatch.envs.docs.scripts] build = "mkdocs build --config-file=docs/mkdocs.yml" serve = "mkdocs serve --verbose --config-file=docs/mkdocs.yml" deploy = "mike deploy --push --update-aliases $(hatch version) latest --config-file=docs/mkdocs.yml" -# ruff -# Ref: https://docs.astral.sh/ruff/configuration/ -# ------------------------------------------------------------------------------ - -[tool.ruff] +[tool.ruff] # Ref: https://docs.astral.sh/ruff/configuration/ line-length = 120 -src = ["src", "tests"] - -[tool.ruff.format] +src = [ "src", "tests" ] # Ref: https://docs.astral.sh/ruff/settings/#format -docstring-code-format = true - -[tool.ruff.lint] +format.docstring-code-format = true # Ref: https://docs.astral.sh/ruff/rules/ -extend-select = [ +lint.extend-select = [ "A", # flake8-builtins "B", # flake8-bugbear "C4", # flake8-comprehensions "D", # pydocstyle - "I", # isort "G", # flake8-logging-format + "I", # isort "PERF", # perflint-perf "PGH", # pygrep-hooks "PIE", # flake8-pie @@ -134,70 +124,55 @@ extend-select = [ "RSE", # flake8-raise "RUF", # ruff "SIM", # flake8-simplify - "TCH", # flake8-type-checking "T20", # flake8-print + "TCH", # flake8-type-checking "UP", # pyupgrade "W", # pycodestyle "YTT", # flake8-2020 ] -ignore = [ +lint.ignore = [ "D105", # undocumented-magic-method "D107", # undocumented-public-init ] -unfixable = [ - "F401", # unused-import -] -isort.known-first-party = ["oaipmh_scythe"] -pydocstyle.convention = "google" - -[tool.ruff.lint.per-file-ignores] -"src/oaipmh_scythe/__about__.py" = [ +lint.per-file-ignores."src/oaipmh_scythe/__about__.py" = [ "D100", # undocumented-public-module ] -"src/oaipmh_scythe/client.py" = [ +lint.per-file-ignores."src/oaipmh_scythe/client.py" = [ "PLR0913", # too-many-arguments ] -"tests/*" = [ - "D100", # undocumented-public-module - "D103", # undocumented-public-function - "PLR2004", # magic-value-comparison +lint.per-file-ignores."tests/**.py" = [ + "D", # pydocstyle + "PLR2004", # magic-value-comparison ] +lint.unfixable = [ + "F401", # unused-import +] +lint.isort.known-first-party = [ "oaipmh_scythe" ] +lint.pydocstyle.convention = "google" -# sp-repo-review -# Ref: https://github.com/scientific-python/cookie/tree/main#list-of-checks -# ------------------------------------------------------------------------------ - -[tool.repo-review] +[tool.repo-review] # Ref: https://github.com/scientific-python/cookie/tree/main#list-of-checks ignore = [ # Pre-commit - "PC111", # blacken-docs - "PC160", # codespell - "PC170", # pygrep hooks - "PC180", # prettier - "MY", # mypy - "RTD", # read the docs + "PC111", # blacken-docs + "PC160", # codespell + "PC170", # pygrep hooks + "PC180", # prettier + "MY", # mypy + "RTD", # read the docs ] -# pytest -# Ref: https://docs.pytest.org/en/stable/customize.html -# ------------------------------------------------------------------------------ - -[tool.pytest.ini_options] +[tool.pytest.ini_options] # Ref: https://docs.pytest.org/en/stable/customize.html minversion = "8.0" -addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"] -filterwarnings = ["error"] +addopts = [ "-ra", "--showlocals", "--strict-markers", "--strict-config" ] +filterwarnings = [ "error" ] log_cli_level = "INFO" xfail_strict = true testpaths = "tests" -# coverage.py -# Ref: https://coverage.readthedocs.io/en/latest/config.html -# ------------------------------------------------------------------------------ - -[tool.coverage.run] +[tool.coverage.run] # Ref: https://coverage.readthedocs.io/en/latest/config.html branch = true parallel = true -source = ["oaipmh_scythe"] +source = [ "oaipmh_scythe" ] omit = [ "__about__.py", ] @@ -212,31 +187,19 @@ show_missing = true skip_covered = true skip_empty = true -# mypy -# Ref: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file -# ------------------------------------------------------------------------------ - -[tool.mypy] +[tool.mypy] # Ref: https://mypy.readthedocs.io/en/stable/config_file.html#using-a-pyproject-toml-file python_version = "3.10" pretty = true show_column_numbers = true show_error_context = true -enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"] +enable_error_code = [ "ignore-without-code", "redundant-expr", "truthy-bool" ] warn_unreachable = true -# licensecheck -# Ref: https://github.com/FHPythonUtils/LicenseCheck/#example-1-pyprojecttoml -# ------------------------------------------------------------------------------ - -[tool.licensecheck] +[tool.licensecheck] # Ref: https://github.com/FHPythonUtils/LicenseCheck/#example-1-pyprojecttoml using = "PEP631" format = "ansi" -# python-semantic-release -# Ref: https://python-semantic-release.readthedocs.io/en/latest/configuration.html#settings -# ------------------------------------------------------------------------------ - -[tool.semantic_release] +[tool.semantic_release] # Ref: https://python-semantic-release.readthedocs.io/en/latest/configuration.html#settings commit_author = "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>" commit_message = "chore: release {version}\n\nAutomatically generated by python-semantic-release [skip ci]" major_on_zero = false @@ -254,10 +217,6 @@ python -m build --installer=uv changelog.template_dir = ".github/templates" changelog.environment.keep_trailing_newline = true -# typos -# Ref: https://github.com/crate-ci/typos/blob/master/docs/reference.md -# ------------------------------------------------------------------------------ - -[tool.typos] +[tool.typos] # Ref: https://github.com/crate-ci/typos/blob/master/docs/reference.md # add "spellchecker:disable-line" to ignore specific lines -default.extend-ignore-re = ["(?Rm)^.*# spellchecker:disable-line$"] +default.extend-ignore-re = [ "(?Rm)^.*# spellchecker:disable-line$" ] diff --git a/src/oaipmh_scythe/client.py b/src/oaipmh_scythe/client.py index d01e288..5d2ad67 100644 --- a/src/oaipmh_scythe/client.py +++ b/src/oaipmh_scythe/client.py @@ -94,13 +94,12 @@ def __init__( if inspect.isclass(iterator) and issubclass(iterator, BaseOAIIterator): self.iterator = iterator else: - raise TypeError("Argument 'iterator' must be subclass of %s" % BaseOAIIterator.__name__) + raise TypeError(f"Argument 'iterator' must be subclass of {BaseOAIIterator.__name__}") self.max_retries = max_retries self.retry_status_codes = retry_status_codes or (503,) if default_retry_after <= 0: raise ValueError( - "Invalid value for 'default_retry_after': %s. default_retry_after must be positive int or float." - % default_retry_after + f"Invalid value for 'default_retry_after': {default_retry_after}. default_retry_after must be positive int or float." ) self.default_retry_after = default_retry_after self.oai_namespace = OAI_NAMESPACE @@ -108,7 +107,7 @@ def __init__( self.encoding = encoding self.auth = auth if timeout <= 0: - raise ValueError("Invalid value for 'timeout': %s. Timeout must be positive int or float." % timeout) + raise ValueError(f"Invalid value for 'timeout': {timeout}. Timeout must be positive int or float.") self.timeout = timeout self._client: httpx.Client | None = None diff --git a/tests/conftest.py b/tests/conftest.py index aacb83b..b443ef0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -14,6 +14,6 @@ def vcr_config() -> dict[str, str]: return {"cassette_library_dir": "tests/cassettes"} -@pytest.fixture() +@pytest.fixture def scythe() -> Scythe: return Scythe("https://zenodo.org/oai2d") diff --git a/tests/integration/test_get_record.py b/tests/integration/test_get_record.py index f5163f0..1cf5b58 100644 --- a/tests/integration/test_get_record.py +++ b/tests/integration/test_get_record.py @@ -19,7 +19,7 @@ @pytest.mark.default_cassette("get_record.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_get_record_with_default_metadata_prefix(scythe: Scythe) -> None: record = scythe.get_record(identifier=IDENTIFIER, metadata_prefix="oai_dc") assert isinstance(record, Record) @@ -27,7 +27,7 @@ def test_get_record_with_default_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("get_record.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_get_record_without_metadata_prefix(scythe: Scythe) -> None: record = scythe.get_record(identifier=IDENTIFIER) assert isinstance(record, Record) @@ -35,7 +35,7 @@ def test_get_record_without_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("get_record.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_get_record_with_valid_metadata_prefix(scythe: Scythe) -> None: record = scythe.get_record(identifier=IDENTIFIER, metadata_prefix="datacite") assert isinstance(record, Record) @@ -43,7 +43,7 @@ def test_get_record_with_valid_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("get_record.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_get_record_with_invalid_metadata_prefix(scythe: Scythe) -> None: with pytest.raises(HTTPStatusError): # cannotDisseminateFormat @@ -51,7 +51,7 @@ def test_get_record_with_invalid_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("id_does_not_exist.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_get_record_with_invalid_identifier(scythe: Scythe) -> None: # idDoesNotExist with pytest.raises(HTTPStatusError): diff --git a/tests/integration/test_identify.py b/tests/integration/test_identify.py index b145b69..5472be0 100644 --- a/tests/integration/test_identify.py +++ b/tests/integration/test_identify.py @@ -12,21 +12,21 @@ @pytest.mark.default_cassette("identify.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_close(scythe: Scythe) -> None: scythe.identify() scythe.close() @pytest.mark.default_cassette("identify.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_context_manager() -> None: with Scythe("https://zenodo.org/oai2d") as scythe: scythe.identify() @pytest.mark.default_cassette("identify.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_identify(scythe: Scythe) -> None: identify = scythe.identify() assert isinstance(identify, Identify) @@ -34,7 +34,7 @@ def test_identify(scythe: Scythe) -> None: @pytest.mark.default_cassette("identify.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_non_oai_pmh_url() -> None: scythe = Scythe("https://duckduckgo.com/") with pytest.raises(ValueError, match="Identify element not found in the XML"): diff --git a/tests/integration/test_list_identifiers.py b/tests/integration/test_list_identifiers.py index 9910ee3..0f07c2f 100644 --- a/tests/integration/test_list_identifiers.py +++ b/tests/integration/test_list_identifiers.py @@ -16,7 +16,7 @@ @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_default_metadata_prefix(scythe: Scythe) -> None: headers = scythe.list_identifiers(metadata_prefix="oai_dc") assert isinstance(headers, Iterator) @@ -26,7 +26,7 @@ def test_list_identifiers_with_default_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_without_metadata_prefix(scythe: Scythe) -> None: headers = scythe.list_identifiers() assert isinstance(headers, Iterator) @@ -36,7 +36,7 @@ def test_list_identifiers_without_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_valid_metadata_prefix(scythe: Scythe) -> None: headers = scythe.list_identifiers(metadata_prefix="datacite") assert isinstance(headers, Iterator) @@ -46,7 +46,7 @@ def test_list_identifiers_with_valid_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_invalid_metadata_prefix(scythe: Scythe) -> None: # cannotDisseminateFormat headers = scythe.list_identifiers(metadata_prefix="XXX") @@ -55,7 +55,7 @@ def test_list_identifiers_with_invalid_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_from(scythe: Scythe) -> None: headers = scythe.list_identifiers(from_="2024-01-16") assert isinstance(headers, Iterator) @@ -64,7 +64,7 @@ def test_list_identifiers_with_from(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_until(scythe: Scythe) -> None: headers = scythe.list_identifiers(until="2024-01-17") assert isinstance(headers, Iterator) @@ -73,7 +73,7 @@ def test_list_identifiers_with_until(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_from_and_until(scythe: Scythe) -> None: headers = scythe.list_identifiers(from_="2024-01-16", until="2024-01-17") header = next(headers) @@ -81,7 +81,7 @@ def test_list_identifiers_with_from_and_until(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_valid_set(scythe: Scythe) -> None: headers = scythe.list_identifiers(set_="software") header = next(headers) @@ -89,7 +89,7 @@ def test_list_identifiers_with_valid_set(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_invalid_set(scythe: Scythe) -> None: # noRecordsMatch headers = scythe.list_identifiers(set_="XXX") @@ -98,7 +98,7 @@ def test_list_identifiers_with_invalid_set(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_valid_resumption_token(scythe: Scythe) -> None: token = "eJyNzt1ugjAYgOF7" headers = scythe.list_identifiers(resumption_token=token) @@ -108,7 +108,7 @@ def test_list_identifiers_with_valid_resumption_token(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_with_invalid_resumption_token(scythe: Scythe) -> None: # badResumptionToken headers = scythe.list_identifiers(resumption_token="XXX") @@ -117,7 +117,7 @@ def test_list_identifiers_with_invalid_resumption_token(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_raises_no_records_match(scythe: Scythe) -> None: # noRecordsMatch headers = scythe.list_identifiers(from_="2025-01-15") @@ -126,7 +126,7 @@ def test_list_identifiers_raises_no_records_match(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_ignore_deleted(scythe: Scythe) -> None: headers = scythe.list_identifiers(ignore_deleted=True) headers = list(headers) @@ -136,7 +136,7 @@ def test_list_identifiers_ignore_deleted(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_identifiers_oai_response(scythe: Scythe) -> None: scythe.iterator = OAIResponseIterator responses = scythe.list_identifiers(metadata_prefix="oai_dc") diff --git a/tests/integration/test_list_metadata_formats.py b/tests/integration/test_list_metadata_formats.py index a2cb7d0..c6722d2 100644 --- a/tests/integration/test_list_metadata_formats.py +++ b/tests/integration/test_list_metadata_formats.py @@ -17,7 +17,7 @@ @pytest.mark.default_cassette("list_metadata_formats.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_metadata_formats(scythe: Scythe) -> None: metadata_formats = scythe.list_metadata_formats() assert isinstance(metadata_formats, Iterator) @@ -27,7 +27,7 @@ def test_list_metadata_formats(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_metadata_formats.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_metadata_formats_with_valid_identifier(scythe: Scythe) -> None: metadata_formats = scythe.list_metadata_formats(identifier="oai:zenodo.org:10357859") assert isinstance(metadata_formats, Iterator) @@ -37,7 +37,7 @@ def test_list_metadata_formats_with_valid_identifier(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_metadata_formats.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_metadata_formats_with_invalid_identifier(scythe: Scythe) -> None: # idDoesNotExist metadata_formats = scythe.list_metadata_formats(identifier="oai:zenodo.org:XXX") diff --git a/tests/integration/test_list_records.py b/tests/integration/test_list_records.py index bd4e760..b99a906 100644 --- a/tests/integration/test_list_records.py +++ b/tests/integration/test_list_records.py @@ -23,7 +23,7 @@ @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_default_metadata_prefix(scythe: Scythe) -> None: records = scythe.list_records(metadata_prefix="oai_dc") assert isinstance(records, Iterator) @@ -33,7 +33,7 @@ def test_list_records_with_default_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_without_metadata_prefix(scythe: Scythe) -> None: records = scythe.list_records() assert isinstance(records, Iterator) @@ -43,7 +43,7 @@ def test_list_records_without_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_valid_metadata_prefix(scythe: Scythe) -> None: records = scythe.list_records(metadata_prefix="datacite") assert isinstance(records, Iterator) @@ -53,7 +53,7 @@ def test_list_records_with_valid_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_invalid_metadata_prefix(scythe: Scythe) -> None: # cannotDisseminateFormat records = scythe.list_records(metadata_prefix="XXX") @@ -62,7 +62,7 @@ def test_list_records_with_invalid_metadata_prefix(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_from(scythe: Scythe) -> None: records = scythe.list_records(from_="2024-01-16") assert isinstance(records, Iterator) @@ -71,7 +71,7 @@ def test_list_records_with_from(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_until(scythe: Scythe) -> None: records = scythe.list_records(until="2024-01-17") assert isinstance(records, Iterator) @@ -80,7 +80,7 @@ def test_list_records_with_until(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_from_and_until(scythe: Scythe) -> None: records = scythe.list_records(from_="2024-01-16", until="2024-01-17") record = next(records) @@ -88,7 +88,7 @@ def test_list_records_with_from_and_until(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_valid_set(scythe: Scythe) -> None: records = scythe.list_records(set_="software") record = next(records) @@ -96,7 +96,7 @@ def test_list_records_with_valid_set(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_invalid_set(scythe: Scythe) -> None: # noRecordsMatch records = scythe.list_records(set_="XXX") @@ -105,7 +105,7 @@ def test_list_records_with_invalid_set(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_valid_resumption_token(scythe: Scythe) -> None: token = "eJyNzE1vgjAcgPHv8j" records = scythe.list_records(resumption_token=token) @@ -115,7 +115,7 @@ def test_list_records_with_valid_resumption_token(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_with_invalid_resumption_token(scythe: Scythe) -> None: # badResumptionToken records = scythe.list_records(resumption_token="XXX") @@ -124,7 +124,7 @@ def test_list_records_with_invalid_resumption_token(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_raises_no_records_match(scythe: Scythe) -> None: # noRecordsMatch records = scythe.list_records(from_="2025-01-15") @@ -133,7 +133,7 @@ def test_list_records_raises_no_records_match(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_ignore_deleted(scythe: Scythe) -> None: records = scythe.list_records(ignore_deleted=True) records = list(records) @@ -143,7 +143,7 @@ def test_list_records_ignore_deleted(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_records.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_records_oai_response(scythe: Scythe) -> None: scythe.iterator = OAIResponseIterator responses = scythe.list_records() diff --git a/tests/integration/test_list_sets.py b/tests/integration/test_list_sets.py index f92cece..7384611 100644 --- a/tests/integration/test_list_sets.py +++ b/tests/integration/test_list_sets.py @@ -17,7 +17,7 @@ @pytest.mark.default_cassette("list_sets.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_sets(scythe: Scythe) -> None: sets = scythe.list_sets() assert isinstance(sets, Iterator) @@ -30,7 +30,7 @@ def test_list_sets(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_sets.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_sets_with_valid_resumption_token(scythe: Scythe) -> None: token = "eyJzZWVkIjowLjcwNjgzOTQzNjM5NDY1MTksInBhZ2UiOjIsImt3YXJncyI6e319.ZYazJA" # spellchecker:disable-line sets = scythe.list_sets(resumption_token=token) @@ -40,7 +40,7 @@ def test_list_sets_with_valid_resumption_token(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_sets.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_list_sets_with_invalid_resumption_token(scythe: Scythe) -> None: # badResumptionToken sets = scythe.list_sets(resumption_token="XXX") diff --git a/tests/unit/test_iterator.py b/tests/unit/test_iterator.py index de4374e..80c5f88 100644 --- a/tests/unit/test_iterator.py +++ b/tests/unit/test_iterator.py @@ -14,14 +14,14 @@ @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_iterator_str(scythe: Scythe) -> None: iterator = OAIResponseIterator(scythe, query) assert str(iterator) == "" @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_oai_response_iterator(scythe: Scythe) -> None: iterator = OAIResponseIterator(scythe, query) responses = list(iterator) @@ -31,7 +31,7 @@ def test_oai_response_iterator(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_oai_item_iterator(scythe: Scythe) -> None: iterator = OAIItemIterator(scythe, query) headers = list(iterator) @@ -41,7 +41,7 @@ def test_oai_item_iterator(scythe: Scythe) -> None: @pytest.mark.default_cassette("list_identifiers.yaml") -@pytest.mark.vcr() +@pytest.mark.vcr def test_oai_item_iterator_ignore_deleted(scythe: Scythe) -> None: iterator = OAIItemIterator(scythe, query, ignore_deleted=True) headers = list(iterator) diff --git a/tests/unit/test_models.py b/tests/unit/test_models.py index 85419dd..0661145 100644 --- a/tests/unit/test_models.py +++ b/tests/unit/test_models.py @@ -14,7 +14,7 @@ def test_resumption_token_repr() -> None: assert repr(token) == "" -@pytest.fixture() +@pytest.fixture def identify_response(mocker): xml = """ @@ -32,7 +32,7 @@ def identify_response(mocker): return mock_response -@pytest.fixture() +@pytest.fixture def identify(identify_response) -> Identify: return Identify(identify_response) @@ -91,12 +91,12 @@ def deleted_header_element(): return etree.fromstring(xml.encode()) -@pytest.fixture() +@pytest.fixture def header(header_element): return Header(header_element) -@pytest.fixture() +@pytest.fixture def deleted_header(deleted_header_element): return Header(deleted_header_element) @@ -123,7 +123,7 @@ def test_header_iter(header): assert items == {"identifier": "oai:zenodo.org:6538892", "datestamp": "2022-05-11T13:49:36Z", "setSpecs": []} -@pytest.fixture() +@pytest.fixture def record_element(): xml = """ @@ -143,7 +143,7 @@ def record_element(): return etree.fromstring(xml.encode()) -@pytest.fixture() +@pytest.fixture def deleted_record_lement(): xml = """ @@ -163,12 +163,12 @@ def deleted_record_lement(): return etree.fromstring(xml.encode()) -@pytest.fixture() +@pytest.fixture def record(record_element): return Record(record_element) -@pytest.fixture() +@pytest.fixture def deleted_record(deleted_record_lement): return Record(deleted_record_lement) @@ -201,7 +201,7 @@ def test_deleted_record_no_metadata(deleted_record): _ = record.metadata -@pytest.fixture() +@pytest.fixture def set_element(): xml = """ @@ -213,7 +213,7 @@ def set_element(): return etree.fromstring(xml.encode()) -@pytest.fixture() +@pytest.fixture def oai_set(set_element): return Set(set_element) @@ -233,7 +233,7 @@ def test_set_iter(oai_set): assert set_items["setSpec"] == ["user-emi"] -@pytest.fixture() +@pytest.fixture def mdf_element(): xml = """ @@ -245,7 +245,7 @@ def mdf_element(): return etree.fromstring(xml.encode()) -@pytest.fixture() +@pytest.fixture def mdf(mdf_element): return MetadataFormat(mdf_element) diff --git a/tests/unit/test_response.py b/tests/unit/test_response.py index a7a5690..beea9a9 100644 --- a/tests/unit/test_response.py +++ b/tests/unit/test_response.py @@ -29,7 +29,7 @@ """ -@pytest.fixture() +@pytest.fixture def mock_response(mocker: MockerFixture): response = mocker.Mock() response.text = IDENTIFY_XML diff --git a/tests/unit/test_utils.py b/tests/unit/test_utils.py index b362424..d6078a8 100644 --- a/tests/unit/test_utils.py +++ b/tests/unit/test_utils.py @@ -9,13 +9,13 @@ from oaipmh_scythe.utils import filter_dict_except_resumption_token, get_namespace, remove_none_values, xml_to_dict -@pytest.fixture() +@pytest.fixture def xml_element_with_namespace() -> etree._Element: xml = 'https://zenodo.org/oai2d' return etree.fromstring(xml) -@pytest.fixture() +@pytest.fixture def xml_element_without_namespace() -> etree._Element: xml = 'https://zenodo.org/oai2d' return etree.fromstring(xml)