Skip to content

Commit

Permalink
Update AudioEventsConfig to return empty dict as default (#98)
Browse files Browse the repository at this point in the history
* Update AudioEventsConfig to return empty dict as default when types not provided
  • Loading branch information
dumitrugutu authored May 14, 2024
1 parent 8eeeead commit 63ba444
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.14.8] - 2024-05-14

### Changed
- AudioEventsConfig class now defaults to empty dict instead of empty list when types not provided

## [1.14.7] - 2024-04-08

## Fixed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.14.7
1.14.8
4 changes: 2 additions & 2 deletions speechmatics/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,12 +220,12 @@ class AutoChaptersConfig:

@dataclass
class AudioEventsConfig:
types: Optional[List[str]]
types: Optional[List[str]] = None
"""Optional list of audio event types to detect."""

def asdict(self):
if self.types is None:
self.types = []
return {}
return asdict(self)


Expand Down
20 changes: 20 additions & 0 deletions tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,23 @@ def test_topic_detection_config(params, want):
def test_notification_config(params, want):
notification_config = models.NotificationConfig(**params)
assert asdict(notification_config) == want


@mark.parametrize(
"params, want",
[
param(
{"types": None},
{},
id="default params",
),
param(
{"types": ["music"]},
{"types": ["music"]},
id="set types param",
),
],
)
def test_audio_events_config_config(params, want):
audio_events_config = models.AudioEventsConfig(**params)
assert audio_events_config.asdict() == want

0 comments on commit 63ba444

Please sign in to comment.