Skip to content

Commit

Permalink
Merge pull request #4190 from RasaHQ/message-timestamp-fix
Browse files Browse the repository at this point in the history
Message timestamp fix
  • Loading branch information
msamogh committed Aug 7, 2019
2 parents 56da3c1 + 3ad3c8e commit da370f4
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 5 deletions.
12 changes: 9 additions & 3 deletions CHANGELOG.rst
Expand Up @@ -6,7 +6,7 @@ Rasa Change Log
All notable changes to this project will be documented in this file.
This project adheres to `Semantic Versioning`_ starting with version 1.0.

[Unreleased 1.2.2] - `master`_
[Unreleased 1.2.3] - `master`_
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Added
Expand All @@ -23,8 +23,14 @@ Removed

Fixed
-----
- ``Flood control exceeded`` error in Telegram connector which happened because the
webhook was set twice


[1.2.2] - 2019-08-07
^^^^^^^^^^^^^^^^^^^^

Fixed
-----
- ``UserUttered`` events always got the same timestamp

[1.2.1] - 2019-08-06
^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 1 addition & 1 deletion rasa/core/events/__init__.py
Expand Up @@ -184,7 +184,7 @@ def __init__(
intent=None,
entities=None,
parse_data: Optional[Dict[Text, Any]] = None,
timestamp: int = time.time(),
timestamp: Optional[int] = None,
input_channel: Optional[Text] = None,
message_id: Optional[Text] = None,
metadata: Optional[Dict] = None,
Expand Down
2 changes: 1 addition & 1 deletion rasa/version.py
@@ -1 +1 @@
__version__ = "1.2.1"
__version__ = "1.2.2"
35 changes: 35 additions & 0 deletions tests/core/test_events.py
@@ -1,3 +1,5 @@
import time

import pytz
from datetime import datetime
import copy
Expand Down Expand Up @@ -232,3 +234,36 @@ def test_json_parse_agent():
evt = {"event": "agent", "text": "Hey, how are you?"}
# DOCS END
assert Event.from_parameters(evt) == AgentUttered("Hey, how are you?")


@pytest.mark.parametrize(
"event_class",
[
UserUttered,
BotUttered,
ActionReverted,
Event,
Restarted,
AllSlotsReset,
ConversationResumed,
ConversationPaused,
StoryExported,
UserUtteranceReverted,
AgentUttered,
],
)
def test_correct_timestamp_setting_for_events_with_no_required_params(event_class):
event = event_class()
time.sleep(0.01)
event2 = event_class()

assert event.timestamp < event2.timestamp


@pytest.mark.parametrize("event_class", [SlotSet, ActionExecuted, FollowupAction])
def test_correct_timestamp_setting(event_class):
event = event_class("test")
time.sleep(0.01)
event2 = event_class("test")

assert event.timestamp < event2.timestamp

0 comments on commit da370f4

Please sign in to comment.