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
24a41dc5
Commit
24a41dc5
authored
Aug 26, 2015
by
Bill DeRusha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve teams test run times by skipping signals
TNL-3126 add **kwargs to skip_signal method
parent
ba1b8421
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
8 deletions
+53
-8
common/test/utils.py
+11
-0
lms/djangoapps/teams/search_indexes.py
+1
-1
lms/djangoapps/teams/tests/test_views.py
+41
-7
No files found.
common/test/utils.py
View file @
24a41dc5
...
...
@@ -96,3 +96,14 @@ class MockSignalHandlerMixin(object):
del
kwargs
[
'exclude_args'
]
self
.
assertEqual
(
mock_args
,
args
)
self
.
assertEqual
(
mock_kwargs
,
dict
(
kwargs
,
signal
=
mock_signal
))
@contextmanager
def
skip_signal
(
signal
,
**
kwargs
):
"""
ContextManager to skip a signal by disconnecting it, yielding,
and then reconnecting the signal.
"""
signal
.
disconnect
(
**
kwargs
)
yield
signal
.
connect
(
**
kwargs
)
lms/djangoapps/teams/search_indexes.py
View file @
24a41dc5
...
...
@@ -88,7 +88,7 @@ class CourseTeamIndexer(object):
return
settings
.
FEATURES
.
get
(
cls
.
ENABLE_SEARCH_KEY
,
False
)
@receiver
(
post_save
,
sender
=
CourseTeam
)
@receiver
(
post_save
,
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
)
def
course_team_post_save_callback
(
**
kwargs
):
"""
Reindex object after save.
...
...
lms/djangoapps/teams/tests/test_views.py
View file @
24a41dc5
...
...
@@ -4,21 +4,22 @@ import json
import
pytz
from
datetime
import
datetime
from
dateutil
import
parser
import
ddt
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
django.db.models.signals
import
post_save
from
nose.plugins.attrib
import
attr
from
rest_framework.test
import
APITestCase
,
APIClient
from
courseware.tests.factories
import
StaffFactory
from
common.test.utils
import
skip_signal
from
student.tests.factories
import
UserFactory
,
AdminFactory
,
CourseEnrollmentFactory
from
student.models
import
CourseEnrollment
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
.factories
import
CourseTeamFactory
,
LAST_ACTIVITY_AT
from
..search_indexes
import
CourseTeamIndexer
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
from
..search_indexes
import
CourseTeamIndexer
,
CourseTeam
,
course_team_post_save_callback
from
django_comment_common.models
import
Role
,
FORUM_ROLE_COMMUNITY_TA
from
django_comment_common.utils
import
seed_permissions_roles
...
...
@@ -194,9 +195,12 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
username
=
'student_enrolled_other_course_not_on_team'
)
# clear the teams search index before rebuilding teams
CourseTeamIndexer
.
engine
()
.
destroy
()
with
skip_signal
(
post_save
,
receiver
=
course_team_post_save_callback
,
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
):
# 'solar team' is intentionally lower case to test case insensitivity in name ordering
self
.
test_team_1
=
CourseTeamFactory
.
create
(
name
=
u'sólar team'
,
...
...
@@ -205,7 +209,11 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
)
self
.
test_team_2
=
CourseTeamFactory
.
create
(
name
=
'Wind Team'
,
course_id
=
self
.
test_course_1
.
id
)
self
.
test_team_3
=
CourseTeamFactory
.
create
(
name
=
'Nuclear Team'
,
course_id
=
self
.
test_course_1
.
id
)
self
.
test_team_4
=
CourseTeamFactory
.
create
(
name
=
'Coal Team'
,
course_id
=
self
.
test_course_1
.
id
,
is_active
=
False
)
self
.
test_team_4
=
CourseTeamFactory
.
create
(
name
=
'Coal Team'
,
course_id
=
self
.
test_course_1
.
id
,
is_active
=
False
)
self
.
test_team_5
=
CourseTeamFactory
.
create
(
name
=
'Another Team'
,
course_id
=
self
.
test_course_2
.
id
)
self
.
test_team_6
=
CourseTeamFactory
.
create
(
name
=
'Public Profile Team'
,
...
...
@@ -227,6 +235,8 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
self
.
test_team_3
,
self
.
test_team_4
,
self
.
test_team_5
,
self
.
test_team_6
,
self
.
test_team_7
,
)}
for
user
,
course
in
[(
'staff'
,
self
.
test_course_1
),
(
'course_staff'
,
self
.
test_course_1
)]:
...
...
@@ -455,6 +465,12 @@ class TestListTeamsAPI(TeamAPITestCase):
# Make "solar team" the most recently active team.
# The CourseTeamFactory sets the last_activity_at to a fixed time (in the past), so all of the
# other teams have the same last_activity_at.
with
skip_signal
(
post_save
,
receiver
=
course_team_post_save_callback
,
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
):
solar_team
=
self
.
test_team_name_id_map
[
u'sólar team'
]
solar_team
.
last_activity_at
=
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
utc
)
solar_team
.
save
()
...
...
@@ -508,6 +524,12 @@ class TestListTeamsAPI(TeamAPITestCase):
)
@ddt.unpack
def
test_text_search
(
self
,
text_search
,
expected_team_names
):
# clear out the teams search index before reindexing
CourseTeamIndexer
.
engine
()
.
destroy
()
for
team
in
self
.
test_team_name_id_map
.
values
():
CourseTeamIndexer
.
index
(
team
)
self
.
verify_names
(
{
'course_id'
:
self
.
test_course_2
.
id
,
'text_search'
:
text_search
},
200
,
...
...
@@ -797,6 +819,12 @@ class TestListTopicsAPI(TeamAPITestCase):
)
@ddt.unpack
def
test_order_by
(
self
,
field
,
status
,
names
,
expected_ordering
):
with
skip_signal
(
post_save
,
receiver
=
course_team_post_save_callback
,
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
):
# Add 2 teams to "Nuclear Power", which previously had no teams.
CourseTeamFactory
.
create
(
name
=
u'Nuclear Team 1'
,
course_id
=
self
.
test_course_1
.
id
,
topic_id
=
'topic_2'
...
...
@@ -817,6 +845,12 @@ class TestListTopicsAPI(TeamAPITestCase):
Ensure that the secondary sort (alphabetical) when primary sort is team_count
works across pagination boundaries.
"""
with
skip_signal
(
post_save
,
receiver
=
course_team_post_save_callback
,
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
):
# Add 2 teams to "Wind Power", which previously had no teams.
CourseTeamFactory
.
create
(
name
=
u'Wind Team 1'
,
course_id
=
self
.
test_course_1
.
id
,
topic_id
=
'topic_1'
...
...
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