12
12
# under the License.
13
13
import os
14
14
import socket
15
- from typing import Iterable , Optional
15
+ from typing import Optional
16
16
17
17
from testcontainers .core .container import DockerContainer
18
+ from testcontainers .core .utils import raise_for_deprecated_parameter
18
19
from testcontainers .core .waiting_utils import wait_container_is_ready
19
20
20
21
21
22
class AzuriteContainer (DockerContainer ):
22
23
"""
23
- The example below spins up an Azurite container and
24
- shows an example to create a Blob service client with the container. The method
25
- :code:`get_connection_string` can be used to create a client for Blob service, Queue service
26
- and Table service.
24
+ The example below spins up an Azurite container and
25
+ shows an example to create a Blob service client with the container. The method
26
+ :code:`get_connection_string` can be used to create a client for Blob service, Queue service
27
+ and Table service.
27
28
28
- Example:
29
+ Example:
29
30
30
- .. doctest::
31
+ .. doctest::
31
32
32
- >>> from testcontainers.azurite import AzuriteContainer
33
- >>> from azure.storage.blob import BlobServiceClient
33
+ >>> from testcontainers.azurite import AzuriteContainer
34
+ >>> from azure.storage.blob import BlobServiceClient
34
35
35
- >>> with AzuriteContainer() as azurite_container:
36
- ... connection_string = azurite_container.get_connection_string()
37
- ... client = BlobServiceClient.from_connection_string(
38
- ... connection_string,
39
- ... api_version="2019-12-12"
40
- ... )
41
- """
36
+ >>> with AzuriteContainer() as azurite_container:
37
+ ... connection_string = azurite_container.get_connection_string()
38
+ ... client = BlobServiceClient.from_connection_string(
39
+ ... connection_string,
40
+ ... api_version="2019-12-12"
41
+ ... )
42
+ """
42
43
def __init__ (self , image : str = "mcr.microsoft.com/azure-storage/azurite:latest" , * ,
43
- ports_to_expose : Optional [ Iterable [ int ]] = None , blob_service_port : int = 10_000 ,
44
- queue_service_port : int = 10_001 , table_service_port : int = 10_002 ,
45
- account_name : Optional [ str ] = None , account_key : Optional [str ] = None , ** kwargs ) \
44
+ blob_service_port : int = 10_000 , queue_service_port : int = 10_001 ,
45
+ table_service_port : int = 10_002 , account_name : Optional [ str ] = None ,
46
+ account_key : Optional [str ] = None , ** kwargs ) \
46
47
-> None :
47
48
""" Constructs an AzuriteContainer.
48
49
49
50
Args:
50
51
image: Expects an image with tag.
51
- ports_to_expose: List with port numbers to expose.
52
52
**kwargs: Keyword arguments passed to super class.
53
53
"""
54
54
super ().__init__ (image = image , ** kwargs )
@@ -58,13 +58,12 @@ def __init__(self, image: str = "mcr.microsoft.com/azure-storage/azurite:latest"
58
58
"AZURITE_ACCOUNT_KEY" , "Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/"
59
59
"K1SZFPTOtr/KBHBeksoGMGw==" )
60
60
61
+ raise_for_deprecated_parameter (kwargs , "ports_to_expose" , "container.with_exposed_ports" )
61
62
self .blob_service_port = blob_service_port
62
63
self .queue_service_port = queue_service_port
63
64
self .table_service_port = table_service_port
64
- if not ports_to_expose :
65
- ports_to_expose = [blob_service_port , queue_service_port , table_service_port ]
66
65
67
- self .with_exposed_ports (* ports_to_expose )
66
+ self .with_exposed_ports (* blob_service_port , queue_service_port , table_service_port )
68
67
self .with_env ("AZURITE_ACCOUNTS" , f"{ self .account_name } :{ self .account_key } " )
69
68
70
69
def get_connection_string (self ) -> str :
0 commit comments