-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
178 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ requires = [ | |
"setuptools >= 46.4.0", | ||
] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[tool.isort] | ||
profile = "black" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
class AttributeNotInitialized(Exception): | ||
pass | ||
def __init__(self, message: str = "Attribute not initialized") -> None: | ||
super().__init__(message) | ||
|
||
|
||
class OperationError(Exception): | ||
pass | ||
def __init__(self, message: str = "OperationError") -> None: | ||
super().__init__(message) | ||
|
||
|
||
class ExchangeNotFound(Exception): | ||
def __init__( | ||
self, exchange_name: str, message: str = "Exchange '{name}' not found" | ||
): | ||
super().__init__(message.format(name=exchange_name)) | ||
def __init__(self, exchange_name: str) -> None: | ||
super().__init__(f"Exchange '{exchange_name}' not found") | ||
|
||
|
||
class ClientNotConnectedError(Exception): | ||
def __init__(self, message="AioRabbitClient was not connected with RabbitMQ"): | ||
def __init__( | ||
self, message: str = "AioRabbitClient was not connected with RabbitMQ" | ||
) -> None: | ||
super().__init__(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from rabbit.background_tasks import BackgroundTasks | ||
from rabbit.job import async_echo_job | ||
|
||
|
||
@pytest.fixture | ||
def background_tasks(): | ||
return BackgroundTasks() | ||
|
||
|
||
async def test_background_tasks_add(background_tasks): | ||
background_tasks.add("test-task", async_echo_job, b'{"message": "test"}') | ||
assert len(background_tasks) == 1 | ||
|
||
|
||
async def test_background_tasks_multiple_add(background_tasks): | ||
background_tasks.add("test-task-1", async_echo_job, b'{"message": "test"}') | ||
background_tasks.add("test-task-1", async_echo_job, b'{"message": "test"}') | ||
background_tasks.add("test-task-2", async_echo_job, b'{"message": "test2"}') | ||
assert len(background_tasks) == 2 | ||
|
||
|
||
async def test_background_tasks_by_name(background_tasks): | ||
background_tasks.add("test-task", async_echo_job, b'{"message": "test"}') | ||
for task in background_tasks: | ||
assert task.get_name() == "test-task" | ||
|
||
|
||
async def test_background_tasks_getitem(background_tasks): | ||
background_tasks.add("test-task", async_echo_job, b'{"message": "test"}') | ||
assert isinstance(background_tasks["test-task"], asyncio.Task) | ||
|
||
|
||
def test_background_tasks_len(background_tasks): | ||
assert len(background_tasks) == 0 | ||
|
||
|
||
def test_background_tasks_repr(background_tasks): | ||
assert repr(background_tasks) == "BackgroundTasks(tasks=0, tasks_by_name=[])" |
Oops, something went wrong.