From d92ceed19a3b32c0cbc89b7c507140ea53ff07cb Mon Sep 17 00:00:00 2001 From: Dario Mirovic Date: Mon, 8 Sep 2025 10:08:23 +0200 Subject: [PATCH] test: cqlpy: add test for create keyspace with no options specified This patch introduces one new test case. It tests that a keyspace can be created without specifying replication options. Since other options already had defaults, this test assures a keyspace can be created with no options specified at all, with the following query: `CREATE KEYSPACE ks;` Refs #25145 --- test/cqlpy/test_keyspace.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/test/cqlpy/test_keyspace.py b/test/cqlpy/test_keyspace.py index cf201f35e5..17456b4003 100644 --- a/test/cqlpy/test_keyspace.py +++ b/test/cqlpy/test_keyspace.py @@ -47,6 +47,13 @@ def test_create_and_drop_keyspace_with_default_replication_options(cql, this_dc) with new_test_keyspace(cql, "WITH REPLICATION = {}") as keyspace: assert_keyspace(cql, keyspace, "org.apache.cassandra.locator.NetworkTopologyStrategy", this_dc) +# The "WITH REPLICATION" part of CREATE KEYSPACE may be omitted. +# Trying to create a keyspace with no replication options at all +# should result in NetworkTopologyStrategy and replication factor of 1 being set by default. +def test_create_and_drop_keyspace_with_no_replication_options(cql, this_dc): + with new_test_keyspace(cql, "") as keyspace: + assert_keyspace(cql, keyspace, "org.apache.cassandra.locator.NetworkTopologyStrategy", this_dc) + # Trying to create the same keyspace - even if with identical parameters - # should result in an AlreadyExists error. def test_create_keyspace_twice(cql, this_dc): @@ -65,12 +72,6 @@ def test_create_keyspace_if_not_exists(cql, this_dc): cql.execute("CREATE KEYSPACE IF NOT EXISTS test_create_keyspace_if_not_exists WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 2 }") cql.execute("DROP KEYSPACE test_create_keyspace_if_not_exists") -# The "WITH REPLICATION" part of CREATE KEYSPACE may not be omitted - trying -# to do so should result in a syntax error: -def test_create_keyspace_missing_with(cql): - with pytest.raises(SyntaxException): - cql.execute("CREATE KEYSPACE test_create_and_drop_keyspace") - # The documentation states that "Keyspace names can have alpha- # numeric characters and contain underscores; only letters and numbers are # supported as the first character.". This is not accurate. Test what is actually