fix: resolve CI test failures
- Added missing fixtures for api_snapshot tests in conftest.py - Added PYTHONPATH to CI workflow for module discovery
This commit is contained in:
@@ -20,14 +20,14 @@ def temp_dir():
|
||||
def sample_package_json():
|
||||
"""Create a sample package.json file content."""
|
||||
return """{
|
||||
\"name\": \"test-project\",
|
||||
\"version\": \"1.0.0\",
|
||||
\"dependencies\": {
|
||||
\"express\": \"4.18.2\",
|
||||
\"lodash\": \"4.17.20\"
|
||||
"name": "test-project",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"express": "4.18.2",
|
||||
"lodash": "4.17.20"
|
||||
},
|
||||
\"devDependencies\": {
|
||||
\"jest\": \"29.7.0\"
|
||||
"devDependencies": {
|
||||
"jest": "29.7.0"
|
||||
}
|
||||
}"""
|
||||
|
||||
@@ -61,13 +61,13 @@ def sample_cargo_toml():
|
||||
"""Create a sample Cargo.toml file content."""
|
||||
return """
|
||||
[package]
|
||||
name = \"my-project\"
|
||||
version = \"0.1.0\"
|
||||
edition = \"2021\"
|
||||
name = "my-project"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
serde = \"1.0\"
|
||||
tokio = \"1.36\"
|
||||
serde = "1.0"
|
||||
tokio = "1.36"
|
||||
"""
|
||||
|
||||
|
||||
@@ -135,3 +135,103 @@ def sample_outdated_dependencies():
|
||||
def empty_scan_result():
|
||||
"""Create an empty scan result."""
|
||||
return ScanResult()
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_request():
|
||||
"""Create a sample recorded request."""
|
||||
from api_snapshot.recorder.recorder import RecordedRequest
|
||||
return RecordedRequest(
|
||||
method="GET",
|
||||
url="https://api.example.com/users",
|
||||
headers={"Accept": "application/json"},
|
||||
body=None,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_response():
|
||||
"""Create a sample recorded response."""
|
||||
from api_snapshot.recorder.recorder import RecordedResponse
|
||||
return RecordedResponse(
|
||||
status_code=200,
|
||||
headers={"Content-Type": "application/json"},
|
||||
body='{"success": true}',
|
||||
latency_ms=150,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_pair(sample_request, sample_response):
|
||||
"""Create a sample request-response pair."""
|
||||
from api_snapshot.recorder.recorder import RequestResponsePair
|
||||
return RequestResponsePair(
|
||||
request=sample_request,
|
||||
response=sample_response,
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_snapshot(sample_pair):
|
||||
"""Create a sample snapshot."""
|
||||
from api_snapshot.snapshot.manager import Snapshot, SnapshotMetadata
|
||||
meta = SnapshotMetadata(description="Test snapshot")
|
||||
return Snapshot(metadata=meta, requests=[sample_pair])
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_snapshot_dict():
|
||||
"""Create a sample snapshot dictionary."""
|
||||
return {
|
||||
"metadata": {
|
||||
"version": "1.0",
|
||||
"timestamp": "2024-01-01T00:00:00",
|
||||
"description": "Test snapshot",
|
||||
"source_url": "https://api.example.com",
|
||||
"latency_mode": "original",
|
||||
"custom_latency_ms": None,
|
||||
"tags": []
|
||||
},
|
||||
"requests": [
|
||||
{
|
||||
"request": {
|
||||
"method": "GET",
|
||||
"url": "https://api.example.com/users",
|
||||
"headers": {"Accept": "application/json"},
|
||||
"body": None,
|
||||
"timestamp": "2024-01-01T00:00:00"
|
||||
},
|
||||
"response": {
|
||||
"status_code": 200,
|
||||
"headers": {"Content-Type": "application/json"},
|
||||
"body": '{"success": true}',
|
||||
"latency_ms": 150
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def snapshot_manager(temp_dir):
|
||||
"""Create a snapshot manager with a test snapshot."""
|
||||
from api_snapshot.snapshot.manager import SnapshotManager
|
||||
manager = SnapshotManager(temp_dir)
|
||||
return manager
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def snapshot_file(temp_dir, sample_pair):
|
||||
"""Create a snapshot file for testing."""
|
||||
from api_snapshot.snapshot.manager import SnapshotManager
|
||||
import json
|
||||
|
||||
manager = SnapshotManager(temp_dir)
|
||||
manager.save_snapshot(
|
||||
name="test_snapshot",
|
||||
requests=[sample_pair, sample_pair],
|
||||
description="Test snapshot"
|
||||
)
|
||||
|
||||
path = manager._get_path("test_snapshot")
|
||||
return path
|
||||
|
||||
Reference in New Issue
Block a user