Example #1
0
    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')
Example #2
0
    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)
Example #3
0
    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)
Example #4
0
    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'
        )
Example #5
0
    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)
Example #6
0
    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)