'Verify that get_enterprise_consent_url correctly builds URLs.'

@mock.patch('openedx.features.enterprise_support.api.consent_needed_for_course')
def test_get_enterprise_consent_url(self, needed_for_course_mock):

    needed_for_course_mock.return_value = True
    request_mock = mock.MagicMock(user=None, build_absolute_uri=(lambda x: ('http://localhost:8000' + x)))
    course_id = 'course-v1:edX+DemoX+Demo_Course'
    return_to = 'info'
    expected_url = '/enterprise/grant_data_sharing_permissions?course_id=course-v1%3AedX%2BDemoX%2BDemo_Course&failure_url=http%3A%2F%2Flocalhost%3A8000%2Fdashboard%3Fconsent_failed%3Dcourse-v1%253AedX%252BDemoX%252BDemo_Course&next=http%3A%2F%2Flocalhost%3A8000%2Fcourses%2Fcourse-v1%3AedX%2BDemoX%2BDemo_Course%2Finfo'
    actual_url = get_enterprise_consent_url(request_mock, course_id, return_to=return_to)
    self.assertEqual(actual_url, expected_url)
