Exemplo n.º 1
0
    def test_add_url(self, Request, urlopen):
        request = mock.Mock()
        Request.return_value = request

        add_url("service_name", "name", "url")

        Request.assert_called_with(
            'POST',
            self.target +
            'services/service_name/proxy/name?callback=/resources/name/url',
            data=json.dumps({'url': 'url'}))

        calls = [
            mock.call("Authorization", "bearer {}".format(self.token)),
            mock.call("Content-Type", "application/json"),
            mock.call("Accept", "text/plain"),
        ]
        self.assertEqual(calls, request.add_header.call_args_list)
        urlopen.assert_called_with(request, timeout=30)
    def test_add_url(self, Request, urlopen):
        request = mock.Mock()
        Request.return_value = request

        add_url("service_name", "name", "url")

        Request.assert_called_with(
            'POST',
            self.target + 'services/service_name/proxy/name?callback=/url',
            data=json.dumps({'url': 'url', 'name': 'name'})
        )

        calls = [
            mock.call("Authorization", "bearer {}".format(self.token)),
            mock.call("Content-Type", "application/json"),
            mock.call("Accept", "text/plain"),
        ]
        self.assertEqual(calls, request.add_header.call_args_list)
        urlopen.assert_called_with(request, timeout=30)