diff options
author | Niklas Mollenhauer <nikeee@users.noreply.github.com> | 2017-10-07 23:43:29 +0200 |
---|---|---|
committer | Dana Powers <dana.powers@gmail.com> | 2017-10-07 14:43:29 -0700 |
commit | 30ba2c1dbd22eff5f202bbbf2ecd8b42d242b1b0 (patch) | |
tree | 5d48f4cb00bb90c90e72871aa2ece81049070ba2 /test | |
parent | f12ff950ad2131f1bd6f5fc6bf8afc6ecd5d6628 (diff) | |
download | kafka-python-30ba2c1dbd22eff5f202bbbf2ecd8b42d242b1b0.tar.gz |
Add method to ensure a valid topic name (#1238)
Diffstat (limited to 'test')
-rw-r--r-- | test/test_substription_state.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/test_substription_state.py b/test/test_substription_state.py new file mode 100644 index 0000000..9718f6a --- /dev/null +++ b/test/test_substription_state.py @@ -0,0 +1,25 @@ +# pylint: skip-file +from __future__ import absolute_import + +import pytest + +from kafka.consumer.subscription_state import SubscriptionState + +@pytest.mark.parametrize(('topic_name', 'expectation'), [ + (0, pytest.raises(TypeError)), + (None, pytest.raises(TypeError)), + ('', pytest.raises(ValueError)), + ('.', pytest.raises(ValueError)), + ('..', pytest.raises(ValueError)), + ('a' * 250, pytest.raises(ValueError)), + ('abc/123', pytest.raises(ValueError)), + ('/abc/123', pytest.raises(ValueError)), + ('/abc123', pytest.raises(ValueError)), + ('name with space', pytest.raises(ValueError)), + ('name*with*stars', pytest.raises(ValueError)), + ('name+with+plus', pytest.raises(ValueError)), +]) +def test_topic_name_validation(topic_name, expectation): + state = SubscriptionState() + with expectation: + state._ensure_valid_topic_name(topic_name) |