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 |
|---|---|---|---|---|---|---|---|---|---|
Lancetnik/Propan | import pytest
from propan import RedisBroker
from propan.test.redis import build_message
from tests.brokers.base.testclient import BrokerTestclientTestcase
class TestKafkaTestclient(BrokerTestclientTestcase):
build_message = staticmethod(build_message)
@pytest.mark.asyncio
async def test_pattern_consume(... | 1 | assert | numeric_literal | tests/brokers/redis/test_test_client.py | test_pattern_consume | TestKafkaTestclient | 20 | null |
Lancetnik/Propan | from contextlib import asynccontextmanager
from typing import Any
from unittest.mock import Mock
import pytest
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from propan._compat import RequestValidationError
from propan.fastapi import KafkaRouter
from propan.test import TestKafkaBroker... | {"a", "b", "c", "m", "k"} | assert | collection | tests/fastapi/test_base.py | test_get_schema_json | 129 | null | |
Lancetnik/Propan | from pathlib import Path
import pytest
from propan.cli.utils.imports import get_app_path, import_object
def test_get_app_path_wrong():
with pytest.raises( | ValueError) | pytest.raises | variable | tests/cli/utils/test_imports.py | test_get_app_path_wrong | 30 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_base():
def func(a: int):
...
handler = BaseHandler(func, build_call_model(call=func))
me... | None | assert | none_literal | tests/asyncapi/handler/test_base_arguments.py | test_base | 26 | null | |
Lancetnik/Propan | from propan import PropanApp, RedisBroker
from propan.cli.docs.gen import gen_app_schema_json
def test_group_handler():
broker = RedisBroker()
@broker.handle("*test", pattern=True)
async def handler(a: int) -> str:
...
schema = gen_app_schema_json(PropanApp(broker))
examples = schema["ch... | { "Handler": { "bindings": { "redis": { "bindingVersion": "custom", "channel": "*test", "method": "psubscribe", } }, "servers": ["dev"], "subscribe": { "bindings": { "redis": { "bindingVersion": "custom", "replyTo": {"title": "HandlerReply", "type": "string"}, } }, "message": {"$ref": "#/components/messages/HandlerMess... | assert | collection | tests/asyncapi/redis/test_handler.py | test_group_handler | 47 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_response_base():
def func() -> str:
...
handler = BaseHandler(func, build_call_model(call=func... | { "title": "FuncPayload", "type": "null", } | assert | collection | tests/asyncapi/handler/test_base_arguments.py | test_response_base | 96 | null | |
Lancetnik/Propan | import aio_pika
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import RabbitBroker
from propan.utils import Depends
@pytest.mark.asyncio
@pytest.mark.rabbit
async def test_different_consumers_has_different_messages(
context,
full_broker: RabbitBroker,
):
message1 = N... | message2 | assert | variable | tests/brokers/rabbit/test_depends.py | test_different_consumers_has_different_messages | 70 | null | |
Lancetnik/Propan | from typing import Callable, Type, TypeVar
from unittest.mock import Mock
from uuid import uuid4
import pytest
from fastapi import APIRouter, Depends, FastAPI, Header
from fastapi.testclient import TestClient
from propan.types import AnyCallable
Broker = TypeVar("Broker")
class FastAPITestcase:
router_class: Ty... | router.broker | assert | complex_expr | tests/fastapi/case.py | test | FastAPITestcase | 58 | null |
Lancetnik/Propan | import logging
from itertools import zip_longest
import pytest
from propan import PropanApp, RabbitBroker
from propan.cli.utils.logs import LogLevels, get_log_level, set_log_level
@pytest.mark.parametrize(
"level,broker",
tuple(
zip_longest(
(
logging.ERROR,
... | app.broker.logger.level | assert | complex_expr | tests/cli/utils/test_logs.py | test_set_level | 28 | null | |
Lancetnik/Propan | from datetime import datetime
from typing import Dict, List
import anyio
import pytest
from pydantic import BaseModel, ValidationError
from propan.brokers._model import BrokerAsyncUsecase
from propan.types import AnyCallable
class BrokerTestclientTestcase:
build_message: AnyCallable
@pytest.mark.asyncio
... | expected_message | assert | variable | tests/brokers/base/testclient.py | test_serialize | BrokerTestclientTestcase | 55 | null |
Lancetnik/Propan | from propan import PropanApp, RabbitBroker
from propan.brokers.rabbit import ExchangeType, RabbitExchange
from propan.cli.docs.gen import gen_app_schema_json
def test_fanout_exchange_handler():
broker = RabbitBroker()
@broker.handle("test", RabbitExchange("test", type=ExchangeType.FANOUT))
async def handl... | { "Handler": { "bindings": { "amqp": { "bindingVersion": "0.2.0", "exchange": { "autoDelete": False, "durable": False, "name": "test", "type": "fanout", "vhost": "/", }, "is": "routingKey", } }, "servers": ["dev"], "subscribe": { "bindings": {"amqp": {"ack": True, "bindingVersion": "0.2.0"}}, "description": "Test descr... | assert | collection | tests/asyncapi/rabbit/test_handler.py | test_fanout_exchange_handler | 51 | null | |
Lancetnik/Propan | from typing import Tuple
import pytest
from propan.utils import apply_types
def cast_int(t: int = 1) -> Tuple[bool, int]:
return isinstance(t, int), t
def cast_default(t: int = 1) -> Tuple[bool, int]:
return isinstance(t, int), t
def test_int():
assert cast_int("1") == (True, 1)
assert cast_int(t=... | (True, 2) | assert | collection | tests/utils/type_cast/test_base.py | test_int | 22 | null | |
Lancetnik/Propan | from propan import KafkaBroker, PropanApp
from propan.cli.docs.gen import gen_app_schema_json
def test_group_handler():
broker = KafkaBroker()
@broker.handle("test", group_id="workers")
async def handler(a: int) -> str:
...
schema = gen_app_schema_json(PropanApp(broker))
examples = schem... | { "Handler": { "bindings": {"kafka": {"bindingVersion": "0.4.0", "topic": ["test"]}}, "servers": ["dev"], "subscribe": { "bindings": { "kafka": { "bindingVersion": "0.4.0", "groupId": {"enum": ["workers"], "type": "string"}, "replyTo": { "title": "HandlerReply", "type": "string", }, } }, "message": {"$ref": "#/componen... | assert | collection | tests/asyncapi/kafka/test_handler.py | test_group_handler | 37 | null | |
Lancetnik/Propan | import platform
from propan.cli.main import cli
def test_version(runner, version):
result = runner.invoke(cli, ["--version"])
assert result.exit_code == | 0 | assert | numeric_literal | tests/cli/test_version.py | test_version | 8 | null | |
Lancetnik/Propan | from propan import PropanApp, SQSBroker
from propan.cli.docs.gen import gen_app_schema_json
def test_base_handler():
broker = SQSBroker()
@broker.handle("test")
async def handler(a: int):
...
schema = gen_app_schema_json(PropanApp(broker))
assert schema["channels"] == | { "Handler": { "bindings": { "sqs": { "bindingVersion": "custom", "queue": {"fifo": False, "name": "test"}, } }, "servers": ["dev"], "subscribe": { "bindings": {"sqs": {"bindingVersion": "custom"}}, "message": {"$ref": "#/components/messages/HandlerMessage"}, }, } } | assert | collection | tests/asyncapi/sqs/test_handler.py | test_base_handler | 14 | null | |
Lancetnik/Propan | from propan import KafkaBroker, PropanApp
from propan.cli.docs.gen import gen_app_schema_json
def test_base_handler():
broker = KafkaBroker()
@broker.handle("test")
async def handler(a: int):
...
schema = gen_app_schema_json(PropanApp(broker))
assert schema["channels"] == | { "Handler": { "bindings": {"kafka": {"bindingVersion": "0.4.0", "topic": ["test"]}}, "servers": ["dev"], "subscribe": {"message": {"$ref": "#/components/messages/HandlerMessage"}}, } } | assert | collection | tests/asyncapi/kafka/test_handler.py | test_base_handler | 13 | null | |
Lancetnik/Propan | from propan import NatsBroker, PropanApp
from propan.cli.docs.gen import gen_app_schema_json
def test_base_handler():
broker = NatsBroker()
@broker.handle("test")
async def handler(a: int):
...
schema = gen_app_schema_json(PropanApp(broker))
assert schema["channels"] == | { "Handler": { "bindings": {"nats": {"bindingVersion": "custom", "subject": "test"}}, "servers": ["dev"], "subscribe": { "bindings": {"nats": {"bindingVersion": "custom"}}, "message": {"$ref": "#/components/messages/HandlerMessage"}, }, } } | assert | collection | tests/asyncapi/nats/test_handler.py | test_base_handler | 13 | null | |
Lancetnik/Propan | from contextlib import asynccontextmanager
from typing import Any
from unittest.mock import Mock
import pytest
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from propan._compat import RequestValidationError
from propan.fastapi import KafkaRouter
from propan.test import TestKafkaBroker... | 404 | assert | numeric_literal | tests/fastapi/test_base.py | test_not_generate_schema | 153 | null | |
Lancetnik/Propan | import asyncio
from datetime import datetime
from typing import Dict, List, Tuple
from unittest.mock import Mock
import pytest
from pydantic import BaseModel
from propan.annotations import Logger
from propan.brokers._model import BrokerAsyncUsecase
class BrokerPublishTestcase:
@pytest.mark.asyncio
async def... | {"a": 1, "b": 1, "args": (2, 3)}) | assert_* | collection | tests/brokers/base/publish.py | test_unwrap_list | BrokerPublishTestcase | 118 | null |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_base():
def func(a: int):
...
handler = BaseHandler(func, build_call_model(call=func))
me... | "FuncMessage" | assert | string_literal | tests/asyncapi/handler/test_base_arguments.py | test_base | 16 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_pydantic_example():
Message = create_model(
"Message",
__config__=ConfigDict(**{SCHEMA_FIEL... | { "example": {"a": 1}, "properties": { "a": {"title": "A", "type": "integer"}, }, "required": ["a"], "title": "Message", "type": "object", } | assert | collection | tests/asyncapi/handler/test_base_arguments.py | test_pydantic_example | 185 | null | |
Lancetnik/Propan | from typing import Tuple
import pytest
from propan.cli.utils.parser import parse_cli_args
APPLICATION = "module:app"
ARG1 = (
"--k",
"1",
)
ARG2 = (
"-k2",
"1",
)
ARG3 = ("--k3",)
ARG4 = ("--no-k4",)
ARG5 = (
"--k5",
"1",
"1",
)
ARG6 = ("--some-key",)
@pytest.mark.parametrize(
"args... | { "k": "1", "k2": "1", "k3": True, "k4": False, "k5": ["1", "1"], "some_key": True, } | assert | collection | tests/cli/utils/test_parser.py | test_custom_argument_parsing | 42 | null | |
Lancetnik/Propan | import pytest
from propan.test import TestSQSBroker
from main import broker
async def test_publish(test_broker):
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/sqs/3_conftest.py | test_publish | 13 | null | |
Lancetnik/Propan | from propan import PropanApp, RabbitBroker
from propan.cli.docs.gen import gen_app_schema_json
def test_server_info():
schema = gen_app_schema_json(PropanApp(RabbitBroker()))
assert schema["servers"]["dev"] == | { "protocol": "amqp", "url": "amqp://guest:guest@localhost:5672/", "protocolVersion": "0.9.1", } | assert | collection | tests/asyncapi/rabbit/test_server.py | test_server_info | 7 | null | |
Lancetnik/Propan | from pathlib import Path
import pytest
from propan.cli.utils.imports import get_app_path, import_object
@pytest.mark.parametrize(
"test_input,exp_module,exp_app",
(
("module:app", "module", "app"),
("module.module.module:app", "module/module/module", "app"),
),
)
def test_get_app_path(tes... | Path.cwd() / exp_module | assert | func_call | tests/cli/utils/test_imports.py | test_get_app_path | 26 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import (
ExchangeType,
RabbitBroker,
RabbitExchange,
RabbitQueue,
)
from propan.test.rabbit import build_message
from tests.brokers.base.testclient import BrokerTestclien... | 1 | assert | numeric_literal | tests/brokers/rabbit/test_test_client.py | test_fanout | TestRabbitTestclient | 57 | null |
Lancetnik/Propan | from propan import NatsBroker, PropanApp
from propan.cli.docs.gen import gen_app_schema_json
def test_server_info():
schema = gen_app_schema_json(PropanApp(NatsBroker()))
assert schema["servers"]["dev"] == | { "protocol": "nats", "url": "nats://localhost:4222", } | assert | collection | tests/asyncapi/nats/test_server.py | test_server_info | 7 | null | |
Lancetnik/Propan | import pytest
from propan.test import TestNatsBroker
from main import broker
async def test_publish(test_broker):
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/nats/3_conftest.py | test_publish | 13 | null | |
Lancetnik/Propan | from propan.utils.classes import Singleton
def test_singleton():
assert Singleton() is | Singleton() | assert | func_call | tests/utils/test_classes.py | test_singleton | 5 | null | |
Lancetnik/Propan | import pytest
from pydantic import ValidationError
from propan.utils import Context, ContextRepo, apply_types
@pytest.mark.asyncio
async def test_reset_global(context: ContextRepo):
a = 1000
context.set_global("key", a)
context.reset_global("key")
@apply_types
async def use(key=Context()): # pra... | ValidationError) | pytest.raises | variable | tests/utils/context/test_main.py | test_reset_global | 107 | null | |
Lancetnik/Propan | from typing import Tuple
import pytest
from propan.utils import apply_types
def cast_int(t: int = 1) -> Tuple[bool, int]:
return isinstance(t, int), t
def cast_default(t: int = 1) -> Tuple[bool, int]:
return isinstance(t, int), t
def test_int():
assert cast_int("1") == | (True, 1) | assert | collection | tests/utils/type_cast/test_base.py | test_int | 19 | null | |
Lancetnik/Propan | from typing import Callable, Type, TypeVar
from unittest.mock import Mock
from uuid import uuid4
import pytest
from fastapi import APIRouter, Depends, FastAPI, Header
from fastapi.testclient import TestClient
from propan.types import AnyCallable
Broker = TypeVar("Broker")
class FastAPITestcase:
router_class: Ty... | "called" | assert | string_literal | tests/fastapi/case.py | hello2 | FastAPITestcase | 49 | null |
Lancetnik/Propan | import pytest
from propan.brokers._model import BrokerAsyncUsecase, BrokerRouter
from propan.types import AnyCallable
class RouterTestcase:
build_message: AnyCallable
async def test_empty_prefix(
self,
router: BrokerRouter,
test_broker: BrokerAsyncUsecase,
queue: str,
):
... | "test" | assert | string_literal | tests/brokers/base/router.py | test_empty_prefix | RouterTestcase | 29 | null |
Lancetnik/Propan | from propan.test.nats import build_message
from main import healthcheck
async def test_publish(test_broker):
msg = build_message("ping", "ping")
assert (await healthcheck(msg)) == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/nats/5_build_message.py | test_publish | 7 | null | |
Lancetnik/Propan | import aio_pika
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import RabbitBroker
from propan.utils import Depends
@pytest.mark.asyncio
@pytest.mark.rabbit
async def test_different_consumers_has_different_messages(
context,
full_broker: RabbitBroker,
):
message1 = N... | None | assert | none_literal | tests/brokers/rabbit/test_depends.py | test_different_consumers_has_different_messages | 71 | null | |
Lancetnik/Propan | from propan import KafkaBroker, PropanApp
from propan.cli.docs.gen import gen_app_schema_json
def test_server_info():
schema = gen_app_schema_json(PropanApp(KafkaBroker()))
assert schema["servers"]["dev"] == | { "protocol": "kafka", "url": "localhost", "protocolVersion": "auto", } | assert | collection | tests/asyncapi/kafka/test_server.py | test_server_info | 7 | null | |
Lancetnik/Propan | from datetime import datetime
from typing import Dict, List
import anyio
import pytest
from pydantic import BaseModel, ValidationError
from propan.brokers._model import BrokerAsyncUsecase
from propan.types import AnyCallable
class BrokerTestclientTestcase:
build_message: AnyCallable
@pytest.mark.asyncio
... | TimeoutError) | pytest.raises | variable | tests/brokers/base/testclient.py | test_rpc_timeout_raises | BrokerTestclientTestcase | 83 | null |
Lancetnik/Propan | from unittest.mock import MagicMock
import pytest
from propan.brokers.exceptions import SkipMessage
from propan.brokers.push_back_watcher import (
FakePushBackWatcher,
PushBackWatcher,
WatcherContext,
)
from tests.tools.marks import needs_py38
def message():
return MagicMock(message_id=1)
@pytest.ma... | ValueError) | pytest.raises | variable | tests/brokers/base/test_pushback.py | test_push_back_watcher | 90 | null | |
Lancetnik/Propan | from propan import KafkaBroker, PropanApp
from propan.cli.docs.gen import gen_app_schema_json
def test_server_custom_info():
schema = gen_app_schema_json(
PropanApp(
KafkaBroker(
"kafka:9092",
protocol="kafka-secury",
api_version="1.0.0",
... | { "protocol": "kafka-secury", "url": "kafka:9092", "protocolVersion": "1.0.0", } | assert | collection | tests/asyncapi/kafka/test_server.py | test_server_custom_info | 24 | null | |
Lancetnik/Propan | from propan.test.rabbit import build_message
from main import healthcheck
async def test_publish(test_broker):
msg = build_message("ping", "ping")
assert (await healthcheck(msg)) == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/rabbit/5_build_message.py | test_publish | 7 | null | |
Lancetnik/Propan | from pathlib import Path
from unittest.mock import Mock
import uvicorn
import yaml
from typer.testing import CliRunner
from propan.cli.main import cli
def test_gen_wrong_path(runner: CliRunner, rabbit_async_project: Path):
app_path = f'{rabbit_async_project / "app" / "serve"}:app1'
r = runner.invoke(cli, ["d... | r.stdout | assert | complex_expr | tests/cli/test_doc.py | test_gen_wrong_path | 29 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import (
ExchangeType,
RabbitBroker,
RabbitExchange,
RabbitQueue,
)
from propan.test.rabbit import build_message
from tests.brokers.base.testclient import BrokerTestclien... | await test_broker.publish( exchange=exch, callback=True, headers={"key": 2} ) | assert | func_call | tests/brokers/rabbit/test_test_client.py | test_header | TestRabbitTestclient | 116 | null |
Lancetnik/Propan | import pytest
from pydantic import ValidationError
from propan.utils import Context, ContextRepo, apply_types
@apply_types
def use(key=Context(), key2=Context()):
assert key == | 1 | assert | numeric_literal | tests/utils/context/test_main.py | use | 127 | null | |
Lancetnik/Propan | import logging
import os
import signal
from unittest.mock import Mock, patch
import anyio
import pytest
from propan import PropanApp
from propan.brokers.rabbit import RabbitBroker
from propan.log import logger
from propan.utils import Context
from tests.tools.marks import needs_py38
def call2():
mock.cal... | 1 | assert | numeric_literal | tests/cli/test_app.py | call2 | 49 | null | |
Lancetnik/Propan | from propan import PropanApp, RabbitBroker
from propan.brokers.rabbit import ExchangeType, RabbitExchange
from propan.cli.docs.gen import gen_app_schema_json
def test_base_handler():
broker = RabbitBroker()
@broker.handle("test")
async def handler(a: int):
...
schema = gen_app_schema_json(Pro... | { "Handler": { "bindings": { "amqp": { "bindingVersion": "0.2.0", "exchange": {"type": "default", "vhost": "/"}, "is": "routingKey", "queue": { "autoDelete": False, "durable": False, "exclusive": False, "name": "test", "vhost": "/", }, } }, "servers": ["dev"], "subscribe": { "bindings": { "amqp": {"ack": True, "binding... | assert | collection | tests/asyncapi/rabbit/test_handler.py | test_base_handler | 15 | null | |
Lancetnik/Propan | import aio_pika
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import RabbitBroker
from propan.utils import Depends
@pytest.mark.asyncio
@pytest.mark.rabbit
async def test_broker_depends(
queue,
full_broker: RabbitBroker,
):
def sync_depends(message: RabbitMessage):
... | True | assert | bool_literal | tests/brokers/rabbit/test_depends.py | test_broker_depends | 39 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_response_base():
def func() -> str:
...
handler = BaseHandler(func, build_call_model(call=func... | {"title": "FuncReply", "type": "string"} | assert | collection | tests/asyncapi/handler/test_base_arguments.py | test_response_base | 105 | null | |
Lancetnik/Propan | from propan import PropanApp, RabbitBroker
from propan.asyncapi import AsyncAPIContact, AsyncAPILicense
from propan.cli.docs.gen import gen_app_schema_json
def test_app_default_info():
schema = gen_app_schema_json(PropanApp(RabbitBroker()))
assert schema["info"] == | { "description": "", "title": "Propan", "version": "0.1.0", } | assert | collection | tests/asyncapi/test_app_info.py | test_app_default_info | 8 | null | |
Lancetnik/Propan | import pytest
from propan.brokers.rabbit import RabbitBroker
@pytest.mark.asyncio
@pytest.mark.rabbit
async def test_set_max():
broker = RabbitBroker(logger=None, consumers=10)
await broker.start()
assert broker._channel._prefetch_count == | 10 | assert | numeric_literal | tests/brokers/rabbit/test_init.py | test_set_max | 11 | null | |
Lancetnik/Propan | from propan.test import TestRabbitBroker
from main import broker
async def test_publish():
async with TestRabbitBroker(broker) as test_broker:
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/rabbit/2_test.py | test_publish | 8 | null | |
Lancetnik/Propan | import pytest
from pydantic import ValidationError
from propan.utils import Context, ContextRepo, apply_types
def test_context_getattr(context: ContextRepo):
a = 1000
context.set_global("key", a)
assert context.key is a
assert context.key2 is | None | assert | none_literal | tests/utils/context/test_main.py | test_context_getattr | 12 | null | |
Lancetnik/Propan | from datetime import datetime
from typing import Dict, List
import anyio
import pytest
from pydantic import BaseModel, ValidationError
from propan.brokers._model import BrokerAsyncUsecase
from propan.types import AnyCallable
class BrokerTestclientTestcase:
build_message: AnyCallable
@pytest.mark.asyncio
... | ValidationError) | pytest.raises | variable | tests/brokers/base/testclient.py | test_handler_calling | BrokerTestclientTestcase | 72 | null |
Lancetnik/Propan | import pytest
import pydantic
from propan.test.rabbit import build_message
from main import healthcheck
async def test_publish(test_broker):
msg = build_message({ "msg": "ping" }, "ping")
with pytest.raises( | pydantic.ValidationError) | pytest.raises | complex_expr | docs/docs_src/quickstart/testing/rabbit/6_reraise.py | test_publish | 9 | null | |
Lancetnik/Propan | import platform
from propan.cli.main import cli
def test_version(runner, version):
result = runner.invoke(cli, ["--version"])
assert result.exit_code == 0
assert version in | result.stdout | assert | complex_expr | tests/cli/test_version.py | test_version | 9 | null | |
Lancetnik/Propan | import asyncio
from datetime import datetime
from typing import Dict, List, Tuple
from unittest.mock import Mock
import pytest
from pydantic import BaseModel
from propan.annotations import Logger
from propan.brokers._model import BrokerAsyncUsecase
class BrokerPublishTestcase:
@pytest.mark.asyncio
async def... | { "a": 1, "b": 1, }) | assert_* | collection | tests/brokers/base/publish.py | test_unwrap_dict | BrokerPublishTestcase | 90 | null |
Lancetnik/Propan | from fast_depends.core import build_call_model
from propan import Depends
from propan.brokers._model.schemas import BaseHandler
def test_multi_args():
def dep2(c: int):
...
def dep(a: int, m=Depends(dep2)):
...
def func(b: float, d=Depends(dep)):
...
handler = BaseHandler(fu... | {"b", "a", "c"} | assert | collection | tests/asyncapi/handler/test_dependencies_arguments.py | test_multi_args | 53 | null | |
Lancetnik/Propan | import logging
import os
import signal
from unittest.mock import Mock, patch
import anyio
import pytest
from propan import PropanApp
from propan.brokers.rabbit import RabbitBroker
from propan.log import logger
from propan.utils import Context
from tests.tools.marks import needs_py38
def test_init(app: PropanApp, con... | logger | assert | variable | tests/cli/test_app.py | test_init | 19 | null | |
Lancetnik/Propan | from propan import PropanApp, RabbitBroker
from propan.asyncapi import AsyncAPIContact, AsyncAPILicense
from propan.cli.docs.gen import gen_app_schema_json
def test_app_base_info():
schema = gen_app_schema_json(
PropanApp(
RabbitBroker(),
title="My App",
description="des... | { "description": "description", "title": "My App", "version": "1.0.0", } | assert | collection | tests/asyncapi/test_app_info.py | test_app_base_info | 24 | null | |
Lancetnik/Propan | from pathlib import Path
from unittest.mock import Mock
import pytest
from typer.testing import CliRunner
from propan import PropanApp
from propan.cli import cli
@pytest.mark.rabbit
@pytest.mark.run
def test_run_rabbit_correct(
runner: CliRunner,
rabbit_async_project: Path,
monkeypatch,
mock: Mock,
)... | 0 | assert | numeric_literal | tests/cli/test_run.py | test_run_rabbit_correct | 30 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import Field
from propan import PropanApp, RabbitBroker
from propan.brokers._model.schemas import BaseHandler
from propan.cli.docs.gen import get_app_schema
def test_scheme_naming():
broker = RabbitBroker()
app = PropanApp(broker)
@broker.handl... | "Handler" | assert | string_literal | tests/asyncapi/handler/test_naming.py | test_scheme_naming | 54 | null | |
Lancetnik/Propan | import pytest
import pydantic
from propan.test.kafka import build_message
from main import healthcheck
async def test_publish(test_broker):
msg = build_message({ "msg": "ping" }, "ping")
with pytest.raises( | pydantic.ValidationError) | pytest.raises | complex_expr | docs/docs_src/quickstart/testing/kafka/6_reraise.py | test_publish | 9 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import (
ExchangeType,
RabbitBroker,
RabbitExchange,
RabbitQueue,
)
from propan.test.rabbit import build_message
from tests.brokers.base.testclient import BrokerTestclien... | await test_broker.publish("", "logs.error", callback=True) | assert | func_call | tests/brokers/rabbit/test_test_client.py | test_topic | TestRabbitTestclient | 80 | null |
Lancetnik/Propan | async def test_publish(test_broker):
r = await test_broker.publish(
{"msg": "ping"}, "ping",
callback=True, callback_timeout=1
)
assert r == | None | assert | none_literal | docs/docs_src/quickstart/testing/4_suppressed_exc.py | test_publish | 6 | null | |
Lancetnik/Propan | from typing import Callable, Type, TypeVar
from unittest.mock import Mock
from uuid import uuid4
import pytest
from fastapi import APIRouter, Depends, FastAPI, Header
from fastapi.testclient import TestClient
from propan.types import AnyCallable
Broker = TypeVar("Broker")
class FastAPITestcase:
router_class: Ty... | "1" | assert | string_literal | tests/fastapi/case.py | test | FastAPITestcase | 63 | null |
Lancetnik/Propan | from propan import PropanApp, RabbitBroker
from propan.cli.docs.gen import gen_app_schema_json
def test_server_custom_info():
schema = gen_app_schema_json(
PropanApp(
RabbitBroker(
"amqps://rabbithost.com", protocol="amqps", protocol_version="0.8.0"
)
)
)... | { "protocol": "amqps", "url": "amqps://rabbithost.com", "protocolVersion": "0.8.0", } | assert | collection | tests/asyncapi/rabbit/test_server.py | test_server_custom_info | 22 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_pydantic_args():
class Message(BaseModel):
a: int
b: float
def func(a: Message):
... | { "properties": { "a": {"title": "A", "type": "integer"}, "b": {"title": "B", "type": "number"}, }, "required": ["a", "b"], "title": "Message", "type": "object", } | assert | collection | tests/asyncapi/handler/test_base_arguments.py | test_pydantic_args | 74 | null | |
Lancetnik/Propan | import pytest
from propan.test import TestRabbitBroker
from main import broker
async def test_publish(test_broker):
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/rabbit/3_conftest.py | test_publish | 13 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import Field
from propan import PropanApp, RabbitBroker
from propan.brokers._model.schemas import BaseHandler
from propan.cli.docs.gen import get_app_schema
def test_pydantic_field_rename_miltiple():
def func(
a: int = Field(title="AField", desc... | result["properties"]["a"]["description"] | assert | complex_expr | tests/asyncapi/handler/test_naming.py | test_pydantic_field_rename_miltiple | 37 | null | |
Lancetnik/Propan | import asyncio
import pytest
from propan import KafkaBroker
from tests.brokers.base.publish import BrokerPublishTestcase
class TestKafkaPublish(BrokerPublishTestcase):
@pytest.mark.asyncio
async def test_publish_batch(self, queue: str, broker: KafkaBroker):
msgs_queue = asyncio.Queue(maxsize=2)
... | {r.result() for r in result} | assert | collection | tests/brokers/kafka/test_publish.py | test_publish_batch | TestKafkaPublish | 33 | null |
Lancetnik/Propan | from fast_depends.core import build_call_model
from propan import Depends
from propan.brokers._model.schemas import BaseHandler
def test_base():
def dep(a: int):
...
def func(a=Depends(dep)):
...
handler = BaseHandler(func, build_call_model(call=func))
message_title, result, respons... | None | assert | none_literal | tests/asyncapi/handler/test_dependencies_arguments.py | test_base | 28 | null | |
Lancetnik/Propan | from propan import PropanApp, SQSBroker
from propan.cli.docs.gen import gen_app_schema_json
def test_server_info():
schema = gen_app_schema_json(PropanApp(SQSBroker()))
assert schema["servers"]["dev"] == | { "protocol": "sqs", "url": "http://localhost:9324/", } | assert | collection | tests/asyncapi/sqs/test_server.py | test_server_info | 7 | null | |
Lancetnik/Propan | from contextlib import asynccontextmanager
from typing import Any
from unittest.mock import Mock
import pytest
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from propan._compat import RequestValidationError
from propan.fastapi import KafkaRouter
from propan.test import TestKafkaBroker... | 200 | assert | numeric_literal | tests/fastapi/test_base.py | test_get_schema_yaml | 101 | null | |
Lancetnik/Propan | from propan.test import TestKafkaBroker
from main import broker
async def test_publish():
async with TestKafkaBroker(broker) as test_broker:
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/kafka/2_test.py | test_publish | 8 | null | |
Lancetnik/Propan | import pytest
from propan.brokers.rabbit import RabbitBroker, RabbitExchange, RabbitQueue
from tests.tools.marks import needs_py38
@needs_py38
@pytest.mark.asyncio
async def test_declare_queue(
broker: RabbitBroker, async_mock, mock, monkeypatch: pytest.MonkeyPatch, queue: str
):
with monkeypatch.context():
... | q2 | assert | variable | tests/brokers/rabbit/test_declare.py | test_declare_queue | 19 | null | |
Lancetnik/Propan | from propan import PropanApp, SQSBroker
from propan.cli.docs.gen import gen_app_schema_json
def test_group_handler():
broker = SQSBroker()
@broker.handle("test")
async def handler(a: int) -> str:
...
schema = gen_app_schema_json(PropanApp(broker))
examples = schema["channels"]["Handler"]... | { "Handler": { "bindings": { "sqs": { "bindingVersion": "custom", "queue": {"fifo": False, "name": "test"}, } }, "servers": ["dev"], "subscribe": { "bindings": { "sqs": { "bindingVersion": "custom", "replyTo": {"title": "HandlerReply", "type": "string"}, } }, "message": {"$ref": "#/components/messages/HandlerMessage"},... | assert | collection | tests/asyncapi/sqs/test_handler.py | test_group_handler | 46 | null | |
Lancetnik/Propan | from pathlib import Path
import pytest
from propan.cli.utils.imports import get_app_path, import_object
def test_import_wrong():
dir, app = get_app_path("tests:test_object")
with pytest.raises(FileNotFoundError) as excinfo:
import_object(dir, app)
assert f"{dir}.py" in | str(excinfo.value) | assert | func_call | tests/cli/utils/test_imports.py | test_import_wrong | 13 | null | |
Lancetnik/Propan | from unittest.mock import MagicMock
import pytest
from propan.brokers.exceptions import SkipMessage
from propan.brokers.push_back_watcher import (
FakePushBackWatcher,
PushBackWatcher,
WatcherContext,
)
from tests.tools.marks import needs_py38
def message():
return MagicMock(message_id=1)
async ... | 1 | assert | numeric_literal | tests/brokers/base/test_pushback.py | call_success | 23 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import (
ExchangeType,
RabbitBroker,
RabbitExchange,
RabbitQueue,
)
from propan.test.rabbit import build_message
from tests.brokers.base.testclient import BrokerTestclien... | await test_broker.publish("", exchange="test2", callback=True) | assert | func_call | tests/brokers/rabbit/test_test_client.py | test_direct | TestRabbitTestclient | 38 | null |
Lancetnik/Propan | import pytest
from propan.utils.functions import call_or_await
def sync_func(a):
return a
async def async_func(a):
return a
@pytest.mark.asyncio
async def test_call():
assert (await call_or_await(sync_func, a=3)) == | 3 | assert | numeric_literal | tests/utils/test_functions.py | test_call | 16 | null | |
Lancetnik/Propan | import asyncio
from datetime import datetime
from typing import Dict, List, Tuple
from unittest.mock import Mock
import pytest
from pydantic import BaseModel
from propan.annotations import Logger
from propan.brokers._model import BrokerAsyncUsecase
class BrokerPublishTestcase:
@pytest.mark.asyncio
@pytest.ma... | expected_message) | assert_* | variable | tests/brokers/base/publish.py | test_serialize | BrokerPublishTestcase | 67 | null |
Lancetnik/Propan | from contextlib import asynccontextmanager
from typing import Any
from unittest.mock import Mock
import pytest
from fastapi import Depends, FastAPI
from fastapi.testclient import TestClient
from propan._compat import RequestValidationError
from propan.fastapi import KafkaRouter
from propan.test import TestKafkaBroker... | True | assert | bool_literal | tests/fastapi/test_base.py | test_nested_lifespan | 44 | null | |
Lancetnik/Propan | from propan.test import TestSQSBroker
from main import broker
async def test_publish():
async with TestSQSBroker(broker) as test_broker:
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/sqs/2_test.py | test_publish | 8 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import anyio
import pytest
from propan.brokers._model import BrokerAsyncUsecase
class BrokerRPCTestcase:
@pytest.mark.asyncio
async def test_rpc(self, queue: str, full_broker: BrokerAsyncUsecase):
@full_broker.handle(queue)
async def m(): # pragm... | "1" | assert | string_literal | tests/brokers/base/rpc.py | test_rpc | BrokerRPCTestcase | 23 | null |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import Field
from propan import PropanApp, RabbitBroker
from propan.brokers._model.schemas import BaseHandler
from propan.cli.docs.gen import get_app_schema
def test_pydantic_field_rename():
def func(a: int = Field(title="MyField", description="MyField"... | "MyField" | assert | string_literal | tests/asyncapi/handler/test_naming.py | test_pydantic_field_rename | 18 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import anyio
import pytest
from propan.brokers._model import BrokerAsyncUsecase
class BrokerRPCTestcase:
@pytest.mark.asyncio
async def test_rpc_with_reply(
self, queue: str, mock: Mock, full_broker: BrokerAsyncUsecase
):
consume = asyncio.Ev... | "1") | assert_* | string_literal | tests/brokers/base/rpc.py | test_rpc_with_reply | BrokerRPCTestcase | 85 | null |
Lancetnik/Propan | import pytest
from propan.utils import Depends, apply_types
def sync_dep(key):
return key
async def async_dep(key):
return key
@pytest.mark.asyncio
async def test_sync_with_async_depends():
with pytest.raises( | AssertionError) | pytest.raises | variable | tests/utils/context/test_depends.py | test_sync_with_async_depends | 27 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from pydantic import BaseModel, create_model
from propan._compat import SCHEMA_FIELD, ConfigDict
from propan.brokers._model.schemas import BaseHandler
def test_pydantic_response():
Message = create_model(
"Message",
__config__=ConfigDict(**{SCHEMA_FIE... | { "examples": [{"a": 1}], "properties": { "a": {"title": "A", "type": "integer"}, }, "required": ["a"], "title": "Message", "type": "object", } | assert | collection | tests/asyncapi/handler/test_base_arguments.py | test_pydantic_response | 159 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import anyio
import pytest
from propan.brokers._model import BrokerAsyncUsecase
class BrokerRPCTestcase:
@pytest.mark.asyncio
async def test_rpc_timeout_raises(
self, queue: str, full_broker: BrokerAsyncUsecase
):
@full_broker.handle(queue)
... | TimeoutError) | pytest.raises | variable | tests/brokers/base/rpc.py | test_rpc_timeout_raises | BrokerRPCTestcase | 36 | null |
Lancetnik/Propan | from typing import Tuple
import pytest
from propan.utils import apply_types
def cast_int(t: int = 1) -> Tuple[bool, int]:
return isinstance(t, int), t
def cast_default(t: int = 1) -> Tuple[bool, int]:
return isinstance(t, int), t
def test_int():
assert cast_int("1") == (True, 1)
assert cast_int(t=... | (True, 0) | assert | collection | tests/utils/type_cast/test_base.py | test_int | 25 | null | |
Lancetnik/Propan | import logging
import os
import signal
from unittest.mock import Mock, patch
import anyio
import pytest
from propan import PropanApp
from propan.brokers.rabbit import RabbitBroker
from propan.log import logger
from propan.utils import Context
from tests.tools.marks import needs_py38
def test_init(app: PropanApp, con... | app | assert | variable | tests/cli/test_app.py | test_init | 18 | null | |
Lancetnik/Propan | import pytest
import pydantic
from propan.test.sqs import build_message
from main import healthcheck
async def test_publish(test_broker):
msg = build_message({ "msg": "ping" }, "ping")
with pytest.raises( | pydantic.ValidationError) | pytest.raises | complex_expr | docs/docs_src/quickstart/testing/sqs/6_reraise.py | test_publish | 9 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import pytest
from propan.annotations import RabbitMessage
from propan.brokers.rabbit import (
ExchangeType,
RabbitBroker,
RabbitExchange,
RabbitQueue,
)
from propan.test.rabbit import build_message
from tests.brokers.base.testclient import BrokerTestclien... | await test_broker.publish(exchange=exch, callback=True, headers={}) | assert | func_call | tests/brokers/rabbit/test_test_client.py | test_header | TestRabbitTestclient | 119 | null |
Lancetnik/Propan | import logging
from itertools import zip_longest
import pytest
from propan import PropanApp, RabbitBroker
from propan.cli.utils.logs import LogLevels, get_log_level, set_log_level
def test_set_default():
app = PropanApp()
level = "wrong_level"
set_log_level(get_log_level(level), app)
assert app.logg... | logging.INFO | assert | complex_expr | tests/cli/utils/test_logs.py | test_set_default | 54 | null | |
Lancetnik/Propan | from propan.test import TestNatsBroker
from main import broker
async def test_publish():
async with TestNatsBroker(broker) as test_broker:
r = await test_broker.publish("ping", "ping", callback=True)
assert r == | "pong" | assert | string_literal | docs/docs_src/quickstart/testing/nats/2_test.py | test_publish | 8 | null | |
Lancetnik/Propan | import asyncio
from unittest.mock import Mock
import anyio
import pytest
from propan.brokers._model import BrokerAsyncUsecase
class ReplyAndConsumeForbidden:
@pytest.mark.asyncio
async def test_rpc_with_reply_and_callback(self, full_broker: BrokerAsyncUsecase):
async with full_broker:
wi... | ValueError) | pytest.raises | variable | tests/brokers/base/rpc.py | test_rpc_with_reply_and_callback | ReplyAndConsumeForbidden | 92 | null |
Lancetnik/Propan | from pathlib import Path
from unittest.mock import Mock
import uvicorn
import yaml
from typer.testing import CliRunner
from propan.cli.main import cli
def test_gen_rabbit_docs(runner: CliRunner, rabbit_async_project: Path):
app_path = f'{rabbit_async_project / "app" / "serve"}:app'
r = runner.invoke(cli, ["d... | 0 | assert | numeric_literal | tests/cli/test_doc.py | test_gen_rabbit_docs | 14 | null | |
Lancetnik/Propan | from fast_depends.core import build_call_model
from propan import Depends
from propan.brokers._model.schemas import BaseHandler
def test_base():
def dep(a: int):
...
def func(a=Depends(dep)):
...
handler = BaseHandler(func, build_call_model(call=func))
message_title, result, respons... | { "title": "FuncPayload", "type": "integer", } | assert | collection | tests/asyncapi/handler/test_dependencies_arguments.py | test_base | 23 | null | |
rubik/radon | import json
import os
import pytest
import radon.cli as cli
from radon.cli.harvest import (
SUPPORTS_IPYNB,
CCHarvester,
Harvester,
MIHarvester,
RawHarvester,
)
from radon.cli.tools import _is_python_file
from radon.tests.test_cli_harvest import MI_CONFIG, RAW_CONFIG
BASE_CONFIG_WITH_IPYNB = cli.... | 37 | assert | numeric_literal | radon/tests/test_ipynb.py | test_raw_ipynb | 117 | null | |
rubik/radon | import pytest
import radon.cli.harvest as harvest
import radon.complexity as cc_mod
from radon.cli import Config
BASE_CONFIG = Config(
exclude=r'test_[^.]+\.py',
ignore='tests,docs',
include_ipynb=False,
ipynb_cells=False,
)
CC_CONFIG = Config(
order=getattr(cc_mod, 'SCORE'),
no_assert=False,... | mocker.sentinel.one) | assert_* | complex_expr | radon/tests/test_cli_harvest.py | test_raw_gobble | 234 | null | |
rubik/radon | import sys
import textwrap
import pytest
from radon.visitors import *
dedent = lambda code: textwrap.dedent(code).strip()
SIMPLE_BLOCKS = [
(
'''
if a: pass
''',
2,
{},
),
(
'''
if a: pass
else: pass
''',
2,
{},
),
(
... | expected_str | assert | variable | radon/tests/test_complexity_visitor.py | test_visitor_containers | 754 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.