Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`.
Expand Down
11 changes: 4 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
-----------------
Expand Down
30 changes: 18 additions & 12 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
32 changes: 22 additions & 10 deletions test/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
import logging
import os
import random
import subprocess
import time
from test.integration.helpers import (
get_test_label,
Expand All @@ -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 (
Expand Down Expand Up @@ -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


Expand Down
17 changes: 0 additions & 17 deletions tox.ini

This file was deleted.