コード例 #1
0
    def test_kg_search(self):
        with mock.patch.object(main, 'kgsearch'):
            entities = main.kgsearch.entities.return_value
            search = entities.search.return_value
            search.execute.return_value = example_response

            request = Request()
            request.form = {'text': 'lion'}
            request.data = json.dumps(request.form)

            now = str(int(time.time()))
            verifier = SignatureVerifier(os.environ['SLACK_SECRET'])
            test_signature = verifier.generate_signature(timestamp=now,
                                                         body=request.data)

            request.method = 'POST'
            request.headers = {
                'X-Slack-Request-Timestamp': now,
                'X-Slack-Signature': test_signature
            }

            with mock.patch('main.jsonify', side_effect=json.dumps):
                response = main.kg_search(request)

        assert 'lion' in response.lower()
        assert 'color' in response.lower()
コード例 #2
0
    def test_kg_search(self):
        with mock.patch.object(main, 'kgsearch'):
            entities = main.kgsearch.entities.return_value
            search = entities.search.return_value
            search.execute.return_value = example_response
            request = Request()
            request.method = 'POST'
            request.form = {'token': config['SLACK_TOKEN'], 'text': 'lion'}

            with mock.patch('main.jsonify', side_effect=json.dumps):
                response = main.kg_search(request)

        assert 'lion' in response.lower()
        assert 'color' in response.lower()
コード例 #3
0
    def test_kg_search(self):
        with mock.patch.object(main, 'kgsearch'):
            entities = main.kgsearch.entities.return_value
            search = entities.search.return_value
            search.execute.return_value = example_response
            request = Request()
            request.method = 'POST'
            request.headers = {
                'X-Slack-Signature': os.environ['SLACK_TEST_SIGNATURE']
            }
            request.form = {'text': 'lion'}

            with mock.patch('main.jsonify', side_effect=json.dumps):
                response = main.kg_search(request)

        assert 'lion' in response.lower()
        assert 'color' in response.lower()
コード例 #4
0
    def test_kg_search(self):
        with mock.patch.object(main, 'kgsearch'):
            entities = main.kgsearch.entities.return_value
            search = entities.search.return_value
            search.execute.return_value = example_response
            request = Request()
            request.method = 'POST'
            request.form = {
                'token': config['SLACK_TOKEN'],
                'text': 'lion'
            }

            with mock.patch('main.jsonify', side_effect=json.dumps):
                response = main.kg_search(request)

        assert 'lion' in response.lower()
        assert 'color' in response.lower()