Exemplo n.º 1
0
    def test_validate_answers_text_list_only_stay_closed(self):
        """
        text_list only when and stay closed
        """
        data = {'text_list': [self._STAY_CLOSED_TEXT]}

        self.assertFalse(validate_answers(data))
Exemplo n.º 2
0
    def test_validate_answers_text_list_only_reopen(self):
        """
        text_list only when an reopens when unhappy string
        """
        data = {'text_list': [self._REOPEN_TEXT]}

        self.assertTrue(validate_answers(data))
Exemplo n.º 3
0
 def test_validate_answers_text_list_multiple_stay_closed(self):
     """
     if text_list has multiple stay closed texts
     """
     data = {
         'text_list': [self._STAY_CLOSED_TEXT, self._STAY_CLOSED_TEXT_2]
     }
     self.assertFalse(validate_answers(data))
Exemplo n.º 4
0
 def test_validate_answers_text_list_multiple_closed_with_custom(self):
     """
     if text_list has a custom text in it
     """
     data = {
         'text_list': [
             self._STAY_CLOSED_TEXT, self._STAY_CLOSED_TEXT_2,
             "some reporter text"
         ]
     }
     self.assertTrue(validate_answers(data))
Exemplo n.º 5
0
 def test_validate_answers_text_list_multiple_stay_mixed(self):
     """
     if text_list has closed and reopen mixed
     """
     data = {
         'text_list': [
             self._STAY_CLOSED_TEXT, self._STAY_CLOSED_TEXT_2,
             self._REOPEN_TEXT_2
         ]
     }
     self.assertTrue(validate_answers(data))
Exemplo n.º 6
0
    def test_validate_answers_duplicate(self):
        """
        Create a check to see that duplicate messages are not seen as custom texts because of a list diff.
        and keep the signal Close with duplicate closed texts
        """
        data = {
            'text_list': [
                self._STAY_CLOSED_TEXT, self._STAY_CLOSED_TEXT,
                self._STAY_CLOSED_TEXT
            ]
        }

        self.assertFalse(validate_answers(data))
Exemplo n.º 7
0
    def update(self, instance, validated_data):
        # TODO: consider whether using a StandardAnswer while overriding the
        # is_satisfied field should be considered an error condition and return
        # an HTTP 400.
        validated_data['submitted_at'] = timezone.now()

        # Check whether the relevant Signal instance should possibly be
        # reopened (i.e. transition to VERZOEK_TOT_HEROPENEN state).
        is_satisfied = validated_data['is_satisfied']

        # @TODO: When text field is depricated the following can be removed
        validated_data = merge_texts(validated_data)
        instance.text = None
        instance.text_list = validated_data['text_list']

        reopen = False
        if not is_satisfied:
            reopen = validate_answers(validated_data)

        # Reopen the Signal (melding) if need be.
        if reopen:
            signal = instance._signal

            # Only allow a request to reopen when in state workflow.AFGEHANDELD
            if signal.status.state == workflow.AFGEHANDELD:
                payload = {
                    'text':
                    'De melder is niet tevreden blijkt uit feedback. Zo nodig heropenen.',
                    'state': workflow.VERZOEK_TOT_HEROPENEN,
                }
                Signal.actions.update_status(payload, signal)

        instance = super().update(instance, validated_data)
        # trigger the mail to be after the instance update to have the new data
        if not is_satisfied and instance._signal.allows_contact:
            MailService.system_mail(signal=instance._signal,
                                    action_name='feedback_received',
                                    feedback=instance)
        return instance
Exemplo n.º 8
0
 def test_validate_answers_text_list_multiple_reopen(self):
     """
     if text_list has multiple reopen texts
     """
     data = {'text_list': [self._REOPEN_TEXT, self._REOPEN_TEXT_2]}
     self.assertTrue(validate_answers(data))
Exemplo n.º 9
0
 def test_validate_answers_text_list_custom_text(self):
     """
     text_list with a custom text should always return true to reopen the signal
     """
     data = {'text_list': ["SOME CUSTOMER TEXT"]}
     self.assertTrue(validate_answers(data))
Exemplo n.º 10
0
 def test_validate_answers_text_list_reopen_and_close(self):
     """
     text_list with multiple anwsers and only triggers reopen it should true to reopen the signal
     """
     data = {'text_list': [self._REOPEN_TEXT, self._STAY_CLOSED_TEXT]}
     self.assertTrue(validate_answers(data))