コード例 #1
0
    def test_get_single_command_parameter(self):
        html = b'''<html><body>
        <h2><a id="getPayment"></a>getPayment</h2>
        <p>Returns all basic and associated information about a payment. This could include credit card information, electronic check information, invoice payments, and payment refunds.</p>
        <h3>Parameters</h3>
        <table style="width: 100%; border: 1px solid #767676;" border="0">
        <thead>
        <tr style="background-color: #eee;">
        <td>Parameter</td>
        <td>Description</td>
        <td>Required</td>
        </tr>
        </thead>
        <tbody>
        <tr>
        <td>payment_id</td>
        <td>The numeric ID of the payment you're interested in.</td>
        <td>Yes</td>
        </tr>
        </tbody>
        </table>
        </body></html>'''
        tree = etree.fromstring(html, etree.HTMLParser())

        parameters = build.get_command_parameters(tree, 'getPayment')

        self.assertEqual(len(parameters), 1)
        self.assertEqual(parameters[0].field, 'payment_id')
        self.assertEqual(
            parameters[0].comment,
            'The numeric ID of the payment you\'re interested in.')
        self.assertEqual(parameters[0].required, True)
コード例 #2
0
    def test_get_none_command_parameters(self):
        html = b'''<html><body>
                <h2><a id="getPayment"></a>getPayment</h2>
                <p>Returns all basic and associated information about a payment. This could include credit card information, electronic check information, invoice payments, and payment refunds.</p>
                <h3>Parameters</h3>
                <p>None.</p>
                </body></html>'''
        tree = etree.fromstring(html, etree.HTMLParser())

        parameters = build.get_command_parameters(tree, 'getPayment')

        self.assertEqual(len(parameters), 0)