Esempio n. 1
0
 def test_user_validation_failed(self):
     profile = UserProfile(validated=False)
     dialog_state = DialogState("123456789", "0", user_profile=profile)
     event = UserValidationFailed(phone_number="123456789",
                                  user_profile=profile)
     event.apply_to(dialog_state)
     self.assertFalse(dialog_state.user_profile.validated)
Esempio n. 2
0
 def test_user_validation_failed_event(self):
     dialog_events: List[DialogEvent] = [
         UserValidationFailed(self.phone, self.non_validated_user_profile)
     ]
     outbound_messages = get_outbound_sms_commands(dialog_events)
     self.assertEqual(len(outbound_messages), 1)
     message = outbound_messages[0]
     self.assertEqual(message.phone_number, self.phone)
     self.assertEqual(message.event_id, dialog_events[0].event_id)
     self.assertEqual(message.body, USER_VALIDATION_FAILED_COPY)
Esempio n. 3
0
    def _validate_registration(
        self, dialog_state: DialogState, base_args: Dict[str, Any]
    ) -> Optional[List[stopcovid.dialog.models.events.DialogEvent]]:

        if dialog_state.user_profile.is_demo or not dialog_state.user_profile.validated:
            validation_payload = self.registration_validator.validate_code(
                self.content_lower)
            if validation_payload.valid:
                return [
                    UserValidated(code_validation_payload=validation_payload,
                                  **base_args)
                ]
            if not dialog_state.user_profile.validated:
                return [UserValidationFailed(**base_args)]
Esempio n. 4
0
 def _validate_registration(
         self, dialog_state: DialogState,
         base_args: Dict[str, Any]) -> Optional[List[DialogEvent]]:
     if not dialog_state.user_profile.validated or (
             dialog_state.user_profile.account_info
             and not dialog_state.user_profile.account_info.employer_id):
         validation_payload = self.registration_validator.validate_code(
             self.content_lower)
         if validation_payload.valid:
             return [
                 UserValidated(code_validation_payload=validation_payload,
                               **base_args)
             ]
         if not dialog_state.user_profile.validated:
             return [UserValidationFailed(**base_args)]
     return None
Esempio n. 5
0
 def test_user_validation_failed(self):
     original = UserValidationFailed("123456789",
                                     user_profile=UserProfile(True))
     serialized = original.to_dict()
     deserialized = event_from_dict(serialized)
     self._make_base_assertions(original, deserialized)