-
Notifications
You must be signed in to change notification settings - Fork 7
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 #698 from dimagi/cs/chat_to_version
Ability to chat to a specific version
- Loading branch information
Showing
15 changed files
with
196 additions
and
50 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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
import pytest | ||
from django.http import Http404 | ||
from django.test import override_settings | ||
from mock.mock import Mock, patch | ||
|
||
from apps.channels.models import ChannelPlatform | ||
from apps.chat.channels import WebChannel | ||
from apps.chat.models import Chat | ||
|
||
|
||
@pytest.mark.django_db() | ||
|
@@ -40,6 +42,12 @@ def test_start_new_session(new_user_message, get_ai_message_id, with_seed_messag | |
assert message.attachments == [] | ||
|
||
|
||
@pytest.mark.django_db() | ||
def test_404_raised_when_version_is_not_found(experiment): | ||
with pytest.raises(Http404): | ||
WebChannel.start_new_session(experiment, "[email protected]", version=20) | ||
|
||
|
||
@pytest.mark.django_db() | ||
class TestVersioning: | ||
@patch("apps.events.tasks.enqueue_static_triggers", Mock()) | ||
|
@@ -54,3 +62,15 @@ def test_start_new_session_uses_default_version(self, check_and_process_seed_mes | |
_session_used, experiment_used = check_and_process_seed_message.call_args[0] | ||
assert experiment_used == new_version | ||
assert session.experiment == experiment | ||
assert session.chat.metadata.get(Chat.MetadataKeys.EXPERIMENT_VERSION) == experiment.DEFAULT_VERSION_NUMBER | ||
|
||
@patch("apps.events.tasks.enqueue_static_triggers", Mock()) | ||
@patch("apps.chat.channels.WebChannel.check_and_process_seed_message") | ||
def test_start_new_session_uses_specified_version(self, check_and_process_seed_message, experiment): | ||
new_version = experiment.create_new_version() | ||
session = WebChannel.start_new_session(experiment, "[email protected]", version=1) | ||
|
||
_session_used, experiment_used = check_and_process_seed_message.call_args[0] | ||
assert experiment_used == new_version | ||
assert session.experiment == experiment | ||
assert session.chat.metadata.get(Chat.MetadataKeys.EXPERIMENT_VERSION) == 1 |
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
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
Oops, something went wrong.