Example #1
0
    def test_response_result_text_not_accounted_for(self):
        # Arrange
        mock_response = '<xmlreply><messages><result>Fred</result></messages></xmlreply>'

        # Act
        result = SoapService._handle_response(mock_response)

        # Assert
        self.assertFalse(result.success)
        self.assertEqual(result.message,
                         'Response result text not accounted for, text: Fred')
Example #2
0
    def test_error_returned(self):
        # Arrange
        mock_response = '<xmlreply><messages><result>Error</result><error>Error 1</error><error>Error 2</error></messages></xmlreply>'

        # Act
        result = SoapService._handle_response(mock_response)

        # Assert
        self.assertFalse(result.success)
        self.assertEqual(len(result.data), 2)
        self.assertIn('Error 1', result.data)
        self.assertIn('Error 2', result.data)
Example #3
0
    def test_no_response_result_text(self):
        # Arrange
        mock_response = '<xmlreply><messages><result></result></messages></xmlreply>'

        # Act
        result = SoapService._handle_response(mock_response)

        # Assert
        self.assertFalse(result.success)
        self.assertEqual(
            result.message,
            'Response has empty result, response: <xmlreply><messages><result /></messages></xmlreply>'
        )
Example #4
0
    def test_success(self):
        # Arrange
        mock_response = """
        <xmlreply>
            <messages>
                <result>OK</result>
            </messages>
            <apmdata>
                <apmpolicy>
                    <p.py>
                        <polref>12345</polref>
                        <refno>12345</refno>
                    </p.py>
                </apmpolicy>
            </apmdata>
        </xmlreply>"""

        # Act
        result = SoapService._handle_response(mock_response)

        # Assert
        self.assertTrue(result.success)
        self.assertEqual(result.data['ref'], '12345')
        self.assertEqual(result.data['polref'], '12345')