@@ -36,31 +36,35 @@ class LocalStackContainer(DockerContainer):
36
36
scan_result = dynamo_client.scan(TableName='foo')
37
37
# Do something with the scan result
38
38
"""
39
- EDGE_PORT = 4566
40
- IMAGE = 'localstack/localstack:0.11.4'
41
-
42
- def __init__ (self , image = IMAGE , ** kwargs ):
39
+ def __init__ (self , image : str = 'localstack/localstack:0.11.4' , edge_port : int = 4566 ,
40
+ ** kwargs ) -> None :
43
41
super (LocalStackContainer , self ).__init__ (image , ** kwargs )
44
- self .with_exposed_ports (LocalStackContainer .EDGE_PORT )
42
+ self .edge_port = edge_port
43
+ self .with_exposed_ports (self .edge_port )
45
44
46
- def with_services (self , * services ):
45
+ def with_services (self , * services ) -> "LocalStackContainer" :
47
46
"""
48
47
Restrict what services to run. By default all localstack services are launched.
49
- :return: the DockerContainer to allow chaining of 'with_*' calls.
48
+
49
+ Args:
50
+ services: Sequency of services to launch.
51
+
52
+ Returns:
53
+ self: Container to allow chaining of 'with_*' calls.
50
54
"""
51
55
return self .with_env ('SERVICES' , ',' .join (services ))
52
56
53
- def get_url (self ):
57
+ def get_url (self ) -> str :
54
58
"""
55
59
Use this to call localstack instead of real AWS services.
56
60
ex: boto3.client('lambda', endpoint_url=localstack.get_url())
57
61
:return: the endpoint where localstack is reachable.
58
62
"""
59
63
host = self .get_container_host_ip ()
60
- port = self .get_exposed_port (LocalStackContainer . EDGE_PORT )
64
+ port = self .get_exposed_port (self . edge_port )
61
65
return 'http://{}:{}' .format (host , port )
62
66
63
- def start (self , timeout = 60 ):
67
+ def start (self , timeout : float = 60 ) -> "LocalStackContainer" :
64
68
super ().start ()
65
69
wait_for_logs (self , r'Ready\.\n' , timeout = timeout )
66
70
return self
0 commit comments