Skip to content

Commit d11370f

Browse files
author
Mehdi BEN ABDALLAH
committed
move configuration steps to _configure
1 parent c0cc64f commit d11370f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

modules/cosmosdb/testcontainers/cosmosdb/__init__.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,11 @@ def __init__(
7171
**docker_client_kw,
7272
):
7373
super().__init__(image=image, **docker_client_kw)
74-
7574
self.partition_count = partition_count
7675
self.key = key
7776
self.enable_data_persistence = enable_data_persistence
7877
self.endpoints = frozenset(endpoints)
79-
80-
self.with_bind_ports(EMULATOR_PORT, EMULATOR_PORT)
81-
82-
endpoints_ports = []
83-
for endpoint in self.endpoints:
84-
endpoints_ports.extend(endpoint_ports[endpoint])
85-
86-
if bind_ports:
87-
[ self.with_bind_ports(port, port) for port in endpoints_ports ]
88-
else:
89-
self.with_exposed_ports(*endpoints_ports)
78+
self.bind_ports = bind_ports
9079

9180
def start(self) -> Self:
9281
self._configure()
@@ -122,6 +111,17 @@ def sync_client(self) -> SyncCosmosClient:
122111
return SyncCosmosClient(url=self.url, credential=self.key, connection_verify=False)
123112

124113
def _configure(self) -> None:
114+
self.with_bind_ports(EMULATOR_PORT, EMULATOR_PORT)
115+
116+
endpoints_ports = []
117+
for endpoint in self.endpoints:
118+
endpoints_ports.extend(endpoint_ports[endpoint])
119+
120+
if self.bind_ports:
121+
[ self.with_bind_ports(port, port) for port in endpoints_ports ]
122+
else:
123+
self.with_exposed_ports(*endpoints_ports)
124+
125125
(
126126
self
127127
.with_env("AZURE_COSMOS_EMULATOR_PARTITION_COUNT", str(self.partition_count))

0 commit comments

Comments
 (0)