Skip to content
This repository was archived by the owner on Aug 19, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 69 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@

name: Tests on platforms

on:
pull_request:
branches:
- master

jobs:
redis:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start containers
run: docker-compose -f "docker-compose.yaml" up -d --build redis
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install pytest
- name: Run tests
run: pytest -m redis tests/
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yaml" down
kafka:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start containers
run: docker-compose -f "docker-compose.yaml" up -d --build kafka
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install pytest
- name: Run tests
run: pytest -m kafka tests/
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yaml" down
postgres:
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Start containers
run: docker-compose -f "docker-compose.yaml" up -d --build postgres
- name: Install Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install pytest
- name: Run tests
run: pytest -m postgres tests/
- name: Stop containers
if: always()
run: docker-compose -f "docker-compose.yaml" down
45 changes: 25 additions & 20 deletions tests/test_broadcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,39 +5,44 @@

@pytest.mark.asyncio
async def test_memory():
async with Broadcast('memory://') as broadcast:
async with broadcast.subscribe('chatroom') as subscriber:
await broadcast.publish('chatroom', 'hello')
async with Broadcast("memory://") as broadcast:
async with broadcast.subscribe("chatroom") as subscriber:
await broadcast.publish("chatroom", "hello")
event = await subscriber.get()
assert event.channel == 'chatroom'
assert event.message == 'hello'
assert event.channel == "chatroom"
assert event.message == "hello"


@pytest.mark.asyncio
@pytest.mark.redis
async def test_redis():
async with Broadcast('redis://localhost:6379') as broadcast:
async with broadcast.subscribe('chatroom') as subscriber:
await broadcast.publish('chatroom', 'hello')
async with Broadcast("redis://localhost:6379") as broadcast:
async with broadcast.subscribe("chatroom") as subscriber:
await broadcast.publish("chatroom", "hello")
event = await subscriber.get()
assert event.channel == 'chatroom'
assert event.message == 'hello'
assert event.channel == "chatroom"
assert event.message == "hello"


@pytest.mark.asyncio
@pytest.mark.postgres
async def test_postgres():
async with Broadcast('postgres://postgres:postgres@localhost:5432/broadcaster') as broadcast:
async with broadcast.subscribe('chatroom') as subscriber:
await broadcast.publish('chatroom', 'hello')
async with Broadcast(
"postgres://postgres:postgres@localhost:5432/broadcaster"
) as broadcast:
async with broadcast.subscribe("chatroom") as subscriber:
await broadcast.publish("chatroom", "hello")
event = await subscriber.get()
assert event.channel == 'chatroom'
assert event.message == 'hello'
assert event.channel == "chatroom"
assert event.message == "hello"


@pytest.mark.asyncio
@pytest.mark.kafka
async def test_kafka():
async with Broadcast('kafka://localhost:9092') as broadcast:
async with broadcast.subscribe('chatroom') as subscriber:
await broadcast.publish('chatroom', 'hello')
async with Broadcast("kafka://localhost:9092") as broadcast:
async with broadcast.subscribe("chatroom") as subscriber:
await broadcast.publish("chatroom", "hello")
event = await subscriber.get()
assert event.channel == 'chatroom'
assert event.message == 'hello'
assert event.channel == "chatroom"
assert event.message == "hello"