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
5fb7932b
Commit
5fb7932b
authored
Apr 01, 2016
by
Zia Fazal
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #663 from edx-solutions/ziafazal/fix-cirlcle-build-timeout
disconnect signals to improve tests time
parents
82265160
4dc03642
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
96 additions
and
30 deletions
+96
-30
cms/djangoapps/contentstore/tests/test_crud.py
+15
-3
lms/djangoapps/instructor_task/tests/test_base.py
+8
-1
lms/envs/test.py
+6
-0
lms/startup.py
+12
-0
openedx/core/djangoapps/content/__init__.py
+0
-5
openedx/core/djangoapps/content/course_metadata/__init__.py
+4
-0
openedx/core/djangoapps/content/course_metadata/signals.py
+1
-1
openedx/core/djangoapps/content/course_metadata/tests.py
+4
-0
openedx/core/djangoapps/content/course_overviews/signals.py
+2
-2
openedx/core/djangoapps/content/course_overviews/tests.py
+8
-1
openedx/core/djangoapps/content/course_structures/__init__.py
+4
-0
openedx/core/djangoapps/content/course_structures/api/v0/tests_api.py
+7
-11
openedx/core/djangoapps/content/course_structures/signals.py
+1
-1
openedx/core/djangoapps/util/testing.py
+24
-5
No files found.
cms/djangoapps/contentstore/tests/test_crud.py
View file @
5fb7932b
import
unittest
"""
Module contains tests for finding and using the templates (boilerplates) for xblocks
"""
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locator
import
LocalId
from
opaque_keys.edx.locator
import
LocalId
from
xmodule
import
templates
from
xmodule
import
templates
...
@@ -7,14 +10,23 @@ from xmodule.modulestore import ModuleStoreEnum
...
@@ -7,14 +10,23 @@ from xmodule.modulestore import ModuleStoreEnum
from
xmodule.modulestore.tests
import
persistent_factories
from
xmodule.modulestore.tests
import
persistent_factories
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.seq_module
import
SequenceDescriptor
from
xmodule.seq_module
import
SequenceDescriptor
from
xmodule.capa_module
import
CapaDescriptor
from
xmodule.capa_module
import
CapaDescriptor
from
xmodule.contentstore.django
import
_CONTENTSTORE
from
xmodule.contentstore.django
import
_CONTENTSTORE
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
DuplicateCourseError
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
,
DuplicateCourseError
from
xmodule.html_module
import
HtmlDescriptor
from
xmodule.html_module
import
HtmlDescriptor
from
openedx.core.djangoapps.util.testing
import
SignalDisconnectTestMixin
# some tests are failed if course indexing is switced on
# so we need to turn it off
FEATURES_WITHOUT_COURSE_INDEXING
=
settings
.
FEATURES
.
copy
()
FEATURES_WITHOUT_COURSE_INDEXING
[
'ENABLE_COURSEWARE_INDEX'
]
=
False
class
TemplateTests
(
unittest
.
TestCase
):
@override_settings
(
FEATURES
=
FEATURES_WITHOUT_COURSE_INDEXING
)
class
TemplateTests
(
SignalDisconnectTestMixin
,
ModuleStoreTestCase
):
"""
"""
Test finding and using the templates (boilerplates) for xblocks.
Test finding and using the templates (boilerplates) for xblocks.
"""
"""
...
...
lms/djangoapps/instructor_task/tests/test_base.py
View file @
5fb7932b
...
@@ -20,9 +20,11 @@ from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey
...
@@ -20,9 +20,11 @@ from opaque_keys.edx.locations import Location, SlashSeparatedCourseKey
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactory
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactory
from
courseware.model_data
import
StudentModule
from
courseware.model_data
import
StudentModule
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
openedx.core.djangoapps.content.course_structures.signals
import
listen_for_course_publish
from
openedx.core.djangoapps.util.testing
import
SignalDisconnectTestMixin
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.django
import
modulestore
,
SignalHandler
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
@@ -108,6 +110,11 @@ class InstructorTaskCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase)
...
@@ -108,6 +110,11 @@ class InstructorTaskCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase)
course
=
None
course
=
None
current_user
=
None
current_user
=
None
def
setUp
(
self
):
super
(
InstructorTaskCourseTestCase
,
self
)
.
setUp
()
SignalHandler
.
course_published
.
connect
(
listen_for_course_publish
)
self
.
addCleanup
(
SignalDisconnectTestMixin
.
disconnect_course_published_signals
)
def
initialize_course
(
self
,
course_factory_kwargs
=
None
):
def
initialize_course
(
self
,
course_factory_kwargs
=
None
):
"""
"""
Create a course in the store, with a chapter and section.
Create a course in the store, with a chapter and section.
...
...
lms/envs/test.py
View file @
5fb7932b
...
@@ -554,6 +554,12 @@ FEATURES['ORGANIZATIONS_APP'] = True
...
@@ -554,6 +554,12 @@ FEATURES['ORGANIZATIONS_APP'] = True
if
FEATURES
.
get
(
'ORGANIZATIONS_APP'
)
and
"organizations"
not
in
INSTALLED_APPS
:
if
FEATURES
.
get
(
'ORGANIZATIONS_APP'
)
and
"organizations"
not
in
INSTALLED_APPS
:
INSTALLED_APPS
+=
(
'organizations'
,)
INSTALLED_APPS
+=
(
'organizations'
,)
# Disable course_published signals
# If we don't disconnect then tests take too much time to run since
# this signal is sent every time course or a course block is created
# via CourseFactory or ItemFactory
FEATURES
[
'DISABLE_COURSE_PUBLISHED_SIGNAL'
]
=
True
# Test mode. Used to let code that might otherwise affect global state know that it shouldn't
# Test mode. Used to let code that might otherwise affect global state know that it shouldn't
# (such as management commands.)
# (such as management commands.)
TEST_MODE
=
True
TEST_MODE
=
True
lms/startup.py
View file @
5fb7932b
...
@@ -3,6 +3,7 @@ Module for code that should run during LMS startup
...
@@ -3,6 +3,7 @@ Module for code that should run during LMS startup
"""
"""
# pylint: disable=unused-argument
# pylint: disable=unused-argument
# pylint: disable=invalid-name
from
django.conf
import
settings
from
django.conf
import
settings
...
@@ -54,6 +55,9 @@ def run():
...
@@ -54,6 +55,9 @@ def run():
if
settings
.
FEATURES
.
get
(
'SEGMENT_IO_LMS'
)
and
hasattr
(
settings
,
'SEGMENT_IO_LMS_KEY'
):
if
settings
.
FEATURES
.
get
(
'SEGMENT_IO_LMS'
)
and
hasattr
(
settings
,
'SEGMENT_IO_LMS_KEY'
):
analytics
.
init
(
settings
.
SEGMENT_IO_LMS_KEY
,
flush_at
=
50
)
analytics
.
init
(
settings
.
SEGMENT_IO_LMS_KEY
,
flush_at
=
50
)
if
settings
.
FEATURES
.
get
(
'DISABLE_COURSE_PUBLISHED_SIGNAL'
,
False
):
disable_course_published_signals
()
def
add_mimetypes
():
def
add_mimetypes
():
"""
"""
...
@@ -155,6 +159,14 @@ def enable_third_party_auth():
...
@@ -155,6 +159,14 @@ def enable_third_party_auth():
auth_settings
.
apply_settings
(
settings
)
auth_settings
.
apply_settings
(
settings
)
def
disable_course_published_signals
():
"""
Disables course_published signal receivers in openedx.core.djangoapps
"""
from
openedx.core.djangoapps.util.testing
import
SignalDisconnectTestMixin
SignalDisconnectTestMixin
.
disconnect_course_published_signals
()
def
startup_notification_subsystem
():
def
startup_notification_subsystem
():
"""
"""
Initialize the Notification subsystem
Initialize the Notification subsystem
...
...
openedx/core/djangoapps/content/__init__.py
View file @
5fb7932b
"""
Setup the signals on startup.
"""
import
openedx.core.djangoapps.content.course_structures.signals
import
openedx.core.djangoapps.content.course_metadata.signals
openedx/core/djangoapps/content/course_metadata/__init__.py
View file @
5fb7932b
"""
Setup the signals on startup.
"""
import
openedx.core.djangoapps.content.course_metadata.signals
# pylint: disable=unused-import
openedx/core/djangoapps/content/course_metadata/signals.py
View file @
5fb7932b
...
@@ -7,7 +7,7 @@ from xmodule.modulestore.django import SignalHandler
...
@@ -7,7 +7,7 @@ from xmodule.modulestore.django import SignalHandler
from
openedx.core.djangoapps.content.course_metadata.tasks
import
update_course_aggregate_metadata
from
openedx.core.djangoapps.content.course_metadata.tasks
import
update_course_aggregate_metadata
@receiver
(
SignalHandler
.
course_published
)
@receiver
(
SignalHandler
.
course_published
,
dispatch_uid
=
'openedx.core.djangoapps.content.course_metadata'
)
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
"""
"""
Receives signal and kicks off celery task to update course aggregate metadata
Receives signal and kicks off celery task to update course aggregate metadata
...
...
openedx/core/djangoapps/content/course_metadata/tests.py
View file @
5fb7932b
...
@@ -9,12 +9,14 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
...
@@ -9,12 +9,14 @@ from xmodule.modulestore.tests.factories import CourseFactory, ItemFactory
from
openedx.core.djangoapps.content.course_metadata.signals
import
listen_for_course_publish
from
openedx.core.djangoapps.content.course_metadata.signals
import
listen_for_course_publish
from
openedx.core.djangoapps.content.course_metadata.models
import
CourseAggregatedMetaData
from
openedx.core.djangoapps.content.course_metadata.models
import
CourseAggregatedMetaData
from
openedx.core.djangoapps.util.testing
import
SignalDisconnectTestMixin
class
CoursesMetaDataTests
(
ModuleStoreTestCase
):
class
CoursesMetaDataTests
(
ModuleStoreTestCase
):
""" Test suite for Course Meta Data """
""" Test suite for Course Meta Data """
def
setUp
(
self
):
def
setUp
(
self
):
SignalHandler
.
course_published
.
connect
(
listen_for_course_publish
)
super
(
CoursesMetaDataTests
,
self
)
.
setUp
()
super
(
CoursesMetaDataTests
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
self
.
course
=
CourseFactory
.
create
()
...
@@ -44,6 +46,8 @@ class CoursesMetaDataTests(ModuleStoreTestCase):
...
@@ -44,6 +46,8 @@ class CoursesMetaDataTests(ModuleStoreTestCase):
display_name
=
"Html component"
display_name
=
"Html component"
)
)
self
.
addCleanup
(
SignalDisconnectTestMixin
.
disconnect_course_published_signals
)
def
test_course_aggregate_metadata_update_on_course_published
(
self
):
def
test_course_aggregate_metadata_update_on_course_published
(
self
):
"""
"""
Test course aggregate metadata update receiver is called on course_published signal
Test course aggregate metadata update receiver is called on course_published signal
...
...
openedx/core/djangoapps/content/course_overviews/signals.py
View file @
5fb7932b
...
@@ -8,8 +8,8 @@ from xmodule.modulestore.django import SignalHandler
...
@@ -8,8 +8,8 @@ from xmodule.modulestore.django import SignalHandler
from
.models
import
CourseOverview
from
.models
import
CourseOverview
@receiver
(
SignalHandler
.
course_published
)
@receiver
(
SignalHandler
.
course_published
,
dispatch_uid
=
'openedx.core.djangoapps.content.course_overviews'
)
def
_
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
"""
"""
Catches the signal that a course has been published in Studio and
Catches the signal that a course has been published in Studio and
invalidates the corresponding CourseOverview cache entry if one exists.
invalidates the corresponding CourseOverview cache entry if one exists.
...
...
openedx/core/djangoapps/content/course_overviews/tests.py
View file @
5fb7932b
...
@@ -13,9 +13,11 @@ from lms.djangoapps.certificates.api import get_active_web_certificate
...
@@ -13,9 +13,11 @@ from lms.djangoapps.certificates.api import get_active_web_certificate
from
lms.djangoapps.courseware.courses
import
course_image_url
from
lms.djangoapps.courseware.courses
import
course_image_url
from
xmodule.course_metadata_utils
import
DEFAULT_START_DATE
from
xmodule.course_metadata_utils
import
DEFAULT_START_DATE
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
SignalHandler
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
check_mongo_calls
,
check_mongo_calls_range
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
check_mongo_calls
,
check_mongo_calls_range
from
openedx.core.djangoapps.util.testing
import
SignalDisconnectTestMixin
from
openedx.core.djangoapps.content.course_overviews.signals
import
listen_for_course_publish
from
.models
import
CourseOverview
from
.models
import
CourseOverview
...
@@ -31,6 +33,11 @@ class CourseOverviewTestCase(ModuleStoreTestCase):
...
@@ -31,6 +33,11 @@ class CourseOverviewTestCase(ModuleStoreTestCase):
NEXT_WEEK
=
TODAY
+
datetime
.
timedelta
(
days
=
7
)
NEXT_WEEK
=
TODAY
+
datetime
.
timedelta
(
days
=
7
)
NEXT_MONTH
=
TODAY
+
datetime
.
timedelta
(
days
=
30
)
NEXT_MONTH
=
TODAY
+
datetime
.
timedelta
(
days
=
30
)
def
setUp
(
self
):
super
(
CourseOverviewTestCase
,
self
)
.
setUp
()
SignalHandler
.
course_published
.
connect
(
listen_for_course_publish
)
self
.
addCleanup
(
SignalDisconnectTestMixin
.
disconnect_course_published_signals
)
def
check_course_overview_against_course
(
self
,
course
):
def
check_course_overview_against_course
(
self
,
course
):
"""
"""
Compares a CourseOverview object against its corresponding
Compares a CourseOverview object against its corresponding
...
...
openedx/core/djangoapps/content/course_structures/__init__.py
View file @
5fb7932b
"""
Setup the signals on startup.
"""
import
openedx.core.djangoapps.content.course_structures.signals
# pylint: disable=unused-import
openedx/core/djangoapps/content/course_structures/api/v0/tests_api.py
View file @
5fb7932b
"""
"""
Course Structure api.py tests
Course Structure api.py tests
"""
"""
import
mock
from
django.core
import
cache
from
.api
import
course_structure
from
.api
import
course_structure
from
openedx.core.djangoapps.content.course_structures.signals
import
listen_for_course_publish
from
xmodule.modulestore.django
import
SignalHandler
from
xmodule.modulestore.django
import
SignalHandler
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
import
mock
from
django.core
import
cache
from
openedx.core.djangoapps.content.course_structures.signals
import
listen_for_course_publish
from
openedx.core.djangoapps.util.testing
import
SignalDisconnectTestMixin
class
CourseStructureApiTests
(
ModuleStoreTestCase
):
class
CourseStructureApiTests
(
ModuleStoreTestCase
):
...
@@ -42,14 +45,7 @@ class CourseStructureApiTests(ModuleStoreTestCase):
...
@@ -42,14 +45,7 @@ class CourseStructureApiTests(ModuleStoreTestCase):
parent_location
=
self
.
vertical
.
location
,
category
=
"html"
,
display_name
=
"My HTML"
parent_location
=
self
.
vertical
.
location
,
category
=
"html"
,
display_name
=
"My HTML"
)
)
self
.
addCleanup
(
self
.
_disconnect_course_published_event
)
self
.
addCleanup
(
SignalDisconnectTestMixin
.
disconnect_course_published_signals
)
def
_disconnect_course_published_event
(
self
):
"""
Disconnect course_published event.
"""
# If we don't disconnect then tests are getting failed in test_crud.py
SignalHandler
.
course_published
.
disconnect
(
listen_for_course_publish
)
def
_expected_blocks
(
self
,
block_types
=
None
,
get_parent
=
False
):
def
_expected_blocks
(
self
,
block_types
=
None
,
get_parent
=
False
):
"""
"""
...
...
openedx/core/djangoapps/content/course_structures/signals.py
View file @
5fb7932b
...
@@ -3,7 +3,7 @@ from django.dispatch.dispatcher import receiver
...
@@ -3,7 +3,7 @@ from django.dispatch.dispatcher import receiver
from
xmodule.modulestore.django
import
SignalHandler
from
xmodule.modulestore.django
import
SignalHandler
@receiver
(
SignalHandler
.
course_published
)
@receiver
(
SignalHandler
.
course_published
,
dispatch_uid
=
'openedx.core.djangoapps.content.course_structures'
)
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
def
listen_for_course_publish
(
sender
,
course_key
,
**
kwargs
):
# pylint: disable=unused-argument
# Import tasks here to avoid a circular import.
# Import tasks here to avoid a circular import.
from
.tasks
import
update_course_structure
from
.tasks
import
update_course_structure
...
...
openedx/core/djangoapps/util/testing.py
View file @
5fb7932b
...
@@ -11,9 +11,14 @@ from student.tests.factories import CourseEnrollmentFactory, UserFactory
...
@@ -11,9 +11,14 @@ from student.tests.factories import CourseEnrollmentFactory, UserFactory
from
openedx.core.djangoapps.course_groups.models
import
CourseUserGroupPartitionGroup
from
openedx.core.djangoapps.course_groups.models
import
CourseUserGroupPartitionGroup
from
openedx.core.djangoapps.course_groups.tests.helpers
import
CohortFactory
from
openedx.core.djangoapps.course_groups.tests.helpers
import
CohortFactory
from
openedx.core.djangoapps.content.course_structures.signals
import
listen_for_course_publish
from
openedx.core.djangoapps.content.course_structures.signals
import
(
listen_for_course_publish
as
listener_in_course_structures
)
from
openedx.core.djangoapps.content.course_metadata.signals
import
(
from
openedx.core.djangoapps.content.course_metadata.signals
import
(
listen_for_course_publish
as
course_publish_listener
listen_for_course_publish
as
listener_in_course_metadata
)
from
openedx.core.djangoapps.content.course_overviews.signals
import
(
listen_for_course_publish
as
listener_in_course_overviews
)
)
from
openedx.core.djangoapps.user_api.tests.factories
import
UserCourseTagFactory
from
openedx.core.djangoapps.user_api.tests.factories
import
UserCourseTagFactory
...
@@ -217,10 +222,24 @@ class TestConditionalContent(ModuleStoreTestCase):
...
@@ -217,10 +222,24 @@ class TestConditionalContent(ModuleStoreTestCase):
class
SignalDisconnectTestMixin
(
object
):
class
SignalDisconnectTestMixin
(
object
):
"""
"""
Mixin for tests to disable calls to signals.
listen_for_course_publish when the course_published signal is fired.
Mixin for tests to disable calls to signals.
"""
"""
def
setUp
(
self
):
def
setUp
(
self
):
super
(
SignalDisconnectTestMixin
,
self
)
.
setUp
()
super
(
SignalDisconnectTestMixin
,
self
)
.
setUp
()
SignalHandler
.
course_published
.
disconnect
(
listen_for_course_publish
)
SignalDisconnectTestMixin
.
disconnect_course_published_signals
()
SignalHandler
.
course_published
.
disconnect
(
course_publish_listener
)
@staticmethod
def
disconnect_course_published_signals
():
"""
Disconnects receivers from course_published signals
"""
SignalHandler
.
course_published
.
disconnect
(
listener_in_course_structures
,
dispatch_uid
=
'openedx.core.djangoapps.content.course_structures'
)
SignalHandler
.
course_published
.
disconnect
(
listener_in_course_metadata
,
dispatch_uid
=
'openedx.core.djangoapps.content.course_metadata'
)
SignalHandler
.
course_published
.
disconnect
(
listener_in_course_overviews
,
dispatch_uid
=
'openedx.core.djangoapps.content.course_overviews'
)
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