Skip to content
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

fix(Kafka backend): use enum values when represent kafka backend as d… #131

Merged
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
1 change: 1 addition & 0 deletions kstreams/backends/kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class Kafka(BaseModel):

class Config:
arbitrary_types_allowed = True
use_enum_values = True

@root_validator
def protocols_validation(cls, values):
Expand Down
18 changes: 18 additions & 0 deletions tests/test_backend_kafka.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,21 @@ def test_sasl_ssl_fail_missing_ssl_context():
sasl_plain_password=password,
)
assert "ssl_context" in str(e.value.args[0])


def test_backend_to_dict():
kafka_backend = Kafka(
security_protocol=SecurityProtocol.SASL_PLAINTEXT,
sasl_plain_username="username",
sasl_plain_password="pwd",
)
assert kafka_backend.security_protocol == SecurityProtocol.SASL_PLAINTEXT
assert kafka_backend.dict() == {
"bootstrap_servers": ["localhost:9092"],
"security_protocol": "SASL_PLAINTEXT",
"ssl_context": None,
"sasl_mechanism": "PLAIN",
"sasl_plain_username": "username",
"sasl_plain_password": "pwd",
"sasl_oauth_token_provider": None,
}