def test_returns_an_object_malicious(self, malicious_data):
        result = MAPPER.load(malicious_data, "customer_satisfaction_action")
        assert isinstance(result, CustomerSatisfactionAction)
        assert result.message == "<script>void();</script>Are you satisfied ?"

        choice1, choice2 = result.choices
        assert choice1.kind == "positive"
        assert choice1.label == "<script>void();</script>yes"
 def test_returns_an_object(self, data):
     result = MAPPER.load(data, "webhook_interlocutor")
     assert isinstance(result, Interlocutor)
     assert result.id == "123"
     assert result.location.lat == 1
     assert result.location.long == 2
     assert result.email == "*****@*****.**"
     assert result.first_name == "tintin"
     assert result.last_name is None
     assert result.custom_attributes == {"age": "21"}
     assert result.phone_number == "0645592034"
    def test_returns_an_object(self, data):
        result = MAPPER.load(data, "customer_satisfaction_action")
        assert isinstance(result, CustomerSatisfactionAction)
        assert result.message == "Are you satisfied ?"
        assert len(result.choices) == 3

        choice1, choice2, choice3 = result.choices
        assert choice1.kind == "positive"
        assert choice1.target.step_id == "a1" * 12
        assert choice1.matching_intent_id == "b1" * 12
        assert choice1.label == "yes"

        assert choice2.kind == "neutral"
        assert choice2.target.step_id == "a2" * 12
        assert choice2.matching_intent_id == "c2" * 12
        assert choice2.label == "neutral"

        assert choice3.kind == "negative"
        assert choice3.target.step_id == "a2" * 12
        assert choice3.matching_intent_id == "b2" * 12
        assert choice3.label == "no"
 def test_returns_a_dict(self, data, action):
     result = MAPPER.dump(action, "customer_satisfaction_action")
     assert result == data
示例#5
0
 def test_returns_a_dict(self, data, image):
     result = MAPPER.dump(image, "image")
     assert result == data
 def test_returns_an_object(self, data):
     result = MAPPER.load(data, "url_loaded_event")
     assert isinstance(result, URLLoadedEvent)
     assert result.url == "http://example.com/"
示例#7
0
 def test_returns_an_object(self, data):
     result = MAPPER.load(data, "incoming_message")
     assert isinstance(result, Message)
     assert result.text == "hello"
     assert isinstance(result.attachments[0], Video)
 def test_returns_an_object(self, data):
     result = MAPPER.load(data, "custom_event")
     assert isinstance(result, CustomEvent)
     assert result.name == "event1"
示例#9
0
 def test_returns_an_object(self, data):
     result = MAPPER.load(data, "audio")
     assert isinstance(result, Audio)
     assert result.url == "http://example.com/"
 def test_doesnt_raise_if_valid(self, data):
     MAPPER.validate(data, "customer_satisfaction_callback_action")
    def test_render_error_if_invalid(self, data):
        data["kind"] = "toto"

        with pytest.raises(InvalidDocument):
            MAPPER.validate(data, "customer_satisfaction_callback_action")
 def test_returns_an_object(self, data):
     result = MAPPER.load(data, "customer_satisfaction_callback_action")
     assert isinstance(result, CustomerSatisfactionCallbackAction)
     assert result.kind == "positive"
     assert isinstance(result.target, StepTarget)
     assert result.target.step_id == "a1" * 12
 def test_returns_a_dict(self, data, callback):
     result = MAPPER.dump(callback, "customer_satisfaction_callback_action")
     assert result == data
示例#14
0
 def test_returns_a_dict(self, data, video):
     result = MAPPER.dump(video, "video")
     assert result == data
示例#15
0
 def test_returns_a_dict(self, data, file):
     result = MAPPER.dump(file, "file")
     assert result == data
示例#16
0
 def test_returns_a_dict(self, data, audio):
     result = MAPPER.dump(audio, "audio")
     assert result == data
 def test_doesnt_raise_id_target_null(self, data_no_target):
     MAPPER.validate(data_no_target, "customer_satisfaction_callback_action")
 def test_returns_a_dict(self, data, event):
     result = MAPPER.dump(event, "custom_event")
     assert result == data
 def test_returns_a_dict(self, data, interlocutor):
     result = MAPPER.dump(interlocutor, "webhook_interlocutor")
     assert result == data
示例#20
0
 def test_returns_a_dict(self, data, message):
     result = MAPPER.dump(message)
     assert result == data
 def test_returns_an_object_malicious(self, malicious_data):
     result = MAPPER.load(malicious_data, "webhook_interlocutor")
     assert isinstance(result, Interlocutor)
     assert result.email == "*****@*****.**"
     assert result.first_name == "<script>void();</script>tintin"
示例#22
0
 def test_returns_an_object(self, malicious_data):
     result = MAPPER.load(malicious_data, "incoming_message")
     assert result.text == "<script>void();</script>hello"
 def test_returns_a_dict(self, data, event):
     result = MAPPER.dump(event, "url_loaded_event")
     assert result == data