예제 #1
0
    def setUp(self):
        super().setUp()

        self.adapter = Microsoft(
            direct_line_token_or_secret=
            'xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )
예제 #2
0
    def setUp(self):
        super(MicrosoftAdapterTests, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_start_conversation)
        requests.get = Mock(side_effect=mock_get_message)

        microsoft.requests = requests

        self.adapter = Microsoft(
            directline_host='https://directline.botframework.com',
            direct_line_token_or_secret=
            'xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )
    def setUp(self):
        super().setUp()

        self.adapter = Microsoft(
            self.chatbot,
            direct_line_token_or_secret='xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )
예제 #4
0
class MicrosoftInputAdapterTests(MicrosoftTestCase):
    def setUp(self):
        super().setUp()

        self.adapter = Microsoft(
            direct_line_token_or_secret=
            'xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )

    def test_process_input(self):
        statement = Statement('Hi! What is your name?')
        data = self.adapter.process_input(statement)
        self.assertEqual('Hi! What is your name?', data)
    def setUp(self):
        super(MicrosoftAdapterTests, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_start_conversation)
        requests.get = Mock(side_effect=mock_get_message)

        microsoft.requests = requests

        self.adapter = Microsoft(
            directline_host='https://directline.botframework.com',
            direct_line_token_or_secret='xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )
class MicrosoftInputAdapterTests(MicrosoftTestCase):

    def setUp(self):
        super().setUp()

        self.adapter = Microsoft(
            self.chatbot,
            direct_line_token_or_secret='xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )

    def test_process_input(self):
        statement = Statement(text='Hi! What is your name?')
        data = self.adapter.process_input(statement)
        self.assertEqual('Hi! What is your name?', data)
예제 #7
0
class MicrosoftAdapterTests(TestCase):
    def setUp(self):
        super(MicrosoftAdapterTests, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_start_conversation)
        requests.get = Mock(side_effect=mock_get_message)

        microsoft.requests = requests

        self.adapter = Microsoft(
            directline_host='https://directline.botframework.com',
            direct_line_token_or_secret=
            'xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )

    def test_validate_status_code_200(self):
        response = MockResponse(200, {})

        try:
            self.adapter._validate_status_code(response)
        except Microsoft.HTTPStatusException:
            self.fail('Test raised HTTPStatusException unexpectedly!')

    def test_response_status_code_not_ok(self):
        response = MockResponse(404, {})
        with self.assertRaises(Microsoft.HTTPStatusException):
            self.adapter._validate_status_code(response)

    def test_start_conversation(self):
        data = self.adapter.start_conversation()
        self.assertIn('conversationId', data)
        self.assertIn('token', data)
        self.assertIn('expires_in', data)

    def test_process_input(self):
        statement = Statement('Hi! What is your name?')
        data = self.adapter.process_input(statement)
        self.assertEqual('Hi! What is your name?', data)
class MicrosoftAdapterTests(TestCase):

    def setUp(self):
        super(MicrosoftAdapterTests, self).setUp()
        import requests

        requests.post = Mock(side_effect=mock_start_conversation)
        requests.get = Mock(side_effect=mock_get_message)

        microsoft.requests = requests

        self.adapter = Microsoft(
            directline_host='https://directline.botframework.com',
            direct_line_token_or_secret='xtFDtPemROU.cwA.Mcs.qiScdaSx87ffj2l7OjSITqJFoN-9Ado5AgwVeknac94',
        )

    def test_validate_status_code_200(self):
        response = MockResponse(200, {})

        try:
            self.adapter._validate_status_code(response)
        except Microsoft.HTTPStatusException:
            self.fail('Test raised HTTPStatusException unexpectedly!')

    def test_response_status_code_not_ok(self):
        response = MockResponse(404, {})
        with self.assertRaises(Microsoft.HTTPStatusException):
            self.adapter._validate_status_code(response)

    def test_start_conversation(self):
        data = self.adapter.start_conversation()
        self.assertIn('conversationId', data)
        self.assertIn('token', data)
        self.assertIn('expires_in', data)

    def test_process_input(self):
        statement = Statement('Hi! What is your name?')
        data = self.adapter.process_input(statement)
        self.assertEqual('Hi! What is your name?', data)