def test_entity_mutation_dict() -> None: """ This piece of code is run by DucklingParser when the Duckling API returns a set of entities. There are a few keys added/removed. We are making sure of those for numerical entities here. """ entities_json = config.mock_number_entity parser = DucklingParser(locale="en_IN") entity = parser.mutate_entity(entities_json) assert "range" in entity assert "start" in entity["range"] assert "end" in entity["range"] assert "values" in entity assert entity["values"][0]["value"] == 4
def test_entity_mutation_list() -> None: """ This piece of code is run by DucklingParser when the Duckling API returns a set of entities. There are a few keys added/removed. We are making sure of those for time entities here. """ entity_json = { "body": "at 5 am", "start": 55, "value": { "values": [ { "value": "2021-01-21T05:00:00.000+05:30", "grain": "hour", "type": "value", }, { "value": "2021-01-22T05:00:00.000+05:30", "grain": "hour", "type": "value", }, { "value": "2021-01-23T05:00:00.000+05:30", "grain": "hour", "type": "value", }, ], "value": "2021-01-21T05:00:00.000+05:30", "grain": "hour", "type": "value", }, "end": 62, "dim": "time", "latent": False, } parser = DucklingParser(locale="en_IN") entity = parser.mutate_entity(entity_json) assert "range" in entity assert "start" in entity["range"] assert "end" in entity["range"] assert "values" in entity assert "value" not in entity assert entity["values"][0]["value"] == "2021-01-21T05:00:00.000+05:30"