Ejemplo n.º 1
0
    def test_next_reminder_due_date(self):
        reminder = Reminder(
            created_at=datetime(year=2020,
                                month=5,
                                day=9,
                                hour=15,
                                minute=10,
                                second=33),
            last_reminded_at=None,
        )
        self.assertEqual(
            reminder.next_reminder_due_date,
            datetime(year=2020, month=5, day=10, hour=15, minute=10,
                     second=33),
        )

        reminder = Reminder(
            created_at=datetime(year=2020,
                                month=5,
                                day=6,
                                hour=11,
                                minute=43,
                                second=12),
            last_reminded_at=datetime(year=2020,
                                      month=5,
                                      day=9,
                                      hour=15,
                                      minute=10,
                                      second=33),
        )
        self.assertEqual(
            reminder.next_reminder_due_date,
            datetime(year=2020, month=5, day=10, hour=11, minute=43,
                     second=12),
        )
Ejemplo n.º 2
0
    def test_metadata_none(self):
        reminder = Reminder.create_from_slot_values({
            METADATA_SLOT: None,
            PHONE_NUMBER_SLOT: PHONE_NUMBER,
            FIRST_NAME_SLOT: NAME,
        })
        expected_reminder = Reminder(timezone=None)
        expected_reminder.phone_number = PHONE_NUMBER
        expected_reminder.first_name = NAME

        self.assertEqual(reminder, expected_reminder)
Ejemplo n.º 3
0
    def test_create_from_slot_values(self):
        reminder = Reminder.create_from_slot_values({
            METADATA_SLOT: {
                TIMEZONE_PROPERTY: TIMEZONE
            },
            PHONE_NUMBER_SLOT: PHONE_NUMBER,
            FIRST_NAME_SLOT: NAME,
            "ignored_slot": "value",
        })
        expected_reminder = Reminder(TIMEZONE)
        expected_reminder.phone_number = PHONE_NUMBER
        expected_reminder.first_name = NAME

        self.assertEqual(reminder, expected_reminder)
Ejemplo n.º 4
0
def _save_reminder(session, slot_values: Dict[Text, Any]):
    reminder = Reminder.create_from_slot_values(slot_values)
    session.add(reminder)
    return reminder
Ejemplo n.º 5
0
    HASHIDS_SALT_ENV_KEY,
    _send_reminder,
    run,
)
from tests.utils.fake_server import FakeServer

ROUTE = "/conversations/{phone_number}/trigger_intent"

HASHIDS_SALT = "abcd1234"
HASHIDS_MIN_LENGTH = 4

REMINDER_1 = Reminder(
    id=1,
    timezone="America/Toronto",
    attributes={
        "first_name": "James",
        "phone_number": "15145551234",
        "language": FR
    },
)

REMINDER_2 = Reminder(
    id=2,
    timezone="America/Toronto",
    attributes={
        "first_name": "Lilly",
        "phone_number": "15145554567",
        "language": EN
    },
)
Ejemplo n.º 6
0
DEFAULT_555_REMINDER_SLOTS: Dict[str, Any] = {PHONE_NUMBER_SLOT: "12225554444"}

DEFAULT_SELF_ASSESSMENT_SLOTS: Dict[str, Any] = {
    **DEFAULT_REMINDER_SLOTS,
    **DEFAULT_ASSESSMENT_SLOTS,
    "ignored_slot": "Jango Fett",
}
DEFAULT_DAILY_CI_SLOTS: Dict[str, Any] = {
    METADATA_SLOT: {
        REMINDER_ID_METADATA_PROPERTY: HASHED_ID
    },
    **DEFAULT_ASSESSMENT_SLOTS,
    "ignored_slot": "Boba Fett",
}

DEFAULT_REMINDER = Reminder(id=REMINDER_ID, attributes=DEFAULT_REMINDER_SLOTS)
DEFAULT_555_REMINDER = Reminder(id=REMINDER_ID,
                                attributes=DEFAULT_555_REMINDER_SLOTS)
DEFAULT_ASSESSMENT = Assessment(id=ASSESSMENT_ID,
                                reminder_id=REMINDER_ID,
                                attributes=DEFAULT_ASSESSMENT_SLOTS)


def _set_id(x):
    if isinstance(x, Reminder):
        x.id = REMINDER_ID
    elif isinstance(x, Assessment):
        x.id = ASSESSMENT_ID
    else:
        raise