@patch('requests.put')
    def test_bad_request(self, r_put):
        # Verified response from the live API
        head = dict()
        head['content-type'] = 'text/xml; charset=utf-8'
        r_put.return_value = Mock(
            status_code=400,
            encoding='utf-8',
            text=mock_data.bad_request_text,
            headers=head
        )

        credentials = Mock(base_url="")
        xero = Xero(credentials)

        try:
            xero.invoices.put({
                'Type': 'ACCREC',
                'LineAmountTypes': 'Exclusive',
                'Date': date(2013, 4, 29),
                'DueDate': date(2013, 4, 29),
                'Reference': 'Order # 123456',
                'Status': 'PAID',
                'AmountPaid': '19.05',
                'TotalTax': '1.05',
                'AmountDue': '0.00',
                'Total': '19.05',
                'SubTotal': '18.00',
            })
            self.fail("Should raise a XeroBadRequest.")

        except XeroBadRequest as e:
            # Error messages have been extracted
            self.assertEqual(str(e), 'A validation exception occurred')
            self.assertEqual(e.errors, [
                'One or more line items must be specified',
                'Invoice not of valid status for creation',
                'A Contact must be specified for this type of transaction',
            ])

            # The response has also been stored
            self.assertEqual(e.response.status_code, 400)
            self.assertTrue(e.response.text.startswith('<ApiException'))
        except Exception as e:
            self.fail("Should raise a XeroBadRequest, not %s" % e)
The effective top of this placeholder shape; its directly-applied
dataset/ETHPy150Open freakboy3742/pyxero/tests/exceptions.py/ExceptionsTest.test_bad_request--crossover with--dataset/ETHPy150Open scanny/python-pptx/pptx/shapes/placeholder.py/_InheritsDimensions.top