diff --git a/modules/cassandra/testcontainers/cassandra/__init__.py b/modules/cassandra/testcontainers/cassandra/__init__.py index 696a0542..a5dd03b5 100644 --- a/modules/cassandra/testcontainers/cassandra/__init__.py +++ b/modules/cassandra/testcontainers/cassandra/__init__.py @@ -20,28 +20,27 @@ class CassandraContainer(DockerContainer): ... "CREATE KEYSPACE keyspace1 WITH replication = " ... "{'class': 'SimpleStrategy', 'replication_factor': '1'};") """ - def __init__(self, image="rinscy/cassandra:latest", ports_to_expose=[9042]): - super(CassandraContainer, self).__init__(image) + + def __init__(self, image="rinscy/cassandra:latest", ports_to_expose=(9042,)): + super().__init__(image) self.ports_to_expose = ports_to_expose self.with_exposed_ports(*self.ports_to_expose) @wait_container_is_ready() def _connect(self): - wait_for_logs( - self, - predicate="Starting listening for CQL clients", - timeout=MAX_TRIES) + wait_for_logs(self, predicate="Starting listening for CQL clients", timeout=MAX_TRIES) cluster = self.get_cluster() cluster.connect() def start(self): - super(CassandraContainer, self).start() + super().start() self._connect() return self def get_cluster(self, **kwargs): from cassandra.cluster import Cluster + container = self.get_wrapped_container() container.reload() - hostname = container.attrs['NetworkSettings']['IPAddress'] + hostname = container.attrs["NetworkSettings"]["IPAddress"] return Cluster(contact_points=[hostname], **kwargs) diff --git a/modules/cassandra/tests/test_cassandra.py b/modules/cassandra/tests/test_cassandra.py index bf2aca01..812791ba 100644 --- a/modules/cassandra/tests/test_cassandra.py +++ b/modules/cassandra/tests/test_cassandra.py @@ -7,9 +7,9 @@ def test_docker_run_cassandra(): with cluster.connect() as session: session.execute( "CREATE KEYSPACE keyspace1 WITH replication = " - "{'class': 'SimpleStrategy', 'replication_factor': '1'};") - session.execute( - "CREATE TABLE keyspace1.table1 (key1 int, key2 int, PRIMARY KEY (key1));") + "{'class': 'SimpleStrategy', 'replication_factor': '1'};" + ) + session.execute("CREATE TABLE keyspace1.table1 (key1 int, key2 int, PRIMARY KEY (key1));") session.execute("INSERT INTO keyspace1.table1 (key1,key2) values (1,2);") response = session.execute("SELECT * FROM keyspace1.table1") diff --git a/modules/scylla/testcontainers/scylla/__init__.py b/modules/scylla/testcontainers/scylla/__init__.py index f3e9c9cc..ca0f44af 100644 --- a/modules/scylla/testcontainers/scylla/__init__.py +++ b/modules/scylla/testcontainers/scylla/__init__.py @@ -20,29 +20,28 @@ class ScyllaContainer(DockerContainer): ... "CREATE KEYSPACE keyspace1 WITH replication " ... "= {'class': 'SimpleStrategy', 'replication_factor': '1'};") """ - def __init__(self, image="scylladb/scylla:latest", ports_to_expose=[9042]): - super(ScyllaContainer, self).__init__(image) + + def __init__(self, image="scylladb/scylla:latest", ports_to_expose=(9042,)): + super().__init__(image) self.ports_to_expose = ports_to_expose self.with_exposed_ports(*self.ports_to_expose) self.with_command("--skip-wait-for-gossip-to-settle=0") @wait_container_is_ready() def _connect(self): - wait_for_logs( - self, - predicate="Starting listening for CQL clients", - timeout=MAX_TRIES) + wait_for_logs(self, predicate="Starting listening for CQL clients", timeout=MAX_TRIES) cluster = self.get_cluster() cluster.connect() def start(self): - super(ScyllaContainer, self).start() + super().start() self._connect() return self def get_cluster(self, **kwargs): from cassandra.cluster import Cluster + container = self.get_wrapped_container() container.reload() - hostname = container.attrs['NetworkSettings']['IPAddress'] + hostname = container.attrs["NetworkSettings"]["IPAddress"] return Cluster(contact_points=[hostname], **kwargs) diff --git a/modules/scylla/tests/test_scylla.py b/modules/scylla/tests/test_scylla.py index a8515e93..3d1ecf44 100644 --- a/modules/scylla/tests/test_scylla.py +++ b/modules/scylla/tests/test_scylla.py @@ -7,9 +7,9 @@ def test_docker_run_scylla(): with cluster.connect() as session: session.execute( "CREATE KEYSPACE keyspace1 WITH replication = " - "{'class': 'SimpleStrategy', 'replication_factor': '1'};") - session.execute( - "CREATE TABLE keyspace1.table1 (key1 int, key2 int, PRIMARY KEY (key1));") + "{'class': 'SimpleStrategy', 'replication_factor': '1'};" + ) + session.execute("CREATE TABLE keyspace1.table1 (key1 int, key2 int, PRIMARY KEY (key1));") session.execute("INSERT INTO keyspace1.table1 (key1,key2) values (1,2);") response = session.execute("SELECT * FROM keyspace1.table1")