This commit is contained in:
asadiqbal
2017-01-11 13:27:24 +05:00
committed by Ayesha Baig
parent c7ff473e6d
commit 8f5ba0115c
8 changed files with 271 additions and 11 deletions

View File

@@ -272,6 +272,7 @@ def create_mode(request, course_id):
`min_price` (int): The minimum price a user must pay to enroll in the new course mode
`suggested_prices` (str): Comma-separated prices to suggest to the user.
`currency` (str): The currency in which to list prices.
`sku` (str): The product SKU value.
By default, this endpoint will create an 'honor' mode for the given course with display name
'Honor Code', a minimum price of 0, no suggested prices, and using USD as the currency.
@@ -289,6 +290,7 @@ def create_mode(request, course_id):
'min_price': 0,
'suggested_prices': u'',
'currency': u'usd',
'sku': None,
}
# Try pulling querystring parameters out of the request

View File

@@ -14,7 +14,8 @@ class ModeCreationPage(PageObject):
created for an existing course.
"""
def __init__(self, browser, course_id, mode_slug=None, mode_display_name=None, min_price=None, suggested_prices=None, currency=None):
def __init__(self, browser, course_id, mode_slug=None, mode_display_name=None, min_price=None,
suggested_prices=None, currency=None, sku=None):
"""The mode creation page is an endpoint for HTTP GET requests.
By default, it will create an 'honor' mode for the given course with display name
@@ -30,6 +31,7 @@ class ModeCreationPage(PageObject):
min_price (int): The minimum price a user must pay to enroll in the new course mode
suggested_prices (str): Comma-separated prices to suggest to the user.
currency (str): The currency in which to list prices.
sku (str): The product SKU value.
"""
super(ModeCreationPage, self).__init__(browser)
@@ -51,6 +53,9 @@ class ModeCreationPage(PageObject):
if currency is not None:
self._parameters['currency'] = currency
if sku is not None:
self._parameters['sku'] = sku
@property
def url(self):
"""Construct the mode creation URL."""

View File

@@ -92,6 +92,15 @@ class InstructorDashboardPage(CoursePage):
email_section.wait_for_page()
return email_section
def select_ecommerce_tab(self):
"""
Selects the E-commerce tab and returns an EcommercePage.
"""
self.q(css='[data-section="e-commerce"]').first.click()
ecommerce_section = EcommercePage(self.browser)
ecommerce_section.wait_for_page()
return ecommerce_section
@staticmethod
def get_asset_path(file_name):
"""
@@ -1416,3 +1425,19 @@ class CertificatesPage(PageObject):
Returns the message (error/success) in "Certificate Invalidation" section.
"""
return self.get_selector('.certificate-invalidation-container div.message')
class EcommercePage(PageObject):
"""
E-commerce section of the Instructor dashboard.
"""
url = None
def is_browser_on_page(self):
return self.q(css='[data-section="e-commerce"].active-section').present
def get_sections_header_values(self):
"""
Returns a list of the headings text under div.
"""
return self.q(css="div.wrap h3").text

View File

@@ -1202,3 +1202,112 @@ class CertificateInvalidationTest(BaseInstructorDashboardTest):
'.certificates-wrapper'
])
self.certificates_section.a11y_audit.check_for_accessibility_errors()
@attr(shard=10)
class EcommerceTest(BaseInstructorDashboardTest):
"""
Bok Choy tests for the "E-Commerce" tab.
"""
def setUp(self):
super(EcommerceTest, self).setUp()
def setup_course(self, course_number):
"""
Sets up the course
"""
self.course_info['number'] = course_number
course_fixture = CourseFixture(
self.course_info["org"],
self.course_info["number"],
self.course_info["run"],
self.course_info["display_name"]
)
course_fixture.install()
def log_in_as_unique_user(self):
"""
Log in as a valid lms user.
"""
AutoAuthPage(
self.browser,
username="test_instructor",
email="test_instructor@example.com",
password="password",
course_id=self.course_id
).visit()
def visit_ecommerce_section(self):
"""
Log in to visit Instructor dashboard and click E-commerce tab
"""
self.log_in_as_unique_user()
instructor_dashboard_page = self.visit_instructor_dashboard()
return instructor_dashboard_page.select_ecommerce_tab()
def add_course_mode(self, sku_value=None):
"""
Add an honor mode to the course
"""
ModeCreationPage(browser=self.browser, course_id=self.course_id, mode_slug=u'honor', min_price=10,
sku=sku_value).visit()
def test_enrollment_codes_section_visible_for_non_ecommerce_course(self):
"""
Test Enrollment Codes UI, under E-commerce Tab, should be visible in the Instructor Dashboard with non
e-commerce course
"""
# Setup course
non_ecommerce_course_number = "34039497242734583224814321005482849780"
self.setup_course(non_ecommerce_course_number)
# Add an honor mode to the course
self.add_course_mode()
# Log in and visit E-commerce section under Instructor dashboard
self.assertIn(u'Enrollment Codes', self.visit_ecommerce_section().get_sections_header_values())
def test_coupon_codes_section_visible_for_non_ecommerce_course(self):
"""
Test Coupon Codes UI, under E-commerce Tab, should be visible in the Instructor Dashboard with non
e-commerce course
"""
# Setup course
non_ecommerce_course_number = "34039497242734583224814321005482849781"
self.setup_course(non_ecommerce_course_number)
# Add an honor mode to the course
self.add_course_mode()
# Log in and visit E-commerce section under Instructor dashboard
self.assertIn(u'Coupon Code List', self.visit_ecommerce_section().get_sections_header_values())
def test_enrollment_codes_section_not_visible_for_ecommerce_course(self):
"""
Test Enrollment Codes UI, under E-commerce Tab, should not be visible in the Instructor Dashboard with
e-commerce course
"""
# Setup course
ecommerce_course_number = "34039497242734583224814321005482849782"
self.setup_course(ecommerce_course_number)
# Add an honor mode to the course with sku value
self.add_course_mode('test_sku')
# Log in and visit E-commerce section under Instructor dashboard
self.assertNotIn(u'Enrollment Codes', self.visit_ecommerce_section().get_sections_header_values())
def test_coupon_codes_section_not_visible_for_ecommerce_course(self):
"""
Test Coupon Codes UI, under E-commerce Tab, should not be visible in the Instructor Dashboard with
e-commerce course
"""
# Setup course
ecommerce_course_number = "34039497242734583224814321005482849783"
self.setup_course(ecommerce_course_number)
# Add an honor mode to the course with sku value
self.add_course_mode('test_sku')
# Log in and visit E-commerce section under Instructor dashboard
self.assertNotIn(u'Coupon Code List', self.visit_ecommerce_section().get_sections_header_values())

View File

@@ -0,0 +1,74 @@
[
{
"pk": 1,
"model": "auth.user",
"fields": {
"username": "test_instructor",
"email":"test_instructor@example.com",
"password": "password",
"is_staff": true,
"is_active": true
}
},
{
"pk": 1,
"model": "student.userprofile",
"fields": {
"user": 1,
"name": "test instructor",
"courseware": "course.xml"
}
},
{
"pk": 1,
"model": "student.registration",
"fields": {
"user": 1,
"activation_key": "52bfac10384d49219385dcd4cc17177q"
}
},
{
"pk": 1,
"model": "student.courseaccessrole",
"fields": {
"id": "1",
"org": "test_org",
"course_id": "course-v1:test_org+34039497242734583224814321005482849780+test_run",
"role": "finance_admin",
"user_id": "1"
}
},
{
"pk": 2,
"model": "student.courseaccessrole",
"fields": {
"id": "2",
"org": "test_org",
"course_id": "course-v1:test_org+34039497242734583224814321005482849781+test_run",
"role": "finance_admin",
"user_id": "1"
}
},
{
"pk": 3,
"model": "student.courseaccessrole",
"fields": {
"id": "3",
"org": "test_org",
"course_id": "course-v1:test_org+34039497242734583224814321005482849782+test_run",
"role": "finance_admin",
"user_id": "1"
}
},
{
"pk": 4,
"model": "student.courseaccessrole",
"fields": {
"id": "4",
"org": "test_org",
"course_id": "course-v1:test_org+34039497242734583224814321005482849783+test_run",
"role": "finance_admin",
"user_id": "1"
}
}
]