Пример #1
0
async def given_a_stream_with_three_events(c, stream_name):
    await c.publish(
        stream_name,
        [
            messages.NewEvent(
                "pony_jumped",
                data={
                    "Pony": "Derpy Hooves",
                    "Height": 10,
                    "Distance": 13
                },
            ),
            messages.NewEvent(
                "pony_jumped",
                data={
                    "Pony": "Sparkly Hooves",
                    "Height": 4,
                    "Distance": 9
                },
            ),
            messages.NewEvent(
                "pony_jumped",
                data={
                    "Pony": "Unlikely Hooves",
                    "Height": 73,
                    "Distance": 912
                },
            ),
        ],
    )
Пример #2
0
async def test_three_events_publish(event_loop):
    stream_name = str(uuid.uuid4())
    async with connect(username="******", password="******") as c:
        result = await c.publish(
            stream_name,
            [
                messages.NewEvent(
                    "pony_jumped",
                    data={
                        "Pony": "Derpy Hooves",
                        "Height": 10,
                        "Distance": 13
                    },
                ),
                messages.NewEvent(
                    "pony_jumped",
                    data={
                        "Pony": "Sparkly Hooves",
                        "Height": 4,
                        "Distance": 9
                    },
                ),
                messages.NewEvent(
                    "pony_jumped",
                    data={
                        "Pony": "Unlikely Hooves",
                        "Height": 73,
                        "Distance": 912
                    },
                ),
            ],
        )
        assert result.first_event_number == 0
        assert result.last_event_number == 2
Пример #3
0
async def given_a_stream_with_three_events(c, stream_name):
    result = await c.publish(
        stream_name,
        [
            messages.NewEvent(
                "pony_jumped",
                data={
                    "Pony": "Derpy Hooves",
                    "Height": 10,
                    "Distance": 13
                },
            ),
            messages.NewEvent(
                "pony_jumped",
                data={
                    "Pony": "Sparkly Hooves",
                    "Height": 4,
                    "Distance": 9
                },
            ),
            messages.NewEvent(
                "pony_jumped",
                data={
                    "Pony": "Unlikely Hooves",
                    "Height": 73,
                    "Distance": 912
                },
            ),
        ],
    )
    assert "denied" not in str(result).lower()  # this should now never happen
Пример #4
0
async def test_a_large_event(event_loop):
    stream_name = str(uuid.uuid4())
    async with connect(username="******", password="******") as c:
        write_result = await c.publish(
            stream_name,
            [
                messages.NewEvent("big_json", data=data.CHAIR),
                messages.NewEvent("big_json", data=data.CHAIR),
                messages.NewEvent("big_json", data=data.CHAIR),
            ],
        )
        assert write_result.first_event_number == 0
        read_result = await c.get(stream_name, 0)
        print(read_result)
        assert read_result[0].event.type == "big_json"
Пример #5
0
async def test_publish_raises_exception_if_not_authenticated(event_loop):
    stream_name = str(uuid.uuid4())

    async with connect() as conn:
        with pytest.raises(exceptions.AccessDenied):
            await conn.publish(
                stream_name,
                [messages.NewEvent("pony_jumped", data={})],
            )
Пример #6
0
async def given_two_streams_with_two_events(c, id):
    await c.publish(
        "stream_one_{}".format(id),
        [
            messages.NewEvent(
                "pony_splits",
                data={
                    "Pony": "Derpy Hooves",
                    "Height": 10,
                    "Distance": 13
                },
            ),
            messages.NewEvent(
                "pony_splits",
                data={
                    "Pony": "Sparkly Hooves",
                    "Height": 4,
                    "Distance": 9
                },
            ),
        ],
    )
    await c.publish(
        "stream_two_{}".format(id),
        [
            messages.NewEvent(
                "pony_splits",
                data={
                    "Pony": "Unlikely Hooves",
                    "Height": 63,
                    "Distance": 23
                },
            ),
            messages.NewEvent(
                "pony_splits",
                data={
                    "Pony": "Glitter Hooves",
                    "Height": 11,
                    "Distance": 94
                },
            ),
        ],
    )