Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderankin committed Mar 14, 2024
1 parent 550036d commit 1114f4d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 22 deletions.
15 changes: 7 additions & 8 deletions modules/cassandra/testcontainers/cassandra/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions modules/cassandra/tests/test_cassandra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 7 additions & 8 deletions modules/scylla/testcontainers/scylla/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
6 changes: 3 additions & 3 deletions modules/scylla/tests/test_scylla.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 1114f4d

Please sign in to comment.