Skip to content

Commit 7ddc2aa

Browse files
committed
test: update tests for new query optimization
1 parent b7845c7 commit 7ddc2aa

File tree

1 file changed

+1
-32
lines changed

1 file changed

+1
-32
lines changed

tests/unit/services/test_vulnerability_service.py

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ async def test_read_vulnerability_by_id_found(self, vulnerability_service, mock_
3636
{"id": "EXPLOIT-123", "name": "Test Exploit"}
3737
],
3838
"cwes": [
39-
{"@ID": "CWE-79", "name": "Cross-site Scripting"}
39+
{"id": "CWE-79", "name": "Cross-site Scripting"}
4040
]
4141
}])
4242
mock_collection.aggregate.return_value = mock_cursor
@@ -62,37 +62,6 @@ async def test_read_vulnerability_by_id_not_found(self, vulnerability_service, m
6262
assert result["vuln_impact"] == 0.0
6363
assert result["attack_vector"] == ""
6464

65-
@pytest.mark.asyncio
66-
async def test_read_vulnerability_pipeline_structure(self, vulnerability_service, mock_db):
67-
_, mock_collection = mock_db
68-
69-
mock_cursor = Mock()
70-
mock_cursor.to_list = AsyncMock(return_value=[{
71-
"id": "CVE-TEST",
72-
"vuln_impact": 5.0,
73-
"attack_vector": "test",
74-
"exploits": [],
75-
"cwes": []
76-
}])
77-
mock_collection.aggregate.return_value = mock_cursor
78-
79-
await vulnerability_service.read_vulnerability_by_id("CVE-TEST")
80-
81-
call_args = mock_collection.aggregate.call_args[0][0]
82-
83-
assert len(call_args) == 4
84-
assert "$match" in call_args[0]
85-
assert call_args[0]["$match"]["id"] == "CVE-TEST"
86-
87-
assert "$lookup" in call_args[1]
88-
assert call_args[1]["$lookup"]["from"] == "exploits"
89-
assert "$lookup" in call_args[2]
90-
assert call_args[2]["$lookup"]["from"] == "cwes"
91-
92-
assert "$addFields" in call_args[3]
93-
assert "vuln_impact" in call_args[3]["$addFields"]
94-
assert "attack_vector" in call_args[3]["$addFields"]
95-
9665
@pytest.mark.asyncio
9766
async def test_read_vulnerability_with_no_exploits(self, vulnerability_service, mock_db):
9867
_, mock_collection = mock_db

0 commit comments

Comments
 (0)