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
3539bac1
Commit
3539bac1
authored
Feb 25, 2015
by
Ben Patterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Event-testing pattern should be supported by a mixin.
parent
ee0ae6ee
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
37 deletions
+37
-37
common/test/acceptance/tests/discussion/test_cohort_management.py
+2
-6
common/test/acceptance/tests/helpers.py
+27
-14
common/test/acceptance/tests/lms/test_lms.py
+8
-17
No files found.
common/test/acceptance/tests/discussion/test_cohort_management.py
View file @
3539bac1
...
@@ -5,13 +5,11 @@ End-to-end tests related to the cohort management on the LMS Instructor Dashboar
...
@@ -5,13 +5,11 @@ End-to-end tests related to the cohort management on the LMS Instructor Dashboar
from
datetime
import
datetime
from
datetime
import
datetime
from
pymongo
import
MongoClient
from
pytz
import
UTC
,
utc
from
pytz
import
UTC
,
utc
from
bok_choy.promise
import
EmptyPromise
from
bok_choy.promise
import
EmptyPromise
from
nose.plugins.attrib
import
attr
from
nose.plugins.attrib
import
attr
from
.helpers
import
CohortTestMixin
from
.helpers
import
CohortTestMixin
from
..helpers
import
UniqueCourseTest
,
create_user_partition_json
from
..helpers
import
UniqueCourseTest
,
EventsTestMixin
,
create_user_partition_json
from
xmodule.partitions.partitions
import
Group
from
xmodule.partitions.partitions
import
Group
from
...fixtures.course
import
CourseFixture
from
...fixtures.course
import
CourseFixture
from
...pages.lms.auto_auth
import
AutoAuthPage
from
...pages.lms.auto_auth
import
AutoAuthPage
...
@@ -23,7 +21,7 @@ import uuid
...
@@ -23,7 +21,7 @@ import uuid
@attr
(
'shard_3'
)
@attr
(
'shard_3'
)
class
CohortConfigurationTest
(
UniqueCourseTest
,
CohortTestMixin
):
class
CohortConfigurationTest
(
EventsTestMixin
,
UniqueCourseTest
,
CohortTestMixin
):
"""
"""
Tests for cohort management on the LMS Instructor Dashboard
Tests for cohort management on the LMS Instructor Dashboard
"""
"""
...
@@ -34,8 +32,6 @@ class CohortConfigurationTest(UniqueCourseTest, CohortTestMixin):
...
@@ -34,8 +32,6 @@ class CohortConfigurationTest(UniqueCourseTest, CohortTestMixin):
"""
"""
super
(
CohortConfigurationTest
,
self
)
.
setUp
()
super
(
CohortConfigurationTest
,
self
)
.
setUp
()
self
.
event_collection
=
MongoClient
()[
"test"
][
"events"
]
# create course with cohorts
# create course with cohorts
self
.
manual_cohort_name
=
"ManualCohort1"
self
.
manual_cohort_name
=
"ManualCohort1"
self
.
auto_cohort_name
=
"AutoCohort1"
self
.
auto_cohort_name
=
"AutoCohort1"
...
...
common/test/acceptance/tests/helpers.py
View file @
3539bac1
...
@@ -6,10 +6,12 @@ import unittest
...
@@ -6,10 +6,12 @@ import unittest
import
functools
import
functools
import
requests
import
requests
import
os
import
os
from
datetime
import
datetime
from
path
import
path
from
path
import
path
from
bok_choy.javascript
import
js_defined
from
bok_choy.javascript
import
js_defined
from
bok_choy.web_app_test
import
WebAppTest
from
bok_choy.web_app_test
import
WebAppTest
from
opaque_keys.edx.locator
import
CourseLocator
from
opaque_keys.edx.locator
import
CourseLocator
from
pymongo
import
MongoClient
from
xmodule.partitions.partitions
import
UserPartition
from
xmodule.partitions.partitions
import
UserPartition
from
xmodule.partitions.tests.test_partitions
import
MockUserPartitionScheme
from
xmodule.partitions.tests.test_partitions
import
MockUserPartitionScheme
from
selenium.webdriver.support.select
import
Select
from
selenium.webdriver.support.select
import
Select
...
@@ -236,33 +238,44 @@ def element_has_text(page, css_selector, text):
...
@@ -236,33 +238,44 @@ 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
):
def
get_modal_alert
(
browser
):
"""
Returns instance of modal alert box shown in browser after waiting
for 4 seconds
"""
WebDriverWait
(
browser
,
4
)
.
until
(
EC
.
alert_is_present
())
return
browser
.
switch_to
.
alert
class
EventsTestMixin
(
object
):
"""
Helpers and setup for running tests that evaluate events emitted
"""
def
setUp
(
self
):
super
(
EventsTestMixin
,
self
)
.
setUp
()
self
.
event_collection
=
MongoClient
()[
"test"
][
"events"
]
self
.
event_collection
.
drop
()
self
.
start_time
=
datetime
.
now
()
def
assert_event_emitted_num_times
(
self
,
event_name
,
event_time
,
event_user_id
,
num_times_emitted
):
"""
"""
Tests the number of times a particular event was 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_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)
:param event_time: Latest expected time, after which the event would fire (e.g., the beginning of the test case)
:param event_user_id: user_id expected in the event
:param num_times_emitted: number of times the event is expected to appear since the event_time
"""
"""
assert
(
self
.
assertEqual
(
event_collection
.
find
(
self
.
event_collection
.
find
(
{
{
"name"
:
event_name
,
"name"
:
event_name
,
"time"
:
{
"$gt"
:
event_time
},
"time"
:
{
"$gt"
:
event_time
},
"event.user_id"
:
int
(
event_user_id
),
"event.user_id"
:
int
(
event_user_id
),
}
}
)
.
count
()
==
num_times_emitted
)
.
count
(),
num_times_emitted
)
)
def
get_modal_alert
(
browser
):
"""
Returns instance of modal alert box shown in browser after waiting
for 4 seconds
"""
WebDriverWait
(
browser
,
4
)
.
until
(
EC
.
alert_is_present
())
return
browser
.
switch_to
.
alert
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 @
3539bac1
...
@@ -3,21 +3,19 @@
...
@@ -3,21 +3,19 @@
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
from
..helpers
import
(
from
..helpers
import
(
UniqueCourseTest
,
UniqueCourseTest
,
EventsTestMixin
,
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
...
@@ -201,7 +199,7 @@ class RegisterFromCombinedPageTest(UniqueCourseTest):
...
@@ -201,7 +199,7 @@ class RegisterFromCombinedPageTest(UniqueCourseTest):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
class
PayAndVerifyTest
(
UniqueCourseTest
):
class
PayAndVerifyTest
(
EventsTestMixin
,
UniqueCourseTest
):
"""Test that we can proceed through the payment and verification flow."""
"""Test that we can proceed through the payment and verification flow."""
def
setUp
(
self
):
def
setUp
(
self
):
"""Initialize the test.
"""Initialize the test.
...
@@ -217,8 +215,6 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -217,8 +215,6 @@ 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
(
...
@@ -252,8 +248,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -252,8 +248,7 @@ class PayAndVerifyTest(UniqueCourseTest):
self
.
fake_payment_page
.
submit_payment
()
self
.
fake_payment_page
.
submit_payment
()
# Expect enrollment activated event
# Expect enrollment activated event
assert_event_emitted_num_times
(
self
.
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.activated"
,
"edx.course.enrollment.activated"
,
self
.
start_time
,
self
.
start_time
,
student_id
,
student_id
,
...
@@ -261,8 +256,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -261,8 +256,7 @@ class PayAndVerifyTest(UniqueCourseTest):
)
)
# Expect that one mode_changed enrollment event fired as part of the upgrade
# Expect that one mode_changed enrollment event fired as part of the upgrade
assert_event_emitted_num_times
(
self
.
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.mode_changed"
,
"edx.course.enrollment.mode_changed"
,
self
.
start_time
,
self
.
start_time
,
student_id
,
student_id
,
...
@@ -307,8 +301,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -307,8 +301,7 @@ class PayAndVerifyTest(UniqueCourseTest):
self
.
fake_payment_page
.
submit_payment
()
self
.
fake_payment_page
.
submit_payment
()
# Expect enrollment activated event
# Expect enrollment activated event
assert_event_emitted_num_times
(
self
.
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.activated"
,
"edx.course.enrollment.activated"
,
self
.
start_time
,
self
.
start_time
,
student_id
,
student_id
,
...
@@ -346,8 +339,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -346,8 +339,7 @@ class PayAndVerifyTest(UniqueCourseTest):
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
# Expect that one mode_changed enrollment event fired as part of the upgrade
assert_event_emitted_num_times
(
self
.
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.mode_changed"
,
"edx.course.enrollment.mode_changed"
,
self
.
start_time
,
self
.
start_time
,
student_id
,
student_id
,
...
@@ -355,8 +347,7 @@ class PayAndVerifyTest(UniqueCourseTest):
...
@@ -355,8 +347,7 @@ class PayAndVerifyTest(UniqueCourseTest):
)
)
# Expect no enrollment activated event
# Expect no enrollment activated event
assert_event_emitted_num_times
(
self
.
assert_event_emitted_num_times
(
self
.
event_collection
,
"edx.course.enrollment.activated"
,
"edx.course.enrollment.activated"
,
self
.
start_time
,
self
.
start_time
,
student_id
,
student_id
,
...
...
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