mirror of
https://github.com/msoedov/agentic_security.git
synced 2026-06-24 14:19:55 +02:00
fix(tests):
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
from inline_snapshot import snapshot
|
||||
import signal
|
||||
import subprocess
|
||||
import time
|
||||
|
||||
import pytest
|
||||
from agentic_security.lib import AgenticSecurity
|
||||
|
||||
SAMPLE_SPEC = """
|
||||
POST http://0.0.0.0:8718/v1/self-probe
|
||||
POST http://0.0.0.0:9094/v1/self-probe
|
||||
Authorization: Bearer XXXXX
|
||||
Content-Type: application/json
|
||||
|
||||
@@ -13,6 +16,25 @@ Content-Type: application/json
|
||||
"""
|
||||
|
||||
|
||||
@pytest.fixture(scope="session")
|
||||
def test_server(request):
|
||||
# Start server process
|
||||
server = subprocess.Popen(
|
||||
["uvicorn", "agentic_security.app:app", "--host", "0.0.0.0", "--port", "9094"],
|
||||
preexec_fn=lambda: signal.signal(signal.SIGINT, signal.SIG_IGN),
|
||||
)
|
||||
|
||||
# Give the server time to start
|
||||
time.sleep(2)
|
||||
|
||||
def cleanup():
|
||||
server.terminate()
|
||||
server.wait()
|
||||
|
||||
request.addfinalizer(cleanup)
|
||||
return server
|
||||
|
||||
|
||||
def make_test_registry():
|
||||
return [
|
||||
{
|
||||
@@ -30,7 +52,7 @@ def make_test_registry():
|
||||
|
||||
class TestAS:
|
||||
# Handles an empty dataset list.
|
||||
def test_class(self):
|
||||
def test_class(self, test_server):
|
||||
llmSpec = SAMPLE_SPEC
|
||||
maxBudget = 1000000
|
||||
max_th = 0.3
|
||||
@@ -41,7 +63,7 @@ class TestAS:
|
||||
assert len(result) in [0, 1]
|
||||
|
||||
# TODO: slow test
|
||||
def test_class_msj(self):
|
||||
def test_class_msj(self, test_server):
|
||||
llmSpec = SAMPLE_SPEC
|
||||
maxBudget = 1000
|
||||
max_th = 0.3
|
||||
|
||||
Generated
+19
-1
@@ -2317,6 +2317,24 @@ pluggy = ">=1.5,<2"
|
||||
[package.extras]
|
||||
dev = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygments (>=2.7.2)", "requests", "setuptools", "xmlschema"]
|
||||
|
||||
[[package]]
|
||||
name = "pytest-asyncio"
|
||||
version = "0.24.0"
|
||||
description = "Pytest support for asyncio"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "pytest_asyncio-0.24.0-py3-none-any.whl", hash = "sha256:a811296ed596b69bf0b6f3dc40f83bcaf341b155a269052d82efa2b25ac7037b"},
|
||||
{file = "pytest_asyncio-0.24.0.tar.gz", hash = "sha256:d081d828e576d85f875399194281e92bf8a68d60d72d1a2faf2feddb6c46b276"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
pytest = ">=8.2,<9"
|
||||
|
||||
[package.extras]
|
||||
docs = ["sphinx (>=5.3)", "sphinx-rtd-theme (>=1.0)"]
|
||||
testing = ["coverage (>=6.2)", "hypothesis (>=5.7.1)"]
|
||||
|
||||
[[package]]
|
||||
name = "python-dateutil"
|
||||
version = "2.9.0.post0"
|
||||
@@ -2982,4 +3000,4 @@ propcache = ">=0.2.0"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = "^3.11"
|
||||
content-hash = "f7e949c4b106ba9e1c5b2b99611f8fcc24c49b5a771d1f2bebb7471939a351c5"
|
||||
content-hash = "cca5e82dfe7ac40a91da508832d071ecccd355146d94bd4d0eb7a1eb0c4d52dc"
|
||||
|
||||
+2
-1
@@ -44,11 +44,12 @@ numpy = ">=1.24.3,<3.0.0"
|
||||
jinja2 = "^3.1.4"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
pytest-asyncio = "^0.24.0"
|
||||
inline-snapshot = "^0.13.3"
|
||||
black = "^24.10.0"
|
||||
mypy = "^1.12.0"
|
||||
pytest = "^8.3.4"
|
||||
pre-commit = "^4.0.1"
|
||||
inline-snapshot = "^0.13.3"
|
||||
langchain-groq = "^0.2.0"
|
||||
huggingface-hub = "^0.25.1"
|
||||
# garak = "*"
|
||||
|
||||
Reference in New Issue
Block a user