Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dev-tools/mcp-mock-server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import subprocess
import sys
import threading
from http.server import HTTPServer, BaseHTTPRequestHandler
from datetime import datetime, UTC
from datetime import UTC, datetime
from http.server import BaseHTTPRequestHandler, HTTPServer
from pathlib import Path
from typing import Any

Expand Down
2 changes: 1 addition & 1 deletion dev-tools/mcp-mock-server/test_mock_mcp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import subprocess
import sys
import time
import urllib.request
import urllib.error
import urllib.request
from typing import Any, Optional

import pytest
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ disable = ["R0801"]
extend-exclude = ["tests/profiles/syntax_error.py"]

[tool.ruff.lint]
extend-select = ["TID251", "UP006", "UP007", "UP010", "UP017", "UP035", "RUF100", "B009", "B010", "DTZ005", "D202"]
extend-select = ["TID251", "UP006", "UP007", "UP010", "UP017", "UP035", "RUF100", "B009", "B010", "DTZ005", "D202", "I001"]

[tool.ruff.lint.flake8-tidy-imports.banned-api]
unittest = { msg = "use pytest instead of unittest" }
Expand Down
3 changes: 1 addition & 2 deletions scripts/gen_doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@

"""Generate documentation for all modules from Lightspeed Core Stack service."""

import os

import ast
import os
from pathlib import Path

DIRECTORIES = ["src", "tests/unit", "tests/integration", "tests/e2e"]
Expand Down
4 changes: 2 additions & 2 deletions scripts/generate_openapi_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@

from fastapi.openapi.utils import get_openapi

from client import AsyncLlamaStackClientHolder

# it is needed to read proper configuration in order to start the app to generate schema
from configuration import configuration

from client import AsyncLlamaStackClientHolder

cfg_file = "lightspeed-stack.yaml"
configuration.load_configuration(cfg_file)

Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/conftest.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Fixtures used by benchmarks."""

from pathlib import Path
import pytest

import psycopg2
import pytest

from app import database
from configuration import configuration, AppConfig
from configuration import AppConfig, configuration


@pytest.fixture(name="configuration_filename_sqlite")
Expand Down
10 changes: 5 additions & 5 deletions tests/benchmarks/db_benchmarks.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
"""Database benchmarks implementations."""

from typing import Optional
from sqlalchemy.orm import Session
from datetime import UTC, datetime
from typing import Optional

from pytest_benchmark.fixture import BenchmarkFixture
from sqlalchemy.orm import Session

from app.database import get_session
from utils.suid import get_suid

from models.database.conversations import UserConversation
from utils.suid import get_suid

from .data_generators import (
generate_provider,
generate_model_for_provider,
generate_provider,
generate_topic_summary,
)

Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/test_app_database.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from pytest_benchmark.fixture import BenchmarkFixture

from .db_benchmarks import (
benchmark_store_new_user_conversations,
benchmark_update_user_conversation,
benchmark_list_conversations_for_all_users,
benchmark_list_conversations_for_one_user,
benchmark_retrieve_conversation,
benchmark_retrieve_conversation_for_one_user,
benchmark_store_new_user_conversations,
benchmark_update_user_conversation,
)

# number of records to be stored in database before benchmarks
Expand Down
4 changes: 2 additions & 2 deletions tests/benchmarks/test_app_database_comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
from pytest_benchmark.fixture import BenchmarkFixture

from .db_benchmarks import (
benchmark_store_new_user_conversations,
benchmark_update_user_conversation,
benchmark_list_conversations_for_all_users,
benchmark_list_conversations_for_one_user,
benchmark_retrieve_conversation,
benchmark_retrieve_conversation_for_one_user,
benchmark_store_new_user_conversations,
benchmark_update_user_conversation,
)

# number of records to be stored in database before benchmarks
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/features/environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

import requests
from behave.model import Feature, Scenario
from tests.e2e.utils.prow_utils import restore_llama_stack_pod
from behave.runner import Context

from tests.e2e.utils.llama_stack_utils import (
register_shield,
unregister_mcp_toolgroups,
unregister_shield,
)
from tests.e2e.utils.prow_utils import restore_llama_stack_pod
from tests.e2e.utils.utils import (
clear_llama_stack_storage,
create_config_backup,
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/features/steps/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import requests
from behave import given, when # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context

from tests.e2e.utils.utils import normalize_endpoint


Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/features/steps/common.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
"""Implementation of common test steps."""

import os

from behave import given # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context
import os


@given("The service is started locally")
Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/features/steps/common_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@

import requests
from behave import (
given,
step,
then,
when,
step,
given,
) # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context

from tests.e2e.utils.utils import (
normalize_endpoint,
replace_placeholders,
Expand Down
8 changes: 5 additions & 3 deletions tests/e2e/features/steps/conversation.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
"""Implementation of common test steps."""

import json

import requests
from behave import (
given,
step,
when,
then,
given,
when,
) # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context
import requests

from tests.e2e.utils.utils import replace_placeholders, restart_container, switch_config

# default timeout for HTTP operations
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/features/steps/health.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import subprocess
import time

from behave import given # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context

Expand Down
1 change: 1 addition & 0 deletions tests/e2e/features/steps/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import json
import re

from behave import then # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context

Expand Down
4 changes: 3 additions & 1 deletion tests/e2e/features/steps/llm_query_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import json
import os

import requests
from behave import then, step # pyright: ignore[reportAttributeAccessIssue]
from behave import step, then # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context

from tests.e2e.utils.utils import replace_placeholders

# Longer timeout for Prow/OpenShift with CPU-based vLLM
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/features/steps/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Steps for /models endpoint."""

import requests

from behave import when, then # pyright: ignore[reportAttributeAccessIssue]
from behave import then, when # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context


Expand Down
1 change: 1 addition & 0 deletions tests/e2e/features/steps/rbac.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""Step definitions for RBAC E2E tests."""

import os

import requests
from behave import given # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/features/steps/rlsapi_v1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""rlsapi v1 endpoint test steps."""

from behave import then, step # pyright: ignore[reportAttributeAccessIssue]
from behave import step, then # pyright: ignore[reportAttributeAccessIssue]
from behave.runner import Context


Expand Down
1 change: 0 additions & 1 deletion tests/e2e/features/steps/token_counters.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Step definitions for token counter validation."""

import json

from typing import Optional

import requests
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/mock_jwks_server/generate_tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
import json
import time

import jwt
from cryptography.hazmat.backends import default_backend
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import rsa
from cryptography.hazmat.backends import default_backend
import jwt

# Generate RSA key pair
private_key = rsa.generate_private_key(
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/mock_jwks_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"""

import json
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Any

# Static JWKS - pre-generated RSA public key
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/mock_mcp_server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""

import json
from http.server import HTTPServer, BaseHTTPRequestHandler
from http.server import BaseHTTPRequestHandler, HTTPServer
from typing import Any, Optional

# Standard OAuth-style challenge so the client can drive an OAuth flow
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/utils/llama_stack_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@

from llama_stack_client import (
APIConnectionError,
AsyncLlamaStackClient,
APIStatusError,
AsyncLlamaStackClient,
)


Expand Down
1 change: 0 additions & 1 deletion tests/e2e/utils/prow_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import os
import subprocess
import tempfile

from typing import Optional


Expand Down
11 changes: 4 additions & 7 deletions tests/integration/conftest.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,26 @@
"""Shared fixtures for integration tests."""

import os
from pathlib import Path
from collections.abc import Generator
from pathlib import Path
from typing import Any

import pytest
from fastapi import Request, Response
from fastapi.testclient import TestClient
from pytest_mock import MockerFixture

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker, Session
from sqlalchemy.engine import Engine
from sqlalchemy.orm import Session, sessionmaker
from sqlalchemy.pool import StaticPool

from authentication.noop import NoopAuthDependency
import app.database
from authentication.interface import AuthTuple

from authentication.noop import NoopAuthDependency
from configuration import configuration
from models.config import Action
from models.database.base import Base

import app.database

# ==========================================
# Common Test Constants
# ==========================================
Expand Down
5 changes: 2 additions & 3 deletions tests/integration/endpoints/test_authorized_endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

import pytest

from app.endpoints.authorized import authorized_endpoint_handler
from authentication.interface import AuthTuple

from configuration import AppConfig
from app.endpoints.authorized import authorized_endpoint_handler
from constants import DEFAULT_USER_UID, DEFAULT_USER_NAME, DEFAULT_SKIP_USER_ID_CHECK
from constants import DEFAULT_SKIP_USER_ID_CHECK, DEFAULT_USER_NAME, DEFAULT_USER_UID


@pytest.mark.asyncio
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/endpoints/test_config_integration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Integration tests for the /config endpoint."""

from typing import cast
import pytest

import pytest
from fastapi import HTTPException, Request, status

from app.endpoints.config import config_endpoint_handler
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/endpoints/test_health_integration.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Integration tests for the /health endpoint."""

from typing import Any
from collections.abc import Generator
from typing import Any

import pytest
from fastapi import Response
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/endpoints/test_info_integration.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""Integration tests for the /info endpoint."""

from typing import Any
from collections.abc import Generator
import pytest
from pytest_mock import MockerFixture, AsyncMockType
from typing import Any

import pytest
from fastapi import HTTPException, Request, status
from llama_stack_client import APIConnectionError
from llama_stack_client.types import VersionInfo
from authentication.interface import AuthTuple
from pytest_mock import AsyncMockType, MockerFixture

from configuration import AppConfig
from app.endpoints.info import info_endpoint_handler
from authentication.interface import AuthTuple
from configuration import AppConfig
from version import __version__


Expand Down
Loading
Loading