Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
2ddc90cb
Commit
2ddc90cb
authored
Feb 10, 2015
by
Ben Patterson
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6886 from edx/benp/change-enrollment-event-tests
An upgrade to verified should emit a mode_changed event.
parents
0f92b092
630801c7
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
80 deletions
+72
-80
common/test/acceptance/tests/helpers.py
+18
-0
common/test/acceptance/tests/lms/test_lms.py
+54
-4
lms/djangoapps/courseware/features/change_enrollment.feature
+0
-24
lms/djangoapps/courseware/features/change_enrollment.py
+0
-52
No files found.
common/test/acceptance/tests/helpers.py
View file @
2ddc90cb
...
@@ -234,6 +234,24 @@ def element_has_text(page, css_selector, text):
...
@@ -234,6 +234,24 @@ def element_has_text(page, css_selector, text):
return
text_present
return
text_present
def
assert_event_emitted_num_times
(
event_collection
,
event_name
,
event_time
,
event_user_id
,
num_times_emitted
):
"""
Tests the number of times a particular event was emitted.
:param event_collection: MongoClient instance to query.
:param event_name: Expected event name (e.g., "edx.course.enrollment.activated")
:param event_time: Latest expected time, after which the event would fire (e.g., the beginning of the test case)
"""
assert
(
event_collection
.
find
(
{
"name"
:
event_name
,
"time"
:
{
"$gt"
:
event_time
},
"event.user_id"
:
int
(
event_user_id
),
}
)
.
count
()
==
num_times_emitted
)
class
UniqueCourseTest
(
WebAppTest
):
class
UniqueCourseTest
(
WebAppTest
):
"""
"""
Test that provides a unique course ID.
Test that provides a unique course ID.
...
...
common/test/acceptance/tests/lms/test_lms.py
View file @
2ddc90cb
...
@@ -3,9 +3,11 @@
...
@@ -3,9 +3,11 @@
End-to-end tests for the LMS.
End-to-end tests for the LMS.
"""
"""
from
datetime
import
datetime
from
textwrap
import
dedent
from
textwrap
import
dedent
from
unittest
import
skip
from
unittest
import
skip
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
pymongo
import
MongoClient
from
bok_choy.promise
import
EmptyPromise
from
bok_choy.promise
import
EmptyPromise
from
bok_choy.web_app_test
import
WebAppTest
from
bok_choy.web_app_test
import
WebAppTest
...
@@ -14,7 +16,8 @@ from ..helpers import (
...
@@ -14,7 +16,8 @@ from ..helpers import (
load_data_str
,
load_data_str
,
generate_course_key
,
generate_course_key
,
select_option_by_value
,
select_option_by_value
,
element_has_text
element_has_text
,
assert_event_emitted_num_times
)
)
from
...pages.lms.auto_auth
import
AutoAuthPage
from
...pages.lms.auto_auth
import
AutoAuthPage
from
...pages.lms.create_mode
import
ModeCreationPage
from
...pages.lms.create_mode
import
ModeCreationPage
...
@@ -214,6 +217,8 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -214,6 +217,8 @@ class PayAndVerifyTest(UniqueCourseTest):
self
.
upgrade_page
=
PaymentAndVerificationFlow
(
self
.
browser
,
self
.
course_id
,
entry_point
=
'upgrade'
)
self
.
upgrade_page
=
PaymentAndVerificationFlow
(
self
.
browser
,
self
.
course_id
,
entry_point
=
'upgrade'
)
self
.
fake_payment_page
=
FakePaymentPage
(
self
.
browser
,
self
.
course_id
)
self
.
fake_payment_page
=
FakePaymentPage
(
self
.
browser
,
self
.
course_id
)
self
.
dashboard_page
=
DashboardPage
(
self
.
browser
)
self
.
dashboard_page
=
DashboardPage
(
self
.
browser
)
self
.
event_collection
=
MongoClient
()[
"test"
][
"events"
]
self
.
start_time
=
datetime
.
now
()
# Create a course
# Create a course
CourseFixture
(
CourseFixture
(
...
@@ -232,7 +237,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -232,7 +237,7 @@ class PayAndVerifyTest(UniqueCourseTest):
@skip
(
"Flaky 02/02/2015"
)
@skip
(
"Flaky 02/02/2015"
)
def
test_immediate_verification_enrollment
(
self
):
def
test_immediate_verification_enrollment
(
self
):
# Create a user and log them in
# Create a user and log them in
AutoAuthPage
(
self
.
browser
)
.
visit
()
student_id
=
AutoAuthPage
(
self
.
browser
)
.
visit
()
.
get_user_id
()
# Navigate to the track selection page
# Navigate to the track selection page
self
.
track_selection_page
.
visit
()
self
.
track_selection_page
.
visit
()
...
@@ -246,6 +251,24 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -246,6 +251,24 @@ class PayAndVerifyTest(UniqueCourseTest):
# Submit payment
# Submit payment
self
.
fake_payment_page
.
submit_payment
()
self
.
fake_payment_page
.
submit_payment
()
# Expect enrollment activated event
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.activated"
,
self
.
start_time
,
student_id
,
1
)
# Expect that one mode_changed enrollment event fired as part of the upgrade
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.mode_changed"
,
self
.
start_time
,
student_id
,
1
)
# Proceed to verification
# Proceed to verification
self
.
payment_and_verification_flow
.
immediate_verification
()
self
.
payment_and_verification_flow
.
immediate_verification
()
...
@@ -269,7 +292,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -269,7 +292,7 @@ class PayAndVerifyTest(UniqueCourseTest):
def
test_deferred_verification_enrollment
(
self
):
def
test_deferred_verification_enrollment
(
self
):
# Create a user and log them in
# Create a user and log them in
AutoAuthPage
(
self
.
browser
)
.
visit
()
student_id
=
AutoAuthPage
(
self
.
browser
)
.
visit
()
.
get_user_id
()
# Navigate to the track selection page
# Navigate to the track selection page
self
.
track_selection_page
.
visit
()
self
.
track_selection_page
.
visit
()
...
@@ -283,6 +306,15 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -283,6 +306,15 @@ class PayAndVerifyTest(UniqueCourseTest):
# Submit payment
# Submit payment
self
.
fake_payment_page
.
submit_payment
()
self
.
fake_payment_page
.
submit_payment
()
# Expect enrollment activated event
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.activated"
,
self
.
start_time
,
student_id
,
1
)
# Navigate to the dashboard
# Navigate to the dashboard
self
.
dashboard_page
.
visit
()
self
.
dashboard_page
.
visit
()
...
@@ -292,7 +324,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -292,7 +324,7 @@ class PayAndVerifyTest(UniqueCourseTest):
def
test_enrollment_upgrade
(
self
):
def
test_enrollment_upgrade
(
self
):
# Create a user, log them in, and enroll them in the honor mode
# Create a user, log them in, and enroll them in the honor mode
AutoAuthPage
(
self
.
browser
,
course_id
=
self
.
course_id
)
.
visit
()
student_id
=
AutoAuthPage
(
self
.
browser
,
course_id
=
self
.
course_id
)
.
visit
()
.
get_user_id
()
# Navigate to the dashboard
# Navigate to the dashboard
self
.
dashboard_page
.
visit
()
self
.
dashboard_page
.
visit
()
...
@@ -313,6 +345,24 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -313,6 +345,24 @@ class PayAndVerifyTest(UniqueCourseTest):
# Submit payment
# Submit payment
self
.
fake_payment_page
.
submit_payment
()
self
.
fake_payment_page
.
submit_payment
()
# Expect that one mode_changed enrollment event fired as part of the upgrade
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.mode_changed"
,
self
.
start_time
,
student_id
,
1
)
# Expect no enrollment activated event
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.activated"
,
self
.
start_time
,
student_id
,
0
)
# Navigate to the dashboard
# Navigate to the dashboard
self
.
dashboard_page
.
visit
()
self
.
dashboard_page
.
visit
()
...
...
lms/djangoapps/courseware/features/change_enrollment.feature
deleted
100644 → 0
View file @
0f92b092
Feature
:
Change Enrollment Events
As a registered user
I want to change my enrollment mode
Scenario
:
I
can change my enrollment
Given
The course
"6.002x"
exists
And
the course
"6.002x"
has all enrollment modes
And
I am logged in
And
I visit the courses page
When
I register to audit the course
And
a
"edx.course.enrollment.activated"
server event is emitted
# Skipping the rest in master. The testcase has not been run and no longer works.
#And a "edx.course.enrollment.mode_changed" server events is emitted
#
#And I visit the dashboard
#And I click on Challenge Yourself
#And I choose an honor code upgrade
#Then I should be on the dashboard page
#Then 2 "edx.course.enrollment.mode_changed" server event is emitted
#
## don't emit another mode_changed event upon unenrollment
#When I unenroll from the course numbered "6.002x"
#Then 2 "edx.course.enrollment.mode_changed" server events is emitted
lms/djangoapps/courseware/features/change_enrollment.py
deleted
100644 → 0
View file @
0f92b092
""" Provides lettuce acceptance methods for course enrollment changes """
from
__future__
import
absolute_import
from
lettuce
import
world
,
step
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
logging
import
getLogger
logger
=
getLogger
(
__name__
)
import
time
@step
(
u'the course "([^"]*)" has all enrollment modes$'
)
def
add_enrollment_modes_to_course
(
_step
,
course
):
""" Add honor, audit, and verified modes to the sample course """
world
.
CourseModeFactory
.
create
(
course_id
=
SlashSeparatedCourseKey
(
"edx"
,
course
,
'Test_Course'
),
mode_slug
=
"verified"
,
mode_display_name
=
"Verified Course"
,
min_price
=
3
)
world
.
CourseModeFactory
.
create
(
course_id
=
SlashSeparatedCourseKey
(
"edx"
,
course
,
'Test_Course'
),
mode_slug
=
"honor"
,
mode_display_name
=
"Honor Course"
,
)
world
.
CourseModeFactory
.
create
(
course_id
=
SlashSeparatedCourseKey
(
"edx"
,
course
,
'Test_Course'
),
mode_slug
=
"audit"
,
mode_display_name
=
"Audit Course"
,
)
@step
(
u'I click on Challenge Yourself$'
)
def
challenge_yourself
(
_step
):
""" Simulates clicking 'Challenge Yourself' button on course """
challenge_button
=
world
.
browser
.
find_by_css
(
'.wrapper-tip'
)
challenge_button
.
click
()
verified_button
=
world
.
browser
.
find_by_css
(
'#upgrade-to-verified'
)
verified_button
.
click
()
@step
(
u'I choose an honor code upgrade$'
)
def
honor_code_upgrade
(
_step
):
""" Simulates choosing the honor code mode on the upgrade page """
honor_code_link
=
world
.
browser
.
find_by_css
(
'.title-expand'
)
honor_code_link
.
click
()
time
.
sleep
(
1
)
honor_code_checkbox
=
world
.
browser
.
find_by_css
(
'#honor-code'
)
honor_code_checkbox
.
click
()
upgrade_button
=
world
.
browser
.
find_by_name
(
"certificate_mode"
)
upgrade_button
.
click
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment