Skip to content

Commit

Permalink
fix(Kafka backend): use enum values when represent kafka backend as d…
Browse files Browse the repository at this point in the history
…ict. Close #130 (#131)
  • Loading branch information
marcosschroh authored Sep 20, 2023
1 parent 6aaf016 commit af14c3f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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,
}

0 comments on commit af14c3f

Please sign in to comment.