Files
edx-platform/lms/djangoapps/verify_student/tests/test_integration.py
Kyle McCormick 151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00

65 lines
2.6 KiB
Python

"""
Integration tests of the payment flow, including course mode selection.
"""
import six
from django.urls import reverse
from common.djangoapps.course_modes.tests.factories import CourseModeFactory
from lms.djangoapps.commerce.tests.mocks import mock_payment_processors
from common.djangoapps.student.models import CourseEnrollment
from common.djangoapps.student.tests.factories import UserFactory
from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from xmodule.modulestore.tests.factories import CourseFactory
class TestProfEdVerification(ModuleStoreTestCase):
"""
Integration test for professional ed verification, including course mode selection.
"""
# Choose an uncommon number for the price so we can search for it on the page
MIN_PRICE = 1438
def setUp(self):
super(TestProfEdVerification, self).setUp()
self.user = UserFactory.create(username="rusty", password="test")
self.client.login(username="rusty", password="test")
course = CourseFactory.create(org='Robot', number='999', display_name='Test Course')
self.course_key = course.id
CourseModeFactory.create(
mode_slug="professional",
course_id=self.course_key,
min_price=self.MIN_PRICE,
suggested_prices=''
)
purchase_workflow = "?purchase_workflow=single"
self.urls = {
'course_modes_choose': reverse(
'course_modes_choose',
args=[six.text_type(self.course_key)]
),
'verify_student_start_flow': reverse(
'verify_student_start_flow',
args=[six.text_type(self.course_key)]
) + purchase_workflow,
}
def test_start_flow(self):
# Go to the course mode page, expecting a redirect to the intro step of the
# payment flow (since this is a professional ed course). Otherwise, the student
# would have the option to choose their track.
with mock_payment_processors():
resp = self.client.get(self.urls['course_modes_choose'], follow=True)
self.assertRedirects(resp, self.urls['verify_student_start_flow'])
# For professional ed courses, expect that the student is NOT enrolled
# automatically in the course.
self.assertFalse(CourseEnrollment.is_enrolled(self.user, self.course_key))
# On the first page of the flow, verify that there's a button allowing the user
# to proceed to the payment processor; this is the only action the user is allowed to take.
self.assertContains(resp, 'payment-button')