diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..eefd6ce --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,127 @@ +"""Pytest configuration and fixtures for DepAudit tests.""" + +import json +import tempfile +from pathlib import Path + +import pytest + + +@pytest.fixture +def sample_package_json(): + """Sample package.json for JavaScript projects.""" + return { + "name": "test-project", + "version": "1.0.0", + "description": "A test project", + "main": "index.js", + "dependencies": { + "express": "^4.18.0", + "lodash": "^4.17.21" + }, + "devDependencies": { + "jest": "^29.0.0", + "fsevents": "^2.3.0" + } + } + + +@pytest.fixture +def sample_requirements_txt(): + """Sample requirements.txt for Python projects.""" + return """ +requests>=2.28.0 +flask>=2.0.0 +pytest>=7.0.0 +""" + + +@pytest.fixture +def sample_pyproject_toml(): + """Sample pyproject.toml for Python projects.""" + return """ +[project] +name = "test-project" +version = "1.0.0" +description = "A test project" +requires-python = ">=3.9" +dependencies = [ + "requests>=2.28.0", + "flask>=2.0.0", +] + +[project.optional-dependencies] +dev = ["pytest>=7.0.0", "black>=22.0.0"] +""" + + +@pytest.fixture +def sample_go_mod(): + """Sample go.mod for Go projects.""" + return """ +module github.com/test/project + +go 1.20 + +require ( + github.com/gin-gonic/gin v1.9.0 + github.com/spf13/viper v1.15.0 +) + +require github.com/some/repo v1.2.0 // indirect +""" + + +@pytest.fixture +def sample_cargo_toml(): + """Sample Cargo.toml for Rust projects.""" + return """ +[package] +name = "test-project" +version = "1.0.0" +edition = "2021" + +[dependencies] +serde = { version = "1.0", features = ["derive"] } +tokio = { version = "1.0", features = ["full"] } + +[dev-dependencies] +proptest = "1.0" +""" + + +@pytest.fixture +def sample_pom_xml(): + """Sample pom.xml for Java projects.""" + return """ + + 4.0.0 + + com.example + test-project + 1.0.0 + + + + org.springframework + spring-core + 6.0.0 + + + com.fasterxml.jackson.core + jackson-databind + 2.15.0 + test + + + +""" + + +@pytest.fixture +def temp_dir(): + """Create a temporary directory for tests.""" + with tempfile.TemporaryDirectory() as tmpdir: + yield Path(tmpdir)