Skip to content

Commit bd6a15a

Browse files
committed
some updates
1 parent 6488e17 commit bd6a15a

File tree

1 file changed

+35
-19
lines changed

1 file changed

+35
-19
lines changed

Diff for: testcontainers/iris/__init__.py

+35-19
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import os
22
from typing import Optional
33
from testcontainers.core.generic import DbContainer
4+
45
# from testcontainers.core.utils import raise_for_deprecated_parameter
56
from testcontainers.core.waiting_utils import wait_for_logs
67

8+
79
class IRISContainer(DbContainer):
810
"""
911
InterSystems IRIS database container.
@@ -27,15 +29,18 @@ class IRISContainer(DbContainer):
2729
>>> version
2830
'IRIS for UNIX (Ubuntu Server LTS for ARM64 Containers) 2023.2 (Build 227U) Mon Jul 31 2023 17:43:25 EDT'
2931
"""
30-
def __init__(self, image: str = "intersystemsdc/iris-community:latest",
31-
port: int = 1972,
32-
username: Optional[str] = None,
33-
password: Optional[str] = None,
34-
namespace: Optional[str] = None,
35-
driver: str = "iris",
36-
license_key: str = None,
37-
**kwargs
38-
) -> None:
32+
33+
def __init__(
34+
self,
35+
image: str = "intersystemsdc/iris-community:latest",
36+
port: int = 1972,
37+
username: Optional[str] = None,
38+
password: Optional[str] = None,
39+
namespace: Optional[str] = None,
40+
driver: str = "iris",
41+
license_key: str = None,
42+
**kwargs,
43+
) -> None:
3944
# raise_for_deprecated_parameter(kwargs, "user", "username")
4045
super(IRISContainer, self).__init__(image=image, **kwargs)
4146
self.image = image
@@ -53,28 +58,39 @@ def _configure(self) -> None:
5358
self.with_env("IRIS_PASSWORD", self.password)
5459
self.with_env("IRIS_NAMESPACE", self.namespace)
5560
if self.license_key:
56-
self.with_volume_mapping(self.license_key, "/usr/irissys/mgr/iris.key", "ro")
61+
self.with_volume_mapping(
62+
self.license_key, "/usr/irissys/mgr/iris.key", "ro"
63+
)
64+
5765
def _connect(self) -> None:
5866
wait_for_logs(self, predicate="Enabling logons")
5967
if self.image.startswith("intersystemsdc"):
6068
wait_for_logs(self, predicate="executed command")
6169
else:
6270
if self.namespace.upper() != "USER":
63-
cmd = f"iris session iris -U %%SYS '##class(%%SQL.Statement).%%ExecDirect(,\"CREATE DATABASE %s\")'" % (
64-
self.namespace,
71+
cmd = (
72+
f"iris session iris -U %%SYS '##class(%%SQL.Statement).%%ExecDirect(,\"CREATE DATABASE %s\")'"
73+
% (self.namespace,)
6574
)
6675
self.exec(cmd)
67-
cmd = f"iris session iris -U %%SYS '##class(Security.Users).Create(\"%s\",\"%s\",\"%s\",,\"%s\")'" % (
68-
self.username,
69-
"%ALL",
70-
self.password,
71-
self.namespace,
76+
cmd = (
77+
f'iris session iris -U %%SYS \'##class(Security.Users).Create("%s","%s","%s",,"%s")\''
78+
% (
79+
self.username,
80+
"%ALL",
81+
self.password,
82+
self.namespace,
83+
)
7284
)
7385
res = self.exec(cmd)
86+
print("res", cmd, res)
7487

7588
def get_connection_url(self, host=None) -> str:
7689
return super()._create_connection_url(
77-
dialect=f"iris", username=self.username,
78-
password=self.password, db_name=self.namespace, host=host,
90+
dialect="iris",
91+
username=self.username,
92+
password=self.password,
93+
db_name=self.namespace,
94+
host=host,
7995
port=self.port,
8096
)

0 commit comments

Comments
 (0)