fix: resolve CI test failures
Some checks failed
CI / test (push) Has been cancelled
CI / build (push) Has been cancelled

- Added ruff and mypy installation to CI workflow
- Removed deprecated license classifier from pyproject.toml
- Added pytest conftest.py for proper test discovery
- Fixed test paths in CI to match actual test file locations
- All 46 tests pass locally
This commit is contained in:
2026-03-22 21:50:02 +00:00
parent 0709018ba3
commit 685a56ae67

View File

@@ -0,0 +1,151 @@
import json
import os
import tempfile
from pathlib import Path
import pytest
from depviz.core.models import Dependency, PackageStatus
@pytest.fixture
def temp_project_dir():
"""Create a temporary project directory."""
with tempfile.TemporaryDirectory() as tmpdir:
yield Path(tmpdir)
@pytest.fixture
def sample_package_json(temp_project_dir):
"""Create a sample package.json file."""
package_json = {
"name": "test-project",
"version": "1.0.0",
"dependencies": {
"lodash": "^4.17.21",
"express": "^4.18.2"
},
"devDependencies": {
"jest": "^29.0.0",
"typescript": "^5.0.0"
}
}
path = temp_project_dir / "package.json"
path.write_text(json.dumps(package_json, indent=2))
return path
@pytest.fixture
def sample_package_lock_json(temp_project_dir):
"""Create a sample package-lock.json file."""
package_lock = {
"name": "test-project",
"version": "1.0.0",
"packages": {
"": {
"name": "test-project",
"version": "1.0.0"
},
"node_modules/lodash": {
"name": "lodash",
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
},
"node_modules/express": {
"name": "express",
"version": "4.18.2",
"resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
"dependencies": {
"body-parser": {
"version": "1.20.2"
}
}
}
}
}
path = temp_project_dir / "package-lock.json"
path.write_text(json.dumps(package_lock, indent=2))
return path
@pytest.fixture
def sample_requirements_txt(temp_project_dir):
"""Create a sample requirements.txt file."""
content = """requests>=2.28.0
flask>=2.3.0
redis>=4.5.0
"""
path = temp_project_dir / "requirements.txt"
path.write_text(content)
return path
@pytest.fixture
def sample_pipfile_lock(temp_project_dir):
"""Create a sample Pipfile.lock file."""
pipfile_lock = {
"default": {
"requests": {
"version": "==2.28.0"
},
"flask": {
"version": "==2.3.0"
}
},
"develop": {
"pytest": {
"version": "==7.4.0"
}
}
}
path = temp_project_dir / "Pipfile.lock"
path.write_text(json.dumps(pipfile_lock, indent=2))
return path
@pytest.fixture
def sample_pyproject_toml(temp_project_dir):
"""Create a sample pyproject.toml file."""
content = """[project]
name = \"test-project\"
version = \"1.0.0\"
dependencies = [
\"requests>=2.28.0\",
\"flask>=2.3.0\",
]
[project.optional-dependencies]
dev = [
\"pytest>=7.4.0\",
\"black>=23.0.0\",
]
"""
path = temp_project_dir / "pyproject.toml"
path.write_text(content)
return path
@pytest.fixture
def sample_dependencies():
"""Create sample Dependency objects."""
return [
Dependency(
name="lodash",
version="4.17.21",
status=PackageStatus.CURRENT,
is_dev=False
),
Dependency(
name="express",
version="4.18.2",
status=PackageStatus.OUTDATED,
latest_version="4.19.0",
is_dev=False
),
Dependency(
name="jest",
version="29.0.0",
status=PackageStatus.VULNERABLE,
is_dev=True
),
]