-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #246 from RasaHQ/form-to-loop-event-rename
support `ActiveLoop` event / deprecate `FormAction`
- Loading branch information
Showing
8 changed files
with
131 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Rasa Open Source 2.0 renamed the ``Form`` event to ``ActiveLoop``. The ``ActiveLoop`` | ||
event was added to the SDK and support for the ``active_loop`` field in JSON payloads | ||
was added. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Using the ``Form`` event is deprecated. Please use the new ``ActiveLoop`` event instead. | ||
Using the ``active_form`` property of the ``Tracker`` object is now deprecated. Please | ||
use the ``active_loop`` property instead. | ||
|
||
The usage of the ``FormAction`` is deprecated. Please see the migration guide | ||
for Rasa Open Source 2.0 for instructions how to migrate your `FormAction`s. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from typing import Dict | ||
|
||
import pytest | ||
|
||
from rasa_sdk.interfaces import Tracker | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"active_loop", | ||
[ | ||
{}, | ||
{"name": "some loop"}, | ||
{"name": "some loop", "validate": True}, | ||
{"name": "✏️", "rejected": False}, | ||
{ | ||
"name": "✏️", | ||
"validate": True, | ||
"trigger_message": {"intent": {}, "intent_ranking": []}, | ||
}, | ||
], | ||
) | ||
def test_tracker_active_loop_parsing(active_loop: Dict): | ||
state = {"events": [], "sender_id": "old", "active_loop": active_loop} | ||
tracker = Tracker.from_dict(state) | ||
|
||
assert tracker.active_loop == active_loop | ||
|
||
|
||
def test_deprecation_warning_active_form(): | ||
form = {"name": "my form"} | ||
state = {"events": [], "sender_id": "old", "active_loop": form} | ||
tracker = Tracker.from_dict(state) | ||
|
||
with pytest.warns(DeprecationWarning): | ||
assert tracker.active_form == form | ||
|
||
|
||
def test_parsing_of_trackers_with_old_active_form_field(): | ||
form = {"name": "my form"} | ||
state = {"events": [], "sender_id": "old", "active_form": form} | ||
tracker = Tracker.from_dict(state) | ||
|
||
assert tracker.active_loop == form | ||
|
||
|
||
def test_active_loop_in_tracker_state(): | ||
form = {"name": "my form"} | ||
state = {"events": [], "sender_id": "old", "active_loop": form} | ||
tracker = Tracker.from_dict(state) | ||
|
||
assert tracker.current_state()["active_loop"] == form |