Skip to content

Commit

Permalink
fix: Reference time must be an Optional Parameter issue: #8 .
Browse files Browse the repository at this point in the history
  • Loading branch information
ltbringer committed Mar 10, 2021
1 parent c6e9ecd commit d7d8b39
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions dialogy/parser/text/entity/duckling_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def reshape(

# == get_entities ==
def get_entities(
self, text: str, reference_time: Optional[int]
self, text: str, reference_time: Optional[int] = None
) -> Optional[List[Dict[str, Any]]]:
"""
Get entities from duckling-server.
Expand Down Expand Up @@ -298,7 +298,7 @@ def plugin(self, workflow: Workflow) -> None:
if access and mutate:
try:
text, reference_time = access(workflow)
entities_json = self.get_entities(text, reference_time)
entities_json = self.get_entities(text, reference_time=reference_time)
if entities_json:
entities = self.reshape(entities_json)
mutate(workflow, entities)
Expand Down
8 changes: 4 additions & 4 deletions tests/parser/text/entity/test_duckling_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_duckling_api_success() -> None:

parser = DucklingParser(locale="en_IN")

response = parser.get_entities(body, None)
response = parser.get_entities(body)
assert response == expected_response


Expand All @@ -85,7 +85,7 @@ def test_duckling_api_failure() -> None:
parser = DucklingParser(dimensions=["time"], locale="en_IN")

with pytest.raises(ValueError):
parser.get_entities(body, None)
parser.get_entities(body)


# == Test duckling with timezone info ==
Expand All @@ -104,7 +104,7 @@ def test_duckling_with_tz() -> None:

parser = DucklingParser(locale="en_IN", timezone="Asia/Kolkata")

response = parser.get_entities(body, None)
response = parser.get_entities(body)
assert response == expected_response


Expand All @@ -123,7 +123,7 @@ def test_duckling_wrong_tz() -> None:
parser = DucklingParser(locale="en_IN", timezone="Earth/Someplace")

with pytest.raises(pytz.UnknownTimeZoneError):
response = parser.get_entities(body, None)
response = parser.get_entities(body)


# == Test entity structure modifications for numerical entities ==
Expand Down

0 comments on commit d7d8b39

Please sign in to comment.