コード例 #1
0
 def test_soap_action(self):
     """Test that SOAP action is passed on to SoapMessage.request()."""
     msg = SoapMessage(etree.Element('test'))
     msg.request = MagicMock()
     with patch('requests.Session'):
         client = SoapClient('http://example.com')
         client(msg, 'testaction', build_response=lambda r: r)
         msg.request.assert_called_once_with('http://example.com',
                                             'testaction')
コード例 #2
0
ファイル: sys_query.py プロジェクト: marlowww/AllegroNotify
    def _create_message(self, ns):
        msg = SoapMessage()
        s = msg.elementmaker("s", ns)

        msg.body = s.DoQuerySysStatusRequest(s.sysvar(self._sysvar),
                                             s.countryId(self._country),
                                             s.webapiKey(self._key))

        return msg
コード例 #3
0
 def test_no_soap_action(self):
     """Test that empty SOAP action is passed to SoapMessage.request()
        when no action given."""
     msg = SoapMessage(etree.Element('test'))
     msg.request = MagicMock()
     with patch('requests.Session') as mock:
         client = SoapClient('http://example.com')
         response = client(msg, build_response=lambda r: r)
         msg.request.assert_called_once_with('http://example.com', '')
コード例 #4
0
ファイル: test_client.py プロジェクト: 2tg67eHE4xWE/rinse
 def test_no_soap_action(self):
     """Test that empty SOAP action is passed to SoapMessage.request()
        when no action given."""
     msg = SoapMessage(etree.Element('test'))
     msg.request = MagicMock()
     with patch('requests.Session'):
         client = SoapClient('http://example.com')
         client(msg, build_response=lambda r: r)
         msg.request.assert_called_once_with('http://example.com', '')
コード例 #5
0
    def _create_message(self, ns):
        msg = SoapMessage()
        s = msg.elementmaker("s", ns)

        msg.body = s.DoLoginEncRequest(s.userLogin(self._login),
                                       s.userHashPassword(self._pwd_hash),
                                       s.countryCode(self._country),
                                       s.webapiKey(self._key),
                                       s.localVersion(self._version))

        return msg
コード例 #6
0
ファイル: sys_query.py プロジェクト: marlowww/AllegroNotify
    def _create_message(self, ns):
        msg = SoapMessage()
        s = msg.elementmaker("s", ns)

        msg.body = s.DoQuerySysStatusRequest(
            s.sysvar(self._sysvar),
            s.countryId(self._country),
            s.webapiKey(self._key)
        )

        return msg
コード例 #7
0
ファイル: login.py プロジェクト: marlowww/AllegroNotify
    def _create_message(self, ns):
        msg = SoapMessage()
        s = msg.elementmaker("s", ns)

        msg.body = s.DoLoginEncRequest(
            s.userLogin(self._login),
            s.userHashPassword(self._pwd_hash),
            s.countryCode(self._country),
            s.webapiKey(self._key),
            s.localVersion(self._version))

        return msg
コード例 #8
0
ファイル: item_list.py プロジェクト: marlowww/AllegroNotify
    def _create_message(self, ns):
        msg = SoapMessage()
        s = msg.elementmaker("s", ns)

        init_body = s.DoGetItemsListRequest(
            s.webapiKey(self._key),
            s.countryId(self._country),
            s.filterOptions(
                s.item(
                    s.filterId("search"),
                    s.filterValueId(
                        s.item(self._title)
                    )
                )
            ),
            s.sortOptions(
                s.sortType("price")
            ),
            s.resultScope("3")
        )
        # [2]nd child is s.filterOptions
        filter_body = init_body.getchildren()[2]

        # Offer type xml
        if self._type != "both":
            offer_body = s.item(
                s.filterId("offerType"),
                s.filterValueId(
                    s.item(self._type)
                )
            )
            filter_body.insert(0, offer_body)

        # Price xml
        if self._price_max > 0 or self._price_min > 0:
            price_body = s.item(
                s.filterId("price"),
                s.filterValueRange()
            )
            range_body = price_body.getchildren()[1]
            if self._price_max > 0:
                range_body.insert(0, s.rangeValueMax(
                    "{0:.2f}".format(round(self._price_max, 2))))
            if self._price_min > 0:
                range_body.insert(0, s.rangeValueMin(
                    "{0:.2f}".format(round(self._price_min, 2))))
            filter_body.insert(0, price_body)

        msg.body = init_body
        return msg
コード例 #9
0
    def _create_message(self, ns):
        msg = SoapMessage()
        s = msg.elementmaker("s", ns)

        init_body = s.DoGetItemsListRequest(
            s.webapiKey(self._key), s.countryId(self._country),
            s.filterOptions(
                s.item(s.filterId("search"),
                       s.filterValueId(s.item(self._title)))),
            s.sortOptions(s.sortType("price")), s.resultScope("3"))
        # [2]nd child is s.filterOptions
        filter_body = init_body.getchildren()[2]

        # Offer type xml
        if self._type != "both":
            offer_body = s.item(s.filterId("offerType"),
                                s.filterValueId(s.item(self._type)))
            filter_body.insert(0, offer_body)

        # Price xml
        if self._price_max > 0 or self._price_min > 0:
            price_body = s.item(s.filterId("price"), s.filterValueRange())
            range_body = price_body.getchildren()[1]
            if self._price_max > 0:
                range_body.insert(
                    0,
                    s.rangeValueMax("{0:.2f}".format(round(self._price_max,
                                                           2))))
            if self._price_min > 0:
                range_body.insert(
                    0,
                    s.rangeValueMin("{0:.2f}".format(round(self._price_min,
                                                           2))))
            filter_body.insert(0, price_body)

        msg.body = init_body
        return msg
コード例 #10
0
 def test_soap_action_debug(self):
     msg = SoapMessage(etree.Element('test'))
     client = SoapClient('http://example.com', debug=True)
     client._session = MagicMock()
     with captured_stdout() as stdout:
         client(msg, 'testaction', build_response=lambda r: r)
     self.assertEqual(
         stdout.getvalue(), 'POST http://example.com\n'
         'Content-Length: 164\n'
         'Content-Type: text/xml;charset=UTF-8\n'
         'SOAPAction: testaction\n'
         '\n'
         '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">\n'
         '  <soapenv:Header/>\n'
         '  <soapenv:Body>\n'
         '    <test/>\n'
         '  </soapenv:Body>\n'
         '</soapenv:Envelope>\n'
         '\n')
コード例 #11
0
 def test_soap_action_is_none(self):
     """Test that SOAP-Action HTTP header is absent when no action is None.
     """
     msg = SoapMessage(etree.Element('test'))
     req = msg.request('http://example.com', None)
     self.assertTrue('SOAPAction' not in req.headers)
コード例 #12
0
 def test_soap_action(self):
     """Test that SOAP-Action HTTP header is set correctly."""
     msg = SoapMessage(etree.Element('test'))
     req = msg.request('http://example.com', 'testaction')
     self.assertEqual(req.headers['SOAPAction'], 'testaction')
コード例 #13
0
ファイル: test_client.py プロジェクト: 2tg67eHE4xWE/rinse
 def test_soap_action_is_none(self):
     """Test that SOAP-Action HTTP header is absent when no action is None.
     """
     msg = SoapMessage(etree.Element('test'))
     req = msg.request('http://example.com', None)
     self.assertTrue('SOAPAction' not in req.headers)
コード例 #14
0
ファイル: test_client.py プロジェクト: 2tg67eHE4xWE/rinse
 def test_soap_action(self):
     """Test that SOAP-Action HTTP header is set correctly."""
     msg = SoapMessage(etree.Element('test'))
     req = msg.request('http://example.com', 'testaction')
     self.assertEqual(req.headers['SOAPAction'], 'testaction')