-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix pre-commit config and typings * tests: move registry infos to fixtures Signed-off-by: Tiziano Müller <[email protected]>
- Loading branch information
Showing
11 changed files
with
104 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,29 @@ | ||
exclude: ".all-contributorsrc|.tributors" | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.3.0 | ||
rev: v4.4.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-case-conflict | ||
- id: check-docstring-first | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- id: mixed-line-ending | ||
|
||
- repo: local | ||
- repo: https://github.com/pycqa/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: black | ||
name: black | ||
language: python | ||
types: [python] | ||
entry: black | ||
|
||
- id: isort | ||
name: isort | ||
args: [--filter-files] | ||
language: python | ||
types: [python] | ||
entry: isort | ||
|
||
- id: mypy | ||
name: mypy | ||
language: python | ||
types: [python] | ||
entry: mypy | ||
|
||
- repo: https://github.com/psf/black | ||
rev: 23.9.1 | ||
hooks: | ||
- id: black | ||
language_version: python3.11 | ||
- repo: https://github.com/pycqa/flake8 | ||
rev: 6.1.0 | ||
hooks: | ||
- id: flake8 | ||
name: flake8 | ||
language: python | ||
types: [python] | ||
entry: flake8 | ||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.5.1 | ||
hooks: | ||
- id: mypy | ||
additional_dependencies: ["types-requests"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import os | ||
from dataclasses import dataclass | ||
|
||
import pytest | ||
|
||
|
||
@dataclass | ||
class TestCredentials: | ||
with_auth: bool | ||
user: str | ||
password: str | ||
|
||
|
||
@pytest.fixture | ||
def registry(): | ||
host = os.environ.get("ORAS_HOST") | ||
port = os.environ.get("ORAS_PORT") | ||
|
||
if not host or not port: | ||
pytest.skip( | ||
"You must export ORAS_HOST and ORAS_PORT" | ||
" for a running registry before running tests." | ||
) | ||
|
||
return f"{host}:{port}" | ||
|
||
|
||
@pytest.fixture | ||
def credentials(request): | ||
with_auth = os.environ.get("ORAS_AUTH") == "true" | ||
user = os.environ.get("ORAS_USER", "myuser") | ||
pwd = os.environ.get("ORAS_PASS", "mypass") | ||
|
||
if with_auth and not user or not pwd: | ||
pytest.skip("To test auth you need to export ORAS_USER and ORAS_PASS") | ||
|
||
marks = [m.name for m in request.node.iter_markers()] | ||
if request.node.parent: | ||
marks += [m.name for m in request.node.parent.iter_markers()] | ||
|
||
if request.node.get_closest_marker("with_auth"): | ||
if request.node.get_closest_marker("with_auth").args[0] != with_auth: | ||
if with_auth: | ||
pytest.skip("test requires un-authenticated access to registry") | ||
else: | ||
pytest.skip("test requires authenticated access to registry") | ||
|
||
return TestCredentials(with_auth, user, pwd) | ||
|
||
|
||
@pytest.fixture | ||
def target(registry): | ||
return f"{registry}/dinosaur/artifact:v1" | ||
|
||
|
||
@pytest.fixture | ||
def target_dir(registry): | ||
return f"{registry}/dinosaur/directory:v1" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
__copyright__ = "Copyright The ORAS Authors." | ||
__license__ = "Apache-2.0" | ||
|
||
__version__ = "0.1.24" | ||
__version__ = "0.1.25" | ||
AUTHOR = "Vanessa Sochat" | ||
EMAIL = "[email protected]" | ||
NAME = "oras" | ||
|
@@ -19,14 +19,7 @@ | |
("requests", {"min_version": None}), | ||
) | ||
|
||
TESTS_REQUIRES = ( | ||
("pytest", {"min_version": "4.6.2"}), | ||
("mypy", {"min_version": None}), | ||
("pyflakes", {"min_version": None}), | ||
("black", {"min_version": None}), | ||
("types-requests", {"min_version": None}), | ||
("isort", {"min_version": None}), | ||
) | ||
TESTS_REQUIRES = (("pytest", {"min_version": "4.6.2"}),) | ||
|
||
DOCKER_REQUIRES = (("docker", {"exact_version": "5.0.1"}),) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters