Skip to content

Commit

Permalink
Stress: Simple test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
ask committed Jun 15, 2017
1 parent 963a50b commit dddd43c
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions t/stress/test_simple.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import asyncio
import pytest
from hypothesis import given
from hypothesis.strategies import (
dictionaries, one_of, integers, booleans,
floats, binary, text,
)
from .app import app, simple
from typing import Mapping
from faust.utils.logging import setup_logging
from .app import simple


setup_logging(loglevel='INFO')


def _build_data(i: int) -> Mapping:
return {'A': {'the': {'quick': {'brown': {'fox': i}}}}}


@pytest.mark.asyncio
async def test_simple():
data = dictionaries(text(),
one_of(integers(),
booleans(),
floats(),
text()))
print('RUNNING TEST')
value = data.example()
print('STARTING: %r' % (value,))
reply = await simple.ask(value=data.example())
assert reply == value
print('ENDED')
async def test_simple_ask() -> None:
for i in range(100):
value = _build_data(i)
assert await simple.ask(value=value) == value


@pytest.mark.asyncio
async def test_simple_map() -> None:
values = [_build_data(i) for i in range(100)]
check = set(range(100))
replies = set()
async for reply in simple.map(values):
v = reply['A']['the']['quick']['brown']['fox']
assert v in check
replies.add(v)
assert replies == check

0 comments on commit dddd43c

Please sign in to comment.