Skip to content

Commit 3ebc193

Browse files
authored
Merge pull request #7 from vcon-dev/allows-meta-into-parties-and-dialogs
Add support for 'meta' field in Dialog class and update tests
2 parents 5e371fd + f6b3f22 commit 3ebc193

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/vcon/dialog.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ def __init__(self,
4343
campaign: Optional[str] = None,
4444
interaction: Optional[str] = None,
4545
skill: Optional[str] = None,
46-
duration: Optional[float] = None) -> None:
46+
duration: Optional[float] = None,
47+
meta: Optional[dict] = None) -> None:
4748
"""
4849
Initialize a Dialog object.
4950
@@ -117,6 +118,7 @@ def __init__(self,
117118
self.interaction = interaction
118119
self.skill = skill
119120
self.duration = duration
121+
self.meta = meta
120122

121123
def to_dict(self):
122124
"""
@@ -157,7 +159,8 @@ def to_dict(self):
157159
"target_dialog": self.target_dialog,
158160
"campaign": self.campaign,
159161
"interaction": self.interaction,
160-
"skill": self.skill
162+
"skill": self.skill,
163+
"meta": self.meta
161164
}
162165
return {k: v for k, v in dialog_dict.items() if v is not None}
163166

tests/test_dialog.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,25 @@ def test_conversion_to_dict(self):
177177
assert dialog_dict["parties"] == [1, 2]
178178
assert dialog_dict["party_history"] == [{"party": 1, "event": "join", "time": party_time}]
179179

180-
# Successfully fetches external data from a valid URL
180+
181+
# Test the meta variable in the dialog
182+
def test_meta_variable_in_dialog(self):
183+
from datetime import datetime
184+
from src.vcon.dialog import Dialog
185+
186+
type = "audio"
187+
start = datetime.now()
188+
parties = [1, 2]
189+
meta = {"key": "value"}
190+
191+
dialog = Dialog(type=type, start=start, parties=parties, meta=meta)
192+
193+
assert dialog.type == type
194+
assert dialog.start == start
195+
assert dialog.parties == parties
196+
assert dialog.meta == meta
197+
198+
# Successfully fetches external data from a valid URL
181199
def test_fetch_external_data_success(self, mocker):
182200
# Arrange
183201
dialog = Dialog(type="text", start="2023-06-01T10:00:00Z", parties=[0])
@@ -308,4 +326,4 @@ def test_encoding_base64url(self):
308326
dialog.add_inline_data("example_body", "example_filename", "text/plain")
309327

310328
# Check if the encoding is set to "base64url"
311-
assert dialog.encoding == "base64url"
329+
assert dialog.encoding == "base64url"

0 commit comments

Comments
 (0)