repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
taskiq-python/taskiq | from concurrent.futures import ThreadPoolExecutor
from typing import Any
import pytest
from pydantic import ValidationError
from taskiq import (
AsyncTaskiqDecoratedTask,
InMemoryBroker,
TaskiqDepends,
TaskiqMessage,
)
from taskiq.abc import AsyncBroker
from taskiq.depends.progress_tracker import Prog... | None | assert | none_literal | tests/depends/test_progress_tracker.py | test_progress_tracker_ctx_raw | 79 | null | |
taskiq-python/taskiq | import asyncio
import contextlib
import pytest
from taskiq.api import run_receiver_task
from tests.utils import AsyncQueueBroker
async def test_cancelation() -> None:
broker = AsyncQueueBroker()
kicked = 0
@broker.task
def test_func() -> None:
nonlocal kicked
kicked += 1
receive... | 1 | assert | numeric_literal | tests/api/test_receiver_task.py | test_cancelation | 43 | null | |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_result_raise_for_error_res() -> None:
res: TaskiqResult[str] = TaskiqResult(
is_err=False,
return_value="Some value",
execution_time=0,
error=None,
)
... | "Some value" | assert | string_literal | tests/test_result.py | test_result_raise_for_error_res | 95 | null | |
taskiq-python/taskiq | from datetime import datetime, timedelta
import pytest
from taskiq.cli.scheduler.run import is_interval_task_now
@pytest.mark.parametrize(
"interval_value,now,last_run,expected",
[
(
timedelta(seconds=10),
datetime(2023, 1, 1, 0, 0, 15),
datetime(2023, 1, 1, 0, 0, ... | expected | assert | variable | tests/cli/scheduler/test_is_interval_task_now.py | test_is_interval_task_now | 34 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | None) | self.assertEqual | none_literal | tests/opentelemetry/test_helpers.py | test_span_delete | TestUtils | 96 | null |
taskiq-python/taskiq | import asyncio
import contextlib
import pytest
from taskiq.api import run_receiver_task
from tests.utils import AsyncQueueBroker
async def test_successful() -> None:
broker = AsyncQueueBroker()
kicked = 0
desired_kicked = 3
@broker.task
def test_func() -> None:
nonlocal kicked
ki... | desired_kicked | assert | variable | tests/api/test_receiver_task.py | test_successful | 27 | null | |
taskiq-python/taskiq | import json
from taskiq.formatters.json_formatter import JSONFormatter
from taskiq.message import BrokerMessage, TaskiqMessage
async def test_json_dumps() -> None:
fmt = JSONFormatter()
msg = TaskiqMessage(
task_id="task-id",
task_name="task.name",
labels={"label1": 1, "label2": "text"... | expected.task_name | assert | complex_expr | tests/formatters/test_json_formatter.py | test_json_dumps | 29 | null | |
taskiq-python/taskiq | import logging
import sys
from io import StringIO
from taskiq.cli.worker.log_collector import log_collector
def test_log_collector_logging_success() -> None:
"""Tests that logging calls are collected correctly."""
log = StringIO()
with log_collector(log, "%(levelname)s %(message)s"):
logger = logg... | "INFO log1\nWARNING log2\nDEBUG log3\n" | assert | string_literal | tests/cli/worker/test_log_collector.py | test_log_collector_logging_success | 26 | null | |
taskiq-python/taskiq | from typing import Any
from unittest.mock import AsyncMock
import pytest
from taskiq.exceptions import ResultIsReadyError, TaskiqResultTimeoutError
from taskiq.funcs import gather
from taskiq.task import AsyncTaskiqTask
async def test_gather_result_backend_error() -> None:
"""Test how gather works if result back... | ResultIsReadyError) | pytest.raises | variable | tests/test_funcs.py | test_gather_result_backend_error | 43 | null | |
taskiq-python/taskiq | import unittest
from unittest import mock
from opentelemetry import trace as trace_api
from opentelemetry.sdk import trace
from taskiq import TaskiqMessage
from taskiq.middlewares import opentelemetry_middleware
from .taskiq_test_tasks import broker
class TestUtils(unittest.TestCase):
def setUp(self) -> None:
... | mock_span.is_recording()) | self.assertFalse | func_call | tests/opentelemetry/test_helpers.py | test_set_attributes_not_recording | TestUtils | 57 | null |
taskiq-python/taskiq | import json
from taskiq.formatters.json_formatter import JSONFormatter
from taskiq.message import BrokerMessage, TaskiqMessage
async def test_json_dumps() -> None:
fmt = JSONFormatter()
msg = TaskiqMessage(
task_id="task-id",
task_name="task.name",
labels={"label1": 1, "label2": "text"... | expected.task_id | assert | complex_expr | tests/formatters/test_json_formatter.py | test_json_dumps | 28 | null | |
taskiq-python/taskiq | import inspect
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def _helper(f: Callable[..., Any], m... | ["f3", 2] | assert | collection | tests/receiver/test_params_parser.py | test_primitive_args_failure | 95 | null | |
taskiq-python/taskiq | import asyncio
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import SpanKind, StatusCode
from taskiq import InMemoryBroker
from taskiq.instrumentation import TaskiqInstrumentor
class TestTaskiqAutoInstrumentation(TestBase):
def test_auto_instrument(self) -> None:
TaskiqInstru... | producer.context) | self.assertNotEqual | complex_expr | tests/opentelemetry/test_auto_instrumentation.py | test_auto_instrument | TestTaskiqAutoInstrumentation | 62 | null |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | producer.context) | self.assertNotEqual | complex_expr | tests/opentelemetry/test_tasks.py | test_task | TestTaskiqInstrumentation | 75 | null |
taskiq-python/taskiq | import asyncio
import time
from taskiq import TaskiqScheduler
from taskiq.api import run_scheduler_task
from taskiq.schedule_sources import LabelScheduleSource
from tests.utils import AsyncQueueBroker
async def test_interval_task_performance() -> None:
broker = AsyncQueueBroker()
scheduler = TaskiqScheduler(b... | None | assert | none_literal | tests/scheduler/test_interval_performance.py | test_interval_task_performance | 27 | null | |
taskiq-python/taskiq | import uuid
from unittest.mock import AsyncMock
import pytest
from taskiq.formatters.json_formatter import JSONFormatter
from taskiq.message import TaskiqMessage
from taskiq.middlewares.simple_retry_middleware import SimpleRetryMiddleware
from taskiq.result import TaskiqResult
def broker() -> AsyncMock:
mocked_b... | "1" | assert | string_literal | tests/middlewares/test_simple_retry.py | test_successful_retry | 38 | null | |
taskiq-python/taskiq | from taskiq.scheduler.merge_functions import only_unique, preserve_all
def test_preserve_all() -> None:
first = [1, 2, 3]
second = [3, 4, 5]
assert preserve_all(first, second) == | [1, 2, 3, 3, 4, 5] | assert | collection | tests/scheduler/test_merge_funcs.py | test_preserve_all | 7 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | None | assert | none_literal | tests/test_serialization.py | test_exception_to_python_when_none | 214 | null | |
taskiq-python/taskiq | import asyncio
import pytest
from taskiq import InMemoryBroker, SimpleRetryMiddleware, SmartRetryMiddleware
from taskiq.exceptions import NoResultError
async def test_wait_result_no_result() -> None:
"""Tests wait_result."""
broker = InMemoryBroker().with_middlewares(
SimpleRetryMiddleware(no_result_... | KeyError) | pytest.raises | variable | tests/middlewares/test_task_retry.py | test_wait_result_no_result | 96 | null | |
taskiq-python/taskiq | from contextlib import suppress
from pathlib import Path
from unittest.mock import patch
from taskiq.cli.utils import import_tasks
def test_import_tasks_list_pattern() -> None:
modules = ["taskiq.tasks"]
with patch("taskiq.cli.utils.import_from_modules", autospec=True) as mock:
import_tasks(modules, [... | modules) | assert_* | variable | tests/cli/test_utils.py | test_import_tasks_list_pattern | 17 | null | |
taskiq-python/taskiq | import asyncio
import pytest
from taskiq import InMemoryBroker, SimpleRetryMiddleware, SmartRetryMiddleware
from taskiq.exceptions import NoResultError
async def test_wait_result() -> None:
"""Tests wait_result."""
broker = InMemoryBroker().with_middlewares(
SimpleRetryMiddleware(no_result_on_retry=T... | "hello world!" | assert | string_literal | tests/middlewares/test_task_retry.py | test_wait_result | 30 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_dumpb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.dumpb(None) == b"null"
assert serizalizer.dumpb(1) == b"1"
assert serizalizer.dumpb("a") == | b'"a"' | assert | string_literal | tests/serializers/test_json_serializer.py | test_json_dumpb | 10 | null | |
taskiq-python/taskiq | from collections.abc import AsyncGenerator
from taskiq.abc.broker import AsyncBroker
from taskiq.decor import AsyncTaskiqDecoratedTask
from taskiq.message import BrokerMessage
def test_decorator_with_labels_success() -> None:
"""Tests that labels are assigned for task as is."""
tbrok = _TestBroker()
@tbr... | { "label1": 1, "label2": 2, } | assert | collection | tests/abc/test_broker.py | test_decorator_with_labels_success | 60 | null | |
taskiq-python/taskiq | import asyncio
from opentelemetry.test.test_base import TestBase
from opentelemetry.trace import SpanKind, StatusCode
from taskiq import InMemoryBroker
from taskiq.instrumentation import TaskiqInstrumentor
class TestTaskiqAutoInstrumentation(TestBase):
def test_auto_instrument(self) -> None:
TaskiqInstru... | 2) | self.assertEqual | numeric_literal | tests/opentelemetry/test_auto_instrumentation.py | test_auto_instrument | TestTaskiqAutoInstrumentation | 27 | null |
taskiq-python/taskiq | import inspect
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def _helper(f: Callable[..., Any], m... | [1] | assert | collection | tests/receiver/test_params_parser.py | test_kwargs_primitives_success | 157 | null | |
taskiq-python/taskiq | import json
import pickle
import re
import traceback
from typing import Any
import pytest
from pydantic import ValidationError
import taskiq
from taskiq import serialization
from taskiq.exceptions import SecurityError
from taskiq.serialization import (
ExceptionRepr,
_UnpickleableExceptionWrapper,
excepti... | actual | assert | variable | tests/test_serialization.py | test_json_py3 | 97 | null | |
taskiq-python/taskiq | import asyncio
from collections.abc import Callable
from contextlib import AbstractContextManager
from typing import Any
from opentelemetry import baggage, context
from opentelemetry.instrumentation.utils import unwrap
from opentelemetry.semconv.trace import SpanAttributes
from opentelemetry.test.test_base import Test... | StatusCode.ERROR) | self.assertEqual | complex_expr | tests/opentelemetry/test_tasks.py | test_task_raises | TestTaskiqInstrumentation | 106 | null |
taskiq-python/taskiq | import asyncio
import contextvars
import random
import time
from collections.abc import Generator
from concurrent.futures import ThreadPoolExecutor
from functools import wraps
from typing import Any, ClassVar
import pytest
from taskiq_dependencies import Depends
from taskiq.abc.broker import AckableMessage, AsyncBrok... | expected | assert | variable | tests/receiver/test_receiver.py | test_callback_no_dep_info | 247 | null | |
taskiq-python/taskiq | import json
import pickle
import pytest
from taskiq import TaskiqResult
from taskiq.compat import model_dump_json
def test_json_error_serialization() -> None:
try:
raise ValueError("Omg", [1, 2, 3])
except Exception as exc:
error = exc
task: TaskiqResult[int] = TaskiqResult(
is_e... | 2 | assert | numeric_literal | tests/test_result.py | test_json_error_serialization | 44 | null | |
taskiq-python/taskiq | import pytest
from polyfactory.factories import BaseFactory, DataclassFactory, TypedDictFactory
from polyfactory.factories.pydantic_factory import ModelFactory
from taskiq.brokers.inmemory_broker import InMemoryBroker
from tests.middlewares.admin_middleware.dto import (
DataclassDTO,
PydanticDTO,
TypedDict... | None | assert | none_literal | tests/middlewares/admin_middleware/test_arguments_formatting.py | test_when_task_dto_passed__then_middleware_successfully_send_request | TestArgumentsFormattingInAdminMiddleware | 44 | null |
taskiq-python/taskiq | import inspect
import logging
from collections.abc import Callable
from dataclasses import dataclass
from typing import Any, get_type_hints
import pytest
from pydantic import BaseModel
from taskiq.message import TaskiqMessage
from taskiq.receiver.params_parser import parse_params
def _helper(f: Callable[..., Any], m... | caplog.text | assert | complex_expr | tests/receiver/test_params_parser.py | test_primitive_args_failure | 94 | null | |
taskiq-python/taskiq | import asyncio
import uuid
import pytest
from taskiq import InMemoryBroker
from taskiq.events import TaskiqEvents
from taskiq.state import TaskiqState
async def test_startup() -> None:
broker = InMemoryBroker()
test_value = uuid.uuid4().hex
@broker.on_event(TaskiqEvents.WORKER_STARTUP)
async def _w_... | test_value | assert | variable | tests/brokers/test_inmemory.py | test_startup | 47 | null | |
taskiq-python/taskiq | import pytest
from taskiq.serializers.json_serializer import JSONSerializer
def test_json_loadb() -> None:
serizalizer = JSONSerializer()
assert serizalizer.loadb(b"null") is None
assert serizalizer.loadb(b"1") == 1
assert serizalizer.loadb(b'"a"') == "a"
assert serizalizer.loadb(b'["a"]') == | ["a"] | assert | collection | tests/serializers/test_json_serializer.py | test_json_loadb | 20 | null | |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import AsyncMock, patch
import langsmith
import pytest
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from langgraph.pregel.types import StateSnapshot
from langgraph.types import Interrupt
from agents.agents import Agent
from schema import ChatHistory, ChatM... | 200 | assert | numeric_literal | tests/service/test_service.py | test_invoke | 21 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
from voice.providers.openai_stt import OpenAISTT
def test_transcribe_api_error(mock_openai_client, mock_audio_file):
"""Test that API errors are handled gracefully."""
# Make the mock raise an exception
mock_openai_client.audio.transcriptions.create.side_effect = Exception(... | "" | assert | string_literal | tests/voice/providers/test_openai_stt.py | test_transcribe_api_error | 55 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.github_mcp_agent.github_mcp_agent import GitHubMCPAgent, prompt
from core.settings import settings
class TestGitHubMCPAgent:
@pytest.mark.asyncio
async def test_load_with_github_pat(self):
"""Test load when GITHUB_PAT is set ... | mock_client | assert | variable | tests/agents/test_github_mcp_agent.py | test_load_with_github_pat | TestGitHubMCPAgent | 66 | null |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import patch
import pytest
from langchain_core.language_models import FakeMessagesListChatModel
from langchain_core.messages import AIMessage, BaseMessage, ToolCall
from langgraph.checkpoint.memory import MemorySaver
from schema import ChatMessage, StreamInput
@pytest.mark.asyncio
asyn... | "5.0" | assert | string_literal | tests/service/test_service_message_generator.py | test_three_layer_supervisor_hierarchy_agent_with_fake_model | 68 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | "0.0.0.0" | assert | string_literal | tests/core/test_settings.py | test_settings_default_values | 32 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import Mock, patch
from voice.manager import VoiceManager
def test_init_with_both_stt_and_tts():
"""Test creating VoiceManager with both STT and TTS."""
mock_stt = Mock()
mock_tts = Mock()
manager = VoiceManager(stt=mock_stt, tts=mock_tts)
# Passes if both STT and TTS are assign... | mock_tts | assert | variable | tests/voice/test_manager.py | test_init_with_both_stt_and_tts | 15 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
import pytest
from voice.providers.openai_tts import OpenAITTS
def test_generate_success(mock_openai_client):
"""Test successful audio generation."""
with patch("voice.providers.openai_tts.OpenAI", return_value=mock_openai_client):
tts = OpenAITTS(api_key="test-key")
... | b"fake audio data" | assert | string_literal | tests/voice/providers/test_openai_tts.py | test_generate_success | 58 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
from voice.providers.openai_stt import OpenAISTT
def test_init_with_api_key(mock_openai_client):
"""Test creating OpenAISTT with API key."""
with patch("voice.providers.openai_stt.OpenAI", return_value=mock_openai_client):
stt = OpenAISTT(api_key="test-key")
# P... | mock_openai_client | assert | variable | tests/voice/providers/test_openai_stt.py | test_init_with_api_key | 13 | null | |
JoshuaC215/agent-service-toolkit | import pytest
from streamlit.testing.v1 import AppTest
from client import AgentClient
@pytest.mark.docker
def test_service_with_app():
"""Test the service using the app.
This test requires the service container to be running with USE_FAKE_MODEL=true
"""
at = AppTest.from_file("../../src/streamlit_app... | "user" | assert | string_literal | tests/integration/test_docker_e2e.py | test_service_with_app | 33 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | "test_key" | assert | string_literal | tests/core/test_settings.py | test_settings_with_azure_openai_key | 113 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | True | assert | bool_literal | tests/core/test_settings.py | test_settings_is_dev | 96 | null | |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from voice.tts import TextToSpeech
def test_from_env_provider_not_set():
"""Test from_env returns None when VOICE_TTS_PROVIDER is not set."""
with patch.dict(os.environ, {}, clear=True):
result = TextToSpeech.from_env()
# Passes if None ... | None | assert | none_literal | tests/voice/test_tts.py | test_from_env_provider_not_set | 38 | null | |
JoshuaC215/agent-service-toolkit | import pytest
from langchain_core.messages import AIMessage
from pydantic_core import ValidationError
from service.service import _create_ai_message
def test_create_ai_message_missing_required_content_raises():
"""
AIMessage requires 'content'; if missing, _create_ai_message should
raise a pydantic Valida... | ValidationError) | pytest.raises | variable | tests/service/test_service_streaming.py | test_create_ai_message_missing_required_content_raises | 55 | null | |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from voice.stt import SpeechToText
def test_init_with_invalid_provider():
"""Test that invalid provider raises ValueError."""
# Passes if ValueError is raised with expected message
with pytest.raises( | ValueError, match="Unknown STT provider: invalid") | pytest.raises | complex_expr | tests/voice/test_stt.py | test_init_with_invalid_provider | 22 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import Mock, patch
from voice.manager import VoiceManager
def test_init_with_both_stt_and_tts():
"""Test creating VoiceManager with both STT and TTS."""
mock_stt = Mock()
mock_tts = Mock()
manager = VoiceManager(stt=mock_stt, tts=mock_tts)
# Passes if both STT and TTS are assign... | mock_stt | assert | variable | tests/voice/test_manager.py | test_init_with_both_stt_and_tts | 14 | null | |
JoshuaC215/agent-service-toolkit | from collections.abc import AsyncGenerator
from unittest.mock import AsyncMock, Mock
import pytest
from streamlit.testing.v1 import AppTest
from client import AgentClientError
from schema import ChatHistory, ChatMessage
from schema.models import OpenAIModelName
def test_app_simple_non_streaming(mock_agent_client):
... | "user" | assert | string_literal | tests/app/test_streamlit_app.py | test_app_simple_non_streaming | 30 | null | |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from voice.stt import SpeechToText
def test_init_with_openai_provider(mock_openai_client):
"""Test creating STT with openai provider and explicit API key."""
with patch("voice.providers.openai_stt.OpenAI", return_value=mock_openai_client):
stt =... | "openai" | assert | string_literal | tests/voice/test_stt.py | test_init_with_openai_provider | 16 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
import pytest
from langchain_core.messages import AIMessage, ToolCall, ToolMessage
from langgraph.checkpoint.memory import MemorySaver
from langgraph.graph import END, MessagesState, StateGraph
from langgraph.types import StreamWriter
from agents.agents import Agent
from agents.utils i... | 5 | assert | numeric_literal | tests/service/test_service_e2e.py | test_messages_conversion | 45 | null | |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import patch
import pytest
from langchain_core.language_models import FakeMessagesListChatModel
from langchain_core.messages import AIMessage, BaseMessage, ToolCall
from langgraph.checkpoint.memory import MemorySaver
from schema import ChatMessage, StreamInput
@pytest.mark.asyncio
asyn... | "add" | assert | string_literal | tests/service/test_service_message_generator.py | test_three_layer_supervisor_hierarchy_agent_with_fake_model | 67 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import Mock, patch
from voice.manager import VoiceManager
def test_init_with_only_tts():
"""Test creating VoiceManager with only TTS (STT=None)."""
mock_tts = Mock()
manager = VoiceManager(stt=None, tts=mock_tts)
# Passes if partial voice features work (TTS only)
assert manager... | None | assert | none_literal | tests/voice/test_manager.py | test_init_with_only_tts | 23 | null | |
JoshuaC215/agent-service-toolkit | import json
import os
from unittest.mock import AsyncMock, Mock, patch
import pytest
from httpx import Request, Response
from client import AgentClient, AgentClientError
from schema import AgentInfo, ChatHistory, ChatMessage, ServiceMetadata
from schema.models import OpenAIModelName
@pytest.mark.asyncio
async def te... | SCORE | assert | variable | tests/client/test_client.py | test_acreate_feedback | 255 | null | |
JoshuaC215/agent-service-toolkit | import logging
from contextlib import asynccontextmanager
import pytest
from fastapi import FastAPI
from schema import AgentInfo
@pytest.mark.asyncio
async def test_lifespan(monkeypatch, caplog) -> None:
"""Test that the lifespan sets up the database and store, loads the agents, and logs errors."""
from serv... | fake_saver | assert | variable | tests/service/test_service_lifespan.py | test_lifespan | 71 | null | |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from langchain_anthropic import ChatAnthropic
from langchain_community.chat_models import FakeListChatModel
from langchain_groq import ChatGroq
from langchain_ollama import ChatOllama
from langchain_openai import ChatOpenAI
from core.llm import get_model
from sc... | ValueError, match="Unsupported model:") | pytest.raises | complex_expr | tests/core/test_llm.py | test_get_model_invalid | 69 | null | |
JoshuaC215/agent-service-toolkit | import pytest
from streamlit.testing.v1 import AppTest
from client import AgentClient
@pytest.mark.docker
def test_service_with_fake_model():
"""Test the service using the fake model.
This test requires the service container to be running with USE_FAKE_MODEL=true
"""
client = AgentClient("http://0.0.... | "ai" | assert | string_literal | tests/integration/test_docker_e2e.py | test_service_with_fake_model | 15 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | "test-key" | assert | string_literal | tests/core/test_settings.py | test_settings_azure_openai | 201 | null | |
JoshuaC215/agent-service-toolkit | import json
import os
from unittest.mock import AsyncMock, Mock, patch
import pytest
from httpx import Request, Response
from client import AgentClient, AgentClientError
from schema import AgentInfo, ChatHistory, ChatMessage, ServiceMetadata
from schema.models import OpenAIModelName
def test_init(mock_env):
"""T... | None | assert | none_literal | tests/client/test_client.py | test_init | 18 | null | |
JoshuaC215/agent-service-toolkit | from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolCall, ToolMessage
from service.utils import langchain_to_chat_message
def test_messages_from_langchain() -> None:
lc_human_message = HumanMessage(content="Hello, world!")
human_message = langchain_to_chat_message(lc_human_message)... | "Hello, world!" | assert | string_literal | tests/service/test_utils.py | test_messages_from_langchain | 10 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
from voice.providers.openai_stt import OpenAISTT
def test_transcribe_seeks_file_to_beginning(mock_openai_client, mock_audio_file):
"""Test that transcribe seeks file to beginning before reading."""
# Move file pointer to simulate already-read file
mock_audio_file.seek(100)
... | 0 | assert | numeric_literal | tests/voice/providers/test_openai_stt.py | test_transcribe_seeks_file_to_beginning | 33 | null | |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import patch
import pytest
from langchain_core.language_models import FakeMessagesListChatModel
from langchain_core.messages import AIMessage, BaseMessage, ToolCall
from langgraph.checkpoint.memory import MemorySaver
from schema import ChatMessage, StreamInput
@pytest.mark.asyncio
asyn... | "2+3 is 5" | assert | string_literal | tests/service/test_service_message_generator.py | test_three_layer_supervisor_hierarchy_agent_with_fake_model | 69 | null | |
JoshuaC215/agent-service-toolkit | from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolCall, ToolMessage
from service.utils import langchain_to_chat_message
def test_message_run_id_usage() -> None:
run_id = "847c6285-8fc9-4560-a83f-4e6285809254"
lc_message = AIMessage(content="Hello, world!")
ai_message = langch... | run_id | assert | variable | tests/service/test_utils.py | test_message_run_id_usage | 35 | null | |
JoshuaC215/agent-service-toolkit | import json
import os
from unittest.mock import AsyncMock, Mock, patch
import pytest
from httpx import Request, Response
from client import AgentClient, AgentClientError
from schema import AgentInfo, ChatHistory, ChatMessage, ServiceMetadata
from schema.models import OpenAIModelName
def test_headers(mock_env):
"... | {} | assert | collection | tests/client/test_client.py | test_headers | 36 | null | |
JoshuaC215/agent-service-toolkit | from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolCall, ToolMessage
from service.utils import langchain_to_chat_message
def test_messages_tool_calls() -> None:
tool_call = ToolCall(name="test_tool", args={"x": 1, "y": 2}, id="call_Jja7")
lc_ai_message = AIMessage(content="", tool... | {"x": 1, "y": 2} | assert | collection | tests/service/test_utils.py | test_messages_tool_calls | 44 | null | |
JoshuaC215/agent-service-toolkit | import json
import os
from unittest.mock import AsyncMock, Mock, patch
import pytest
from httpx import Request, Response
from client import AgentClient, AgentClientError
from schema import AgentInfo, ChatHistory, ChatMessage, ServiceMetadata
from schema.models import OpenAIModelName
def test_get_history(agent_client... | 2 | assert | numeric_literal | tests/client/test_client.py | test_get_history | 283 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | logging.DEBUG | assert | complex_expr | tests/core/test_settings.py | test_log_level_enum | 208 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.github_mcp_agent.github_mcp_agent import GitHubMCPAgent, prompt
from core.settings import settings
class TestGitHubMCPAgent:
def test_get_graph_loaded(self):
"""Test get_graph when agent is loaded."""
agent = GitHubMCPAge... | agent._graph | assert | complex_expr | tests/agents/test_github_mcp_agent.py | test_get_graph_loaded | TestGitHubMCPAgent | 132 | null |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from voice.tts import TextToSpeech
def test_init_with_openai_provider(mock_openai_client):
"""Test creating TTS with openai provider and explicit API key."""
with patch("voice.providers.openai_tts.OpenAI", return_value=mock_openai_client):
tts =... | "openai" | assert | string_literal | tests/voice/test_tts.py | test_init_with_openai_provider | 16 | null | |
JoshuaC215/agent-service-toolkit | from collections.abc import AsyncGenerator
from unittest.mock import AsyncMock, Mock
import pytest
from streamlit.testing.v1 import AppTest
from client import AgentClientError
from schema import ChatHistory, ChatMessage
from schema.models import OpenAIModelName
def test_app_simple_non_streaming(mock_agent_client):
... | RESPONSE | assert | variable | tests/app/test_streamlit_app.py | test_app_simple_non_streaming | 33 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import Mock
import pytest
from agents.lazy_agent import LazyLoadingAgent
class TestLazyLoadingAgentBase:
def test_get_graph_before_load(self):
"""Test that get_graph raises error before load."""
agent = TestLazyLoadingAgent()
with pytest.raises( | RuntimeError, match="Agent not loaded") | pytest.raises | complex_expr | tests/agents/test_lazy_agent.py | test_get_graph_before_load | TestLazyLoadingAgentBase | 46 | null |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
import pytest
from voice.providers.openai_tts import OpenAITTS
def test_validate_text_too_short(mock_openai_client):
"""Test that text shorter than MIN_LENGTH returns None."""
with patch("voice.providers.openai_tts.OpenAI", return_value=mock_openai_client):
tts = OpenA... | None | assert | none_literal | tests/voice/providers/test_openai_tts.py | test_validate_text_too_short | 38 | null | |
JoshuaC215/agent-service-toolkit | import logging
from contextlib import asynccontextmanager
import pytest
from fastapi import FastAPI
from schema import AgentInfo
@pytest.mark.asyncio
async def test_lifespan(monkeypatch, caplog) -> None:
"""Test that the lifespan sets up the database and store, loads the agents, and logs errors."""
from serv... | caplog.text | assert | complex_expr | tests/service/test_service_lifespan.py | test_lifespan | 76 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.github_mcp_agent.github_mcp_agent import GitHubMCPAgent, prompt
from core.settings import settings
class TestGitHubMCPAgent:
def test_initialization(self):
"""Test that agent initializes correctly."""
agent = GitHubMCPAge... | [] | assert | collection | tests/agents/test_github_mcp_agent.py | test_initialization | TestGitHubMCPAgent | 18 | null |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | logging.WARNING | assert | complex_expr | tests/core/test_settings.py | test_log_level_enum | 210 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | ValidationError) | pytest.raises | variable | tests/core/test_settings.py | test_check_str_is_http | 24 | null | |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from langchain_anthropic import ChatAnthropic
from langchain_community.chat_models import FakeListChatModel
from langchain_groq import ChatGroq
from langchain_ollama import ChatOllama
from langchain_openai import ChatOpenAI
from core.llm import get_model
from sc... | "llama3.3" | assert | string_literal | tests/core/test_llm.py | test_get_model_ollama | 58 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.github_mcp_agent.github_mcp_agent import GitHubMCPAgent, prompt
from core.settings import settings
class TestGitHubMCPAgent:
@pytest.mark.asyncio
async def test_load_with_github_pat(self):
"""Test load when GITHUB_PAT is set ... | mock_tools | assert | variable | tests/agents/test_github_mcp_agent.py | test_load_with_github_pat | TestGitHubMCPAgent | 65 | null |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import AsyncMock, patch
import langsmith
import pytest
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from langgraph.pregel.types import StateSnapshot
from langgraph.types import Interrupt
from agents.agents import Agent
from schema import ChatHistory, ChatM... | 422 | assert | numeric_literal | tests/service/test_service.py | test_invoke_model_param | 93 | null | |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import AsyncMock, patch
import langsmith
import pytest
from langchain_core.messages import AIMessage, AIMessageChunk, HumanMessage
from langgraph.pregel.types import StateSnapshot
from langgraph.types import Interrupt
from agents.agents import Agent
from schema import ChatHistory, ChatM... | 1 | assert | numeric_literal | tests/service/test_service.py | test_info | 372 | null | |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import patch
import pytest
from langchain_core.language_models import FakeMessagesListChatModel
from langchain_core.messages import AIMessage, BaseMessage, ToolCall
from langgraph.checkpoint.memory import MemorySaver
from schema import ChatMessage, StreamInput
@pytest.mark.asyncio
asyn... | "transfer_back_to_supervisor" | assert | string_literal | tests/service/test_service_message_generator.py | test_three_layer_supervisor_hierarchy_agent_with_fake_model | 73 | null | |
JoshuaC215/agent-service-toolkit | import pytest
from streamlit.testing.v1 import AppTest
from client import AgentClient
@pytest.mark.docker
def test_service_with_fake_model():
"""Test the service using the fake model.
This test requires the service container to be running with USE_FAKE_MODEL=true
"""
client = AgentClient("http://0.0.... | "This is a test response from the fake model." | assert | string_literal | tests/integration/test_docker_e2e.py | test_service_with_fake_model | 16 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
from voice.providers.openai_stt import OpenAISTT
def test_transcribe_strips_whitespace(mock_openai_client, mock_audio_file):
"""Test that transcription result has whitespace stripped."""
# Mock API returns text with surrounding whitespace
mock_openai_client.audio.transcript... | "text with spaces" | assert | string_literal | tests/voice/providers/test_openai_stt.py | test_transcribe_strips_whitespace | 44 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import Mock
import pytest
from agents.lazy_agent import LazyLoadingAgent
class TestLazyLoadingAgentBase:
def test_initialization(self):
"""Test that agent initializes correctly."""
agent = TestLazyLoadingAgent()
assert not agent._loaded
assert agent._graph is | None | assert | none_literal | tests/agents/test_lazy_agent.py | test_initialization | TestLazyLoadingAgentBase | 34 | null |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.github_mcp_agent.github_mcp_agent import GitHubMCPAgent, prompt
from core.settings import settings
class TestGitHubMCPAgent:
def test_get_graph_not_loaded(self):
"""Test get_graph when agent is not loaded."""
agent = GitH... | RuntimeError, match="Agent not loaded. Call load\\(\\) first.") | pytest.raises | func_call | tests/agents/test_github_mcp_agent.py | test_get_graph_not_loaded | TestGitHubMCPAgent | 122 | null |
JoshuaC215/agent-service-toolkit | from collections.abc import AsyncGenerator
from unittest.mock import AsyncMock, Mock
import pytest
from streamlit.testing.v1 import AppTest
from client import AgentClientError
from schema import ChatHistory, ChatMessage
from schema.models import OpenAIModelName
def test_app_simple_non_streaming(mock_agent_client):
... | PROMPT | assert | variable | tests/app/test_streamlit_app.py | test_app_simple_non_streaming | 31 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.agents import agents, get_agent, load_agent
from agents.lazy_agent import LazyLoadingAgent
class TestAgentLoading:
def test_get_agent_lazy_agent_loaded(self):
"""Test getting a lazy agent that has been loaded."""
mock_age... | mock_graph | assert | variable | tests/agents/test_agent_loading.py | test_get_agent_lazy_agent_loaded | TestAgentLoading | 65 | null |
JoshuaC215/agent-service-toolkit | from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolCall, ToolMessage
from service.utils import langchain_to_chat_message
def test_messages_from_langchain() -> None:
lc_human_message = HumanMessage(content="Hello, world!")
human_message = langchain_to_chat_message(lc_human_message)... | "123" | assert | string_literal | tests/service/test_utils.py | test_messages_from_langchain | 21 | null | |
JoshuaC215/agent-service-toolkit | from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolCall, ToolMessage
from service.utils import langchain_to_chat_message
def test_messages_from_langchain() -> None:
lc_human_message = HumanMessage(content="Hello, world!")
human_message = langchain_to_chat_message(lc_human_message)... | "human" | assert | string_literal | tests/service/test_utils.py | test_messages_from_langchain | 9 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import AsyncMock, Mock, patch
import pytest
from agents.agents import agents, get_agent, load_agent
from agents.lazy_agent import LazyLoadingAgent
class TestAgentLoading:
def test_get_agent_static_agent(self):
"""Test getting a static agent."""
agent = get_agent("chatbot")
... | None | assert | none_literal | tests/agents/test_agent_loading.py | test_get_agent_static_agent | TestAgentLoading | 42 | null |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
import pytest
from voice.providers.openai_tts import OpenAITTS
def test_init_with_invalid_voice():
"""Test that invalid voice raises ValueError."""
# Passes if ValueError is raised for invalid voice
with pytest.raises( | ValueError, match="Invalid voice") | pytest.raises | complex_expr | tests/voice/providers/test_openai_tts.py | test_init_with_invalid_voice | 21 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | expected_models | assert | variable | tests/core/test_settings.py | test_settings_with_multiple_api_keys | 86 | null | |
JoshuaC215/agent-service-toolkit | from unittest.mock import patch
import pytest
from voice.providers.openai_tts import OpenAITTS
def test_init_with_invalid_model():
"""Test that invalid model raises ValueError."""
# Passes if ValueError is raised for invalid model
with pytest.raises( | ValueError, match="Invalid model") | pytest.raises | complex_expr | tests/voice/providers/test_openai_tts.py | test_init_with_invalid_model | 28 | null | |
JoshuaC215/agent-service-toolkit | import json
import os
from unittest.mock import AsyncMock, Mock, patch
import pytest
from httpx import Request, Response
from client import AgentClient, AgentClientError
from schema import AgentInfo, ChatHistory, ChatMessage, ServiceMetadata
from schema.models import OpenAIModelName
def test_init(mock_env):
"""T... | 30.0 | assert | numeric_literal | tests/client/test_client.py | test_init | 27 | null | |
JoshuaC215/agent-service-toolkit | from langchain_core.messages import AIMessage, HumanMessage, SystemMessage, ToolCall, ToolMessage
from service.utils import langchain_to_chat_message
def test_messages_tool_calls() -> None:
tool_call = ToolCall(name="test_tool", args={"x": 1, "y": 2}, id="call_Jja7")
lc_ai_message = AIMessage(content="", tool... | "call_Jja7" | assert | string_literal | tests/service/test_utils.py | test_messages_tool_calls | 42 | null | |
JoshuaC215/agent-service-toolkit | import json
from unittest.mock import patch
import pytest
from langchain_core.language_models import FakeMessagesListChatModel
from langchain_core.messages import AIMessage, BaseMessage, ToolCall
from langgraph.checkpoint.memory import MemorySaver
from schema import ChatMessage, StreamInput
@pytest.mark.asyncio
asyn... | "The result is 5." | assert | string_literal | tests/service/test_service_message_generator.py | test_three_layer_supervisor_hierarchy_agent_with_fake_model | 75 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | 8080 | assert | numeric_literal | tests/core/test_settings.py | test_settings_default_values | 33 | null | |
JoshuaC215/agent-service-toolkit | import json
import os
from unittest.mock import AsyncMock, Mock, patch
import pytest
from httpx import Request, Response
from client import AgentClient, AgentClientError
from schema import AgentInfo, ChatHistory, ChatMessage, ServiceMetadata
from schema.models import OpenAIModelName
@pytest.mark.asyncio
async def te... | KWARGS | assert | variable | tests/client/test_client.py | test_acreate_feedback | 256 | null | |
JoshuaC215/agent-service-toolkit | import os
from unittest.mock import patch
import pytest
from voice.tts import TextToSpeech
def test_init_with_unimplemented_provider():
"""Test that unimplemented provider raises NotImplementedError."""
# Passes if NotImplementedError is raised (elevenlabs not yet implemented)
with pytest.raises( | NotImplementedError, match="ElevenLabs TTS provider not yet implemented") | pytest.raises | complex_expr | tests/voice/test_tts.py | test_init_with_unimplemented_provider | 29 | null | |
JoshuaC215/agent-service-toolkit | import json
import logging
import os
from unittest.mock import patch
import pytest
from pydantic import SecretStr, ValidationError
from core.settings import LogLevel, Settings, check_str_is_http
from schema.models import (
AnthropicModelName,
AzureOpenAIModelName,
OpenAIModelName,
VertexAIModelName,
)... | logging.INFO | assert | complex_expr | tests/core/test_settings.py | test_log_level_enum | 209 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.