test: specify exceptions being caught in guardrails_test.py

Before this commit, the test caught a broad `Exception`. This change
specifies the expected exceptions to avoid a situation where the product
or test is broken and it goes undetected.
This commit is contained in:
Andrzej Jackowski
2026-02-02 10:20:06 +01:00
parent 625f292417
commit 136db260ca

View File

@@ -8,6 +8,7 @@ import logging
import pytest
from cassandra.cluster import Session
from cassandra.protocol import ConfigurationException, InvalidRequest
from dtest_class import Tester
@@ -27,9 +28,9 @@ def create_ks_and_assert_warning(session, query, ks_name, key_warn_msg_words):
def assert_creating_ks_fails(session, query, ks_name):
with pytest.raises(Exception):
with pytest.raises(ConfigurationException):
session.execute(query)
with pytest.raises(Exception):
with pytest.raises(InvalidRequest):
session.execute(f"USE {ks_name}")