feat: add GitHub Actions workflow for running tests on push and pull request
This commit is contained in:
@@ -3,6 +3,7 @@ import tempfile
|
||||
import tomllib
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
from zipfile import ZipFile
|
||||
|
||||
|
||||
@@ -23,10 +24,18 @@ class PackTest(unittest.TestCase):
|
||||
def test_builds_platform_specific_extension_zips(self):
|
||||
pack = load_pack()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
directory_path = Path(directory)
|
||||
wheel_path = directory_path / "blendjob-0.1.13-py3-none-any.whl"
|
||||
wheel_path.write_bytes(b"wheel")
|
||||
original_dist = pack.DIST_DIR
|
||||
pack.DIST_DIR = Path(directory)
|
||||
pack.DIST_DIR = directory_path / "dist"
|
||||
try:
|
||||
output_paths = pack.build_all()
|
||||
with patch.object(
|
||||
pack,
|
||||
"download_wheels",
|
||||
return_value=[wheel_path],
|
||||
):
|
||||
output_paths = pack.build_all()
|
||||
finally:
|
||||
pack.DIST_DIR = original_dist
|
||||
|
||||
@@ -105,6 +114,32 @@ class PackTest(unittest.TestCase):
|
||||
manifest.split("platforms =", 1)[-1],
|
||||
)
|
||||
|
||||
def test_reads_extension_dependencies_from_pyproject(self):
|
||||
pack = load_pack()
|
||||
self.assertEqual(pack.project_dependencies(), ["blendjob==0.1.13"])
|
||||
|
||||
def test_downloads_declared_wheels_for_target_platform(self):
|
||||
pack = load_pack()
|
||||
with tempfile.TemporaryDirectory() as directory:
|
||||
destination = Path(directory)
|
||||
|
||||
def fake_run(command, check):
|
||||
self.assertTrue(check)
|
||||
(destination / "blendjob-0.1.13-py3-none-any.whl").write_bytes(
|
||||
b"wheel"
|
||||
)
|
||||
|
||||
with patch.object(pack.subprocess, "run", side_effect=fake_run) as run:
|
||||
wheels = pack.download_wheels("linux-x64", destination)
|
||||
|
||||
command = run.call_args.args[0]
|
||||
self.assertIn("blendjob==0.1.13", command)
|
||||
self.assertIn("--python-version=3.11", command)
|
||||
self.assertIn("--platform=manylinux2014_x86_64", command)
|
||||
self.assertEqual(
|
||||
[wheel.name for wheel in wheels],
|
||||
["blendjob-0.1.13-py3-none-any.whl"],
|
||||
)
|
||||
def test_rejects_unknown_platform(self):
|
||||
pack = load_pack()
|
||||
with self.assertRaisesRegex(ValueError, "Unsupported platform"):
|
||||
|
||||
Reference in New Issue
Block a user