Skip to content

Commit a26f7eb

Browse files
authored
update exception messages for TopicConfigurationMismatch (#370)
1 parent 1b2048e commit a26f7eb

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

quixstreams/models/topics/manager.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,17 @@ def validate_all_topics(self, timeout: Optional[float] = None):
446446

447447
if changelog_cfg.num_partitions != source_cfg.num_partitions:
448448
raise TopicConfigurationMismatch(
449-
f'Invalid partition count for the topic "{source_name}": '
449+
f'changelog topic "{changelog.name}" partition count '
450+
f'does not match its source topic "{source_name}": '
450451
f"expected {source_cfg.num_partitions}, "
451-
f"got {changelog_cfg.num_partitions}"
452+
f'got {changelog_cfg.num_partitions}"'
452453
)
453454
if changelog_cfg.replication_factor != source_cfg.replication_factor:
454455
raise TopicConfigurationMismatch(
455-
f'Invalid replication factor for the topic "{source_name}": '
456+
f'changelog topic "{changelog.name}" replication factor '
457+
f'does not match its source topic "{source_name}": '
456458
f"expected {source_cfg.replication_factor}, "
457-
f"got {changelog_cfg.num_partitions}"
459+
f'got {changelog_cfg.replication_factor}"'
458460
)
459461

460462
logger.info(f"Kafka topics validation complete")

tests/test_quixstreams/test_models/test_topics/test_manager.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def test_validate_all_topics_changelog_partition_count_mismatch(
249249
),
250250
}
251251

252-
with pytest.raises(TopicConfigurationMismatch, match="Invalid partition count"):
252+
with pytest.raises(TopicConfigurationMismatch, match="partition count"):
253253
topic_manager.validate_all_topics()
254254

255255
def test_validate_all_topics_changelog_replication_factor_mismatch(
@@ -281,9 +281,7 @@ def test_validate_all_topics_changelog_replication_factor_mismatch(
281281
),
282282
}
283283

284-
with pytest.raises(
285-
TopicConfigurationMismatch, match="Invalid replication factor"
286-
):
284+
with pytest.raises(TopicConfigurationMismatch, match="replication factor"):
287285
topic_manager.validate_all_topics()
288286

289287
def test_topic_name_len_exceeded(self, topic_manager_factory):

0 commit comments

Comments
 (0)