コード例 #1
0
ファイル: conn_tests.py プロジェクト: fangbei/retdec-python
    def test_send_post_request_includes_given_parameters(self):
        self.setup_responses(method=responses.POST,
                             url='https://retdec.com/service/api')
        conn = APIConnection('https://retdec.com/service/api', 'KEY')

        conn.send_post_request(params={'key': 'value'})

        self.assertEqual(responses.calls[0].request.url,
                         'https://retdec.com/service/api?key=value')
コード例 #2
0
ファイル: conn_tests.py プロジェクト: fangbei/retdec-python
    def test_send_post_request_sends_post_request(self):
        self.setup_responses(method=responses.POST,
                             url='https://retdec.com/service/api')
        conn = APIConnection('https://retdec.com/service/api', 'KEY')

        conn.send_post_request()

        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.method, responses.POST)
コード例 #3
0
ファイル: conn_tests.py プロジェクト: hugsy/retdec-python
    def test_send_post_request_sends_post_request(self):
        self.setup_responses(
            method=responses.POST,
            url='https://retdec.com/service/api'
        )
        conn = APIConnection('https://retdec.com/service/api', 'KEY')

        conn.send_post_request()

        self.assertEqual(len(responses.calls), 1)
        self.assertEqual(responses.calls[0].request.method, responses.POST)
コード例 #4
0
ファイル: conn_tests.py プロジェクト: hugsy/retdec-python
    def test_send_post_request_includes_given_parameters(self):
        self.setup_responses(
            method=responses.POST,
            url='https://retdec.com/service/api'
        )
        conn = APIConnection('https://retdec.com/service/api', 'KEY')

        conn.send_post_request(params={'key': 'value'})

        self.assertEqual(
            responses.calls[0].request.url,
            'https://retdec.com/service/api?key=value'
        )
コード例 #5
0
ファイル: conn_tests.py プロジェクト: fangbei/retdec-python
    def test_send_post_request_includes_given_files(self):
        self.setup_responses(method=responses.POST,
                             url='https://retdec.com/service/api')
        conn = APIConnection('https://retdec.com/service/api', 'KEY')

        files = {'input': ('test.c', io.StringIO('main()'))}
        conn.send_post_request(files=files)

        body = str(responses.calls[0].request.body)
        self.assertIn(
            'Content-Disposition: form-data; name="input"; filename="test.c"',
            body)
        self.assertIn('main()', body)
コード例 #6
0
ファイル: conn_tests.py プロジェクト: hugsy/retdec-python
    def test_send_post_request_includes_given_files(self):
        self.setup_responses(
            method=responses.POST,
            url='https://retdec.com/service/api'
        )
        conn = APIConnection('https://retdec.com/service/api', 'KEY')

        files = {'input': ('test.c', io.StringIO('main()'))}
        conn.send_post_request(files=files)

        body = str(responses.calls[0].request.body)
        self.assertIn(
            'Content-Disposition: form-data; name="input"; filename="test.c"',
            body
        )
        self.assertIn('main()', body)