Ejemplo n.º 1
0
    def test_successful_post(self):
        # Arrange
        mock_client = mock.Mock()
        mock_client.service.processMessage.return_value = '<xmlreply><messages><result>OK</result></messages></xmlreply>'

        # Act
        result = SoapService._post_to_xstream(mock_client,
                                              '<xmlexecute></xmlexecute>')

        # Assert
        self.assertTrue(result.data)
        self.assertTrue(result.success)
Ejemplo n.º 2
0
    def test_post_errors(self, mock_logger: mock.MagicMock):
        # Arrange
        mock_client = mock.Mock()
        mock_client.service.processMessage.side_effect = Exception('Timed out')

        # Act
        result = SoapService._post_to_xstream(mock_client,
                                              '<xmlexecute></xmlexecute>')

        # Assert
        self.assertFalse(result.success)
        self.assertEqual(result.message,
                         'Failed to post to xstream, error: Timed out')
        mock_logger.assert_called_once_with(
            'Failed to post to xstream, error: Timed out')