@@ -23,11 +23,6 @@ class RabbitMqContainer(DockerContainer):
23
23
... connection = pika.BlockingConnection(rabbitmq.get_connection_params())
24
24
... channel = connection.channel()
25
25
"""
26
-
27
- RABBITMQ_NODE_PORT = os .environ .get ("RABBITMQ_NODE_PORT" , 5672 )
28
- RABBITMQ_DEFAULT_USER = os .environ .get ("RABBITMQ_DEFAULT_USER" , "guest" )
29
- RABBITMQ_DEFAULT_PASS = os .environ .get ("RABBITMQ_DEFAULT_PASS" , "guest" )
30
-
31
26
def __init__ (self , image : str = "rabbitmq:latest" , port : Optional [int ] = None ,
32
27
username : Optional [str ] = None , password : Optional [str ] = None , ** kwargs ) -> None :
33
28
"""Initialize the RabbitMQ test container.
@@ -39,14 +34,14 @@ def __init__(self, image: str = "rabbitmq:latest", port: Optional[int] = None,
39
34
password: RabbitMQ password.
40
35
"""
41
36
super (RabbitMqContainer , self ).__init__ (image = image , ** kwargs )
42
- self .RABBITMQ_NODE_PORT = port or int (self . RABBITMQ_NODE_PORT )
43
- self .RABBITMQ_DEFAULT_USER = username or self . RABBITMQ_DEFAULT_USER
44
- self .RABBITMQ_DEFAULT_PASS = password or self . RABBITMQ_DEFAULT_PASS
37
+ self .port = port or int (os . environ . get ( " RABBITMQ_NODE_PORT" , 5672 ) )
38
+ self .username = username or os . environ . get ( " RABBITMQ_DEFAULT_USER" , "guest" )
39
+ self .password = password or os . environ . get ( " RABBITMQ_DEFAULT_PASS" , "guest" )
45
40
46
- self .with_exposed_ports (self .RABBITMQ_NODE_PORT )
47
- self .with_env ("RABBITMQ_NODE_PORT" , self .RABBITMQ_NODE_PORT )
48
- self .with_env ("RABBITMQ_DEFAULT_USER" , self .RABBITMQ_DEFAULT_USER )
49
- self .with_env ("RABBITMQ_DEFAULT_PASS" , self .RABBITMQ_DEFAULT_PASS )
41
+ self .with_exposed_ports (self .port )
42
+ self .with_env ("RABBITMQ_NODE_PORT" , self .port )
43
+ self .with_env ("RABBITMQ_DEFAULT_USER" , self .username )
44
+ self .with_env ("RABBITMQ_DEFAULT_PASS" , self .password )
50
45
51
46
@wait_container_is_ready (pika .exceptions .IncompatibleProtocolError )
52
47
def readiness_probe (self ) -> bool :
@@ -63,12 +58,11 @@ def get_connection_params(self) -> pika.ConnectionParameters:
63
58
For more details see:
64
59
https://pika.readthedocs.io/en/latest/modules/parameters.html
65
60
"""
66
- credentials = pika .PlainCredentials (username = self .RABBITMQ_DEFAULT_USER ,
67
- password = self .RABBITMQ_DEFAULT_PASS )
61
+ credentials = pika .PlainCredentials (username = self .username , password = self .password )
68
62
69
63
return pika .ConnectionParameters (
70
64
host = self .get_container_host_ip (),
71
- port = self .get_exposed_port (self .RABBITMQ_NODE_PORT ),
65
+ port = self .get_exposed_port (self .port ),
72
66
credentials = credentials ,
73
67
)
74
68
0 commit comments