1
- from unittest .mock import patch , MagicMock
2
- from dramatiq .encoder import DecodeError
3
- from dramatiq import get_broker , get_encoder
4
- from dramatiq .brokers .stub import StubBroker
1
+ from unittest .mock import MagicMock , patch
5
2
6
- import pytest
7
3
import orjson
4
+ import pytest
5
+ from dramatiq import get_broker , get_encoder
6
+ from dramatiq .brokers .stub import StubBroker
7
+ from dramatiq .encoder import DecodeError
8
8
9
9
from common import AppConfig
10
10
from common .config import DramatiqConfig
@@ -27,7 +27,10 @@ def test_orjson_encoder(
27
27
mocked_loads .assert_called_once_with (b"serialized" )
28
28
29
29
30
- @patch ("common.dramatiq.orjson.loads" , side_effect = orjson .JSONDecodeError ("msg" ,"doc" , 123 ))
30
+ @patch (
31
+ "common.dramatiq.orjson.loads" ,
32
+ side_effect = orjson .JSONDecodeError ("msg" , "doc" , 123 ),
33
+ )
31
34
def test_orjson_encoder_fails (
32
35
mocked_loads : MagicMock ,
33
36
):
@@ -60,6 +63,10 @@ def test_init_dramatiq_with_redis():
60
63
61
64
def test_init_dramatiq_without_redis_url ():
62
65
"""Test if an exception is raised when in non-test environment without Redis URL."""
63
- config = AppConfig (ENVIRONMENT = "production" , DRAMATIQ = DramatiqConfig (REDIS_URL = None )) # Mock config
64
- with pytest .raises (RuntimeError , match = "Running a non-test environment without Redis URL set" ):
65
- init_dramatiq (config )
66
+ config = AppConfig (
67
+ ENVIRONMENT = "production" , DRAMATIQ = DramatiqConfig (REDIS_URL = None )
68
+ ) # Mock config
69
+ with pytest .raises (
70
+ RuntimeError , match = "Running a non-test environment without Redis URL set"
71
+ ):
72
+ init_dramatiq (config )
0 commit comments