'Ensure that the page displays the right message for the reason_code (it
may be a user error message or a system error message).'

@ddt.data(True, False)
@mock.patch('commerce.views.is_user_payment_error')
def test_cybersource_message(self, is_user_message_expected, mock_is_user_payment_error):

    mock_is_user_payment_error.return_value = is_user_message_expected
    self._login()
    response = self.post_to_receipt_page({'decision': 'REJECT', 'reason_code': '99', 'signed_field_names': 'dummy'})
    self.assertTrue(mock_is_user_payment_error.called)
    self.assertTrue(mock_is_user_payment_error.call_args[0][0], '99')
    user_message = 'There    was    a    problem    with    this    transaction'
    system_message = 'A    system    error    occurred    while    processing    your    payment'
    self.assertRegexpMatches(response.content, (user_message if is_user_message_expected else system_message))
    self.assertNotRegexpMatches(response.content, (user_message if (not is_user_message_expected) else system_message))
