Skip to content

Fixing spelling and minor whitespace issues in tests #1225

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion tests/integration/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def drop_keyspace_shutdown_cluster(keyspace_name, session, cluster):
try:
execute_with_long_wait_retry(session, "DROP KEYSPACE {0}".format(keyspace_name))
except:
log.warning("Error encountered when droping keyspace {0}".format(keyspace_name))
log.warning("Error encountered when dropping keyspace {0}".format(keyspace_name))
ex_type, ex, tb = sys.exc_info()
log.warning("{0}: {1} Backtrace: {2}".format(ex_type.__name__, ex, traceback.extract_tb(tb)))
del tb
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/advanced/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def use_singledc_wth_graph_and_spark(start=True):

def use_cluster_with_graph(num_nodes):
"""
This is a work around to account for the fact that spark nodes will conflict over master assignment
This is a workaround to account for the fact that spark nodes will conflict over master assignment
when started all at once.
"""
if USE_CASS_EXTERNAL:
Expand Down Expand Up @@ -125,7 +125,7 @@ def use_cluster_with_graph(num_nodes):

class BasicGeometricUnitTestCase(BasicKeyspaceUnitTestCase):
"""
This base test class is used by all the geomteric tests. It contains class level teardown and setup
This base test class is used by all the geometric tests. It contains class level teardown and setup
methods. It also contains the test fixtures used by those tests
"""

Expand Down
4 changes: 2 additions & 2 deletions tests/integration/advanced/graph/test_graph_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def _test_range_query(self, schema, graphson):
"""
Test to validate range queries are handled correctly.

Creates a very large line graph script and executes it. Then proceeds to to a range
Creates a very large line graph script and executes it. Then proceeds to a range
limited query against it, and ensure that the results are formatted correctly and that
the result set is properly sized.

Expand Down Expand Up @@ -331,7 +331,7 @@ def _test_large_create_script(self, schema, graphson):
@test_category dse graph
"""
self.execute_graph(schema.fixtures.line(150), graphson)
self.execute_graph(schema.fixtures.line(300), graphson) # This should passed since the queries are splitted
self.execute_graph(schema.fixtures.line(300), graphson) # This should pass since the queries are split
self.assertRaises(SyntaxException, self.execute_graph, schema.fixtures.line(300, single_script=True), graphson) # this is not and too big

def _test_large_result_set(self, schema, graphson):
Expand Down
6 changes: 3 additions & 3 deletions tests/integration/advanced/test_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class BasicDseAuthTest(unittest.TestCase):
@classmethod
def setUpClass(self):
"""
This will setup the necessary infrastructure to run our authentication tests. It requres the ADS_HOME environment variable
This will setup the necessary infrastructure to run our authentication tests. It requires the ADS_HOME environment variable
and our custom embedded apache directory server jar in order to run.
"""
if not DSE_VERSION:
Expand All @@ -86,7 +86,7 @@ def setUpClass(self):
self.charlie_keytab = os.path.join(self.conf_file_dir, "charlie.keytab")
actual_jar = os.path.join(ADS_HOME, "embedded-ads.jar")

# Create configuration directories if they don't already exists
# Create configuration directories if they don't already exist
if not os.path.exists(self.conf_file_dir):
os.makedirs(self.conf_file_dir)
if not os.path.exists(actual_jar):
Expand Down Expand Up @@ -175,7 +175,7 @@ def test_should_not_authenticate_with_bad_user_ticket(self):
auth_provider = DSEGSSAPIAuthProvider(service='dse', qops=["auth"])
self.assertRaises(NoHostAvailable, self.connect_and_query, auth_provider)

def test_should_not_athenticate_without_ticket(self):
def test_should_not_authenticate_without_ticket(self):
"""
This tests will attempt to authenticate with a user that is valid but has no ticket
@since 3.20
Expand Down
10 changes: 5 additions & 5 deletions tests/integration/advanced/test_cont_paging.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ def create_cluster(cls):

cls.select_all_statement = "SELECT * FROM {0}.{0}".format(cls.ks_name)

def test_continous_paging(self):
def test_continuous_paging(self):
"""
Test to ensure that various continuous paging schemes return the full set of results.
@since 3.20
@jira_ticket PYTHON-615
@expected_result various continous paging options should fetch all the results
@expected_result various continuous paging options should fetch all the results

@test_category queries
"""
Expand Down Expand Up @@ -131,9 +131,9 @@ def test_paging_cancel(self):
self.session_with_profiles.default_fetch_size = 1
# This combination should fetch one result a second. We should see a very few results
results = self.session_with_profiles.execute_async(self.select_all_statement, execution_profile= "SLOW")
result_set =results.result()
result_set = results.result()
result_set.cancel_continuous_paging()
result_lst =list(result_set)
result_lst = list(result_set)
self.assertLess(len(result_lst), 2, "Cancel should have aborted fetch immediately")

def test_con_paging_verify_writes(self):
Expand Down Expand Up @@ -183,7 +183,7 @@ def test_con_paging_verify_writes(self):

def test_can_get_results_when_no_more_pages(self):
"""
Test to validate that the resutls can be fetched when
Test to validate that the results can be fetched when
has_more_pages is False
@since 3.20
@jira_ticket PYTHON-946
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/advanced/test_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class AbstractGeometricTypeTest():

def test_should_insert_simple(self):
"""
This tests will attempt to insert a point, polygon, or line, using simple inline formating.
This tests will attempt to insert a point, polygon, or line, using simple inline formatting.
@since 3.20
@jira_ticket PYTHON-456
@test_category dse geometric
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/advanced/test_spark.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def setup_module():
@requiredse
class SparkLBTests(BasicGraphUnitTestCase):
"""
Test to validate that analtics query can run in a multi-node enviroment. Also check to to ensure
Test to validate that analytics query can run in a multi-node environment. Also check to ensure
that the master spark node is correctly targeted when OLAP queries are run

@since 3.20
Expand All @@ -42,7 +42,7 @@ def test_spark_analytic_query(self):
self.session.execute_graph(ClassicGraphFixtures.classic())
spark_master = find_spark_master(self.session)

# Run multipltle times to ensure we don't round robin
# Run multiple times to ensure we don't round-robin
for i in range(3):
to_run = SimpleGraphStatement("g.V().count()")
rs = self.session.execute_graph(to_run, execution_profile=EXEC_PROFILE_GRAPH_ANALYTICS_DEFAULT)
Expand Down
3 changes: 2 additions & 1 deletion tests/integration/cloud/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from tests.integration.cloud import setup_package, teardown_package


@pytest.fixture(scope='session', autouse=True)
def setup_and_teardown_packages():
setup_package()
yield
teardown_package()
teardown_package()
4 changes: 2 additions & 2 deletions tests/integration/cloud/test_cloud_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ def test_for_schema_disagreement_attribute(self):
self.check_and_wait_for_agreement(session, rs, True)
cluster.shutdown()

def check_and_wait_for_agreement(self, session, rs, exepected):
def check_and_wait_for_agreement(self, session, rs, expected):
# Wait for RESULT_KIND_SCHEMA_CHANGE message to arrive
time.sleep(1)
self.assertEqual(rs.response_future.is_schema_agreed, exepected)
self.assertEqual(rs.response_future.is_schema_agreed, expected)
if not rs.response_future.is_schema_agreed:
session.cluster.control_connection.wait_for_schema_agreement(wait_time=1000)
3 changes: 2 additions & 1 deletion tests/integration/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

from tests.integration import teardown_package


@pytest.fixture(scope='session', autouse=True)
def setup_and_teardown_packages():
print('setup')
yield
teardown_package()
teardown_package()
4 changes: 2 additions & 2 deletions tests/integration/cqlengine/test_connections.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def test_context_connection_priority(self):
"""
Tests to ensure the proper connection priority is honored.

Explicit connection should have higest priority,
Explicit connection should have the highest priority,
Followed by context query connection
Default connection should be honored last.

Expand Down Expand Up @@ -458,7 +458,7 @@ def test_keyspace(self):

@since 3.7
@jira_ticket PYTHON-613
@expected_result Keyspace segration is honored
@expected_result Keyspace segregation is honored

@test_category object_mapper
"""
Expand Down
13 changes: 6 additions & 7 deletions tests/integration/cqlengine/test_ifexists.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def test_update_if_exists(self):
m = TestIfExistsModel.get(id=id)
self.assertEqual(m.text, 'changed_again')

m = TestIfExistsModel(id=uuid4(), count=44) # do not exists
m = TestIfExistsModel(id=uuid4(), count=44) # do not exist
with self.assertRaises(LWTException) as assertion:
m.if_exists().update()

Expand Down Expand Up @@ -155,7 +155,7 @@ def test_batch_update_if_exists_success(self):
@unittest.skipUnless(PROTOCOL_VERSION >= 2, "only runs against the cql3 protocol v2.0")
def test_batch_mixed_update_if_exists_success(self):
"""
Tests that batch update with with one bad query will still fail with LWTException
Tests that batch update with one bad query will still fail with LWTException

@since 3.1
@jira_ticket PYTHON-432
Expand All @@ -177,7 +177,7 @@ def test_batch_mixed_update_if_exists_success(self):
@unittest.skipUnless(PROTOCOL_VERSION >= 2, "only runs against the cql3 protocol v2.0")
def test_delete_if_exists(self):
"""
Tests that delete with if_exists work, and throw proper LWT exception when they are are not applied
Tests that delete with if_exists work, and throws proper LWT exception when they are not applied

@since 3.1
@jira_ticket PYTHON-432
Expand All @@ -193,7 +193,7 @@ def test_delete_if_exists(self):
q = TestIfExistsModel.objects(id=id)
self.assertEqual(len(q), 0)

m = TestIfExistsModel(id=uuid4(), count=44) # do not exists
m = TestIfExistsModel(id=uuid4(), count=44) # do not exist
with self.assertRaises(LWTException) as assertion:
m.if_exists().delete()

Expand All @@ -212,7 +212,7 @@ def test_delete_if_exists(self):
@unittest.skipUnless(PROTOCOL_VERSION >= 2, "only runs against the cql3 protocol v2.0")
def test_batch_delete_if_exists_success(self):
"""
Tests that batch deletes with if_exists work, and throw proper LWTException when they are are not applied
Tests that batch deletes with if_exists work, and throws proper LWTException when they are not applied

@since 3.1
@jira_ticket PYTHON-432
Expand Down Expand Up @@ -243,7 +243,7 @@ def test_batch_delete_if_exists_success(self):
@unittest.skipUnless(PROTOCOL_VERSION >= 2, "only runs against the cql3 protocol v2.0")
def test_batch_delete_mixed(self):
"""
Tests that batch deletes with multiple queries and throw proper LWTException when they are are not all applicable
Tests that batch deletes with multiple queries and throws proper LWTException when they are not all applicable

@since 3.1
@jira_ticket PYTHON-432
Expand Down Expand Up @@ -309,4 +309,3 @@ def test_instance_raise_exception(self):
id = uuid4()
with self.assertRaises(IfExistsWithCounterColumn):
TestIfExistsWithCounterModel.if_exists()

1 change: 0 additions & 1 deletion tests/integration/cqlengine/test_ifnotexists.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,4 +198,3 @@ def test_instance_raise_exception(self):
id = uuid4()
with self.assertRaises(IfNotExistsWithCounterColumn):
TestIfNotExistsWithCounterModel.if_not_exists()

1 change: 0 additions & 1 deletion tests/integration/cqlengine/test_lwt_conditional.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ def test_batch_update_conditional_several_rows(self):
second_row.delete()
b.execute()


def test_delete_conditional(self):
# DML path
t = TestConditionalModel.if_not_exists().create(text='something', count=5)
Expand Down
4 changes: 1 addition & 3 deletions tests/integration/cqlengine/test_timestamp.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,7 @@ def test_delete_in_the_past(self):

TestTimestampModel.get(id=uid).should.be.ok

# delete the in past, should not affect the object created above
# delete in the past, should not affect the object created above
TestTimestampModel.objects(id=uid).timestamp(timedelta(seconds=-60)).delete()

TestTimestampModel.get(id=uid)


6 changes: 3 additions & 3 deletions tests/integration/cqlengine/test_ttl.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_default_ttl_not_set(self):
self.assertEqual(default_ttl, 0)

with mock.patch.object(session, 'execute') as m:
TestTTLModel.objects(id=tid).update(text="aligators")
TestTTLModel.objects(id=tid).update(text="alligators")

query = m.call_args[0][0].query_string
self.assertNotIn("USING TTL", query)
Expand All @@ -197,7 +197,7 @@ def test_default_ttl_set(self):
self.assertEqual(default_ttl, 20)

with mock.patch.object(session, 'execute') as m:
TestTTLModel.objects(id=tid).update(text="aligators expired")
TestTTLModel.objects(id=tid).update(text="alligators expired")

# Should not be set either
query = m.call_args[0][0].query_string
Expand Down Expand Up @@ -228,7 +228,7 @@ def test_override_default_ttl(self):
self.assertEqual(o._ttl, 3600)

with mock.patch.object(session, 'execute') as m:
TestDefaultTTLModel.objects(id=tid).ttl(None).update(text="aligators expired")
TestDefaultTTLModel.objects(id=tid).ttl(None).update(text="alligators expired")

query = m.call_args[0][0].query_string
self.assertNotIn("USING TTL", query)
22 changes: 12 additions & 10 deletions tests/integration/standard/column_encryption/test_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@
from cassandra.column_encryption.policies import AES256ColumnEncryptionPolicy, \
AES256_KEY_SIZE_BYTES, AES256_BLOCK_SIZE_BYTES


def setup_module():
use_singledc()


class ColumnEncryptionPolicyTest(unittest.TestCase):

def _recreate_keyspace(self, session):
Expand Down Expand Up @@ -57,13 +59,13 @@ def test_end_to_end_prepared(self):

# A straight select from the database will now return the decrypted bits. We select both encrypted and unencrypted
# values here to confirm that we don't interfere with regular processing of unencrypted vals.
(encrypted,unencrypted) = session.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
(encrypted, unencrypted) = session.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
self.assertEqual(expected, encrypted)
self.assertEqual(expected, unencrypted)

# Confirm the same behaviour from a subsequent prepared statement as well
prepared = session.prepare("select encrypted, unencrypted from foo.bar where unencrypted = ? allow filtering")
(encrypted,unencrypted) = session.execute(prepared, [expected]).one()
(encrypted, unencrypted) = session.execute(prepared, [expected]).one()
self.assertEqual(expected, encrypted)
self.assertEqual(expected, unencrypted)

Expand All @@ -78,20 +80,20 @@ def test_end_to_end_simple(self):
self._recreate_keyspace(session)

# Use encode_and_encrypt helper function to populate date
for i in range(1,100):
for i in range(1, 100):
self.assertIsNotNone(i)
encrypted = cl_policy.encode_and_encrypt(col_desc, i)
session.execute("insert into foo.bar (encrypted, unencrypted) values (%s,%s)", (encrypted, i))

# A straight select from the database will now return the decrypted bits. We select both encrypted and unencrypted
# values here to confirm that we don't interfere with regular processing of unencrypted vals.
(encrypted,unencrypted) = session.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
(encrypted, unencrypted) = session.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
self.assertEqual(expected, encrypted)
self.assertEqual(expected, unencrypted)

# Confirm the same behaviour from a subsequent prepared statement as well
prepared = session.prepare("select encrypted, unencrypted from foo.bar where unencrypted = ? allow filtering")
(encrypted,unencrypted) = session.execute(prepared, [expected]).one()
(encrypted, unencrypted) = session.execute(prepared, [expected]).one()
self.assertEqual(expected, encrypted)
self.assertEqual(expected, unencrypted)

Expand All @@ -117,7 +119,7 @@ def test_end_to_end_different_cle_contexts_different_ivs(self):
self._recreate_keyspace(session1)

# Use encode_and_encrypt helper function to populate date
for i in range(1,100):
for i in range(1, 100):
self.assertIsNotNone(i)
encrypted = cl_policy1.encode_and_encrypt(col_desc1, i)
session1.execute("insert into foo.bar (encrypted, unencrypted) values (%s,%s)", (encrypted, i))
Expand All @@ -134,7 +136,7 @@ def test_end_to_end_different_cle_contexts_different_ivs(self):
(_, cl_policy2) = self._create_policy(key, iv=iv2)
cluster2 = TestCluster(column_encryption_policy=cl_policy2)
session2 = cluster2.connect()
(encrypted,unencrypted) = session2.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
(encrypted, unencrypted) = session2.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
self.assertEqual(expected, encrypted)
self.assertEqual(expected, unencrypted)

Expand All @@ -152,19 +154,19 @@ def test_end_to_end_different_cle_contexts_different_policies(self):
self._recreate_keyspace(session)

# Use encode_and_encrypt helper function to populate date
session.execute("insert into foo.bar (encrypted, unencrypted) values (%s,%s)",(cl_policy.encode_and_encrypt(col_desc, expected), expected))
session.execute("insert into foo.bar (encrypted, unencrypted) values (%s,%s)", (cl_policy.encode_and_encrypt(col_desc, expected), expected))

# We now open a new session _without_ the CLE policy specified. We should _not_ be able to read decrypted bits from this session.
cluster2 = TestCluster()
session2 = cluster2.connect()

# A straight select from the database will now return the decrypted bits. We select both encrypted and unencrypted
# values here to confirm that we don't interfere with regular processing of unencrypted vals.
(encrypted,unencrypted) = session2.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
(encrypted, unencrypted) = session2.execute("select encrypted, unencrypted from foo.bar where unencrypted = %s allow filtering", (expected,)).one()
self.assertEqual(cl_policy.encode_and_encrypt(col_desc, expected), encrypted)
self.assertEqual(expected, unencrypted)

# Confirm the same behaviour from a subsequent prepared statement as well
prepared = session2.prepare("select encrypted, unencrypted from foo.bar where unencrypted = ? allow filtering")
(encrypted,unencrypted) = session2.execute(prepared, [expected]).one()
(encrypted, unencrypted) = session2.execute(prepared, [expected]).one()
self.assertEqual(cl_policy.encode_and_encrypt(col_desc, expected), encrypted)
Loading