diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d65acf9e6..fecd97885 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -67,5 +67,5 @@ jobs: python-version: ${{ matrix.python-version }} - name: Run tests run: | - pip install ".[test]" - tox + pip install ".[unit-test]" + make test-unit diff --git a/AGENTS.md b/AGENTS.md index 8cc3170c5..20f924d80 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -3,8 +3,7 @@ ## Source of Truth - This is the official synchronous Python SDK for the Linode API. Supported - Python versions come from [pyproject.toml](pyproject.toml) (`>=3.10`); do not - infer support from the older environment names still present in [tox.ini](tox.ini). + Python versions come from [pyproject.toml](pyproject.toml) (`>=3.10`). - Make changes only in canonical source trees such as `linode_api4/`, `test/`, `docs/`, `examples/`, and `.github/`. Do not edit generated copies or output in `build/`, `dist/`, `docs/build/`, `docs/_build/`, or `linode_api4.egg-info/`. diff --git a/README.rst b/README.rst index 5615bb488..3f7f00a30 100644 --- a/README.rst +++ b/README.rst @@ -102,14 +102,13 @@ Tests ----- Tests live in the ``test`` directory. When invoking tests, make sure you are -in the root directory of this project. To run the full suite across all -supported python versions, use tox_: +in the root directory of this project. Install unit-test dependencies and run +the mocked unit suite with: .. code-block:: shell - tox - -Running tox also runs pylint and coverage reports. + python3 -m pip install -e ".[unit-test]" + make test-unit The test suite uses fixtures stored as JSON in ``test/fixtures``. These files contain sanitized JSON responses from the API - the file name is the URL called @@ -131,8 +130,6 @@ from the api base url that should be returned, for example:: linode = self.client.linode.instance_create('g6-standard-2', 'us-east') self.assertEqual(linode.id, 123) # passes -.. _tox: http://tox.readthedocs.io - Integration Tests ----------------- diff --git a/pyproject.toml b/pyproject.toml index 3b3d982b7..e4e641aa7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,32 +35,38 @@ dependencies = ["requests", "polling", "deprecated"] dynamic = ["version"] [project.optional-dependencies] -test = ["tox>=4.4.0"] - -dev = [ - "tox>=4.4.0", - "mock>=5.0.0", +test-shared = [ "pytest>=7.3.1", "httpretty>=1.1.4", + "pytest-rerunfailures", +] +unit-test = [ + "linode_api4[test-shared]", + "mock>=5.0.0", +] +int-test = [ + "linode_api4[test-shared]", + "cryptography", +] +lint = [ "black>=23.1.0", "isort>=5.12.0", "autoflake>=2.0.1", "pylint", "twine>=4.0.2", "build>=0.10.0", - "Sphinx>=6.0.0", - "sphinx-autobuild>=2021.3.14", - "sphinxcontrib-fulltoc>=1.2.0", - "build>=0.10.0", - "twine>=4.0.2", - "pytest-rerunfailures", ] - doc = [ "Sphinx>=6.0.0", "sphinx-autobuild>=2021.3.14", "sphinxcontrib-fulltoc>=1.2.0", ] +dev = [ + "linode_api4[unit-test]", + "linode_api4[int-test]", + "linode_api4[lint]", + "linode_api4[doc]", +] [project.urls] Homepage = "https://github.com/linode/linode_api4-python" diff --git a/test/integration/conftest.py b/test/integration/conftest.py index 6470d9df1..c5d60512e 100644 --- a/test/integration/conftest.py +++ b/test/integration/conftest.py @@ -2,7 +2,6 @@ import logging import os import random -import subprocess import time from test.integration.helpers import ( get_test_label, @@ -14,6 +13,8 @@ import pytest import requests +from cryptography.hazmat.primitives import serialization +from cryptography.hazmat.primitives.asymmetric import ed25519 from requests.exceptions import ConnectionError, RequestException from linode_api4 import ( @@ -263,17 +264,28 @@ def create_linode_for_pass_reset(test_linode_client, e2e_test_firewall): @pytest.fixture(scope="session") -def ssh_key_gen(tmp_path_factory): - key_path = tmp_path_factory.mktemp("ssh-key-gen") / "sdk-sshkey" - - subprocess.run( - ["ssh-keygen", "-q", "-t", "rsa", "-f", str(key_path), "-N", ""], - check=True, +def ssh_key_gen(): + key = ed25519.Ed25519PrivateKey.generate() + + pub_key = ( + key.public_key() + .public_bytes( + encoding=serialization.Encoding.OpenSSH, + format=serialization.PublicFormat.OpenSSH, + ) + .decode() + .rstrip() + ) + priv_key = ( + key.private_bytes( + encoding=serialization.Encoding.PEM, + format=serialization.PrivateFormat.OpenSSH, + encryption_algorithm=serialization.NoEncryption(), + ) + .decode() + .rstrip() ) - pub_key = key_path.with_suffix(".pub").read_text().rstrip() - priv_key = key_path.read_text().rstrip() - yield pub_key, priv_key diff --git a/tox.ini b/tox.ini deleted file mode 100644 index 266c26717..000000000 --- a/tox.ini +++ /dev/null @@ -1,17 +0,0 @@ -[tox] -envlist = py38,py39,py310,py311,py312 -skip_missing_interpreters = true - -[testenv] -deps = - pytest - coverage - mock - pylint - httpretty - pytest-rerunfailures -commands = - python -m pip install . - coverage run --source linode_api4 -m pytest test/unit - coverage report - pylint linode_api4