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
43ac38aa
Commit
43ac38aa
authored
Sep 29, 2015
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add autospec to all mocks
parent
1f2f3de4
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
93 additions
and
89 deletions
+93
-89
cms/djangoapps/contentstore/tests/test_libraries.py
+1
-1
common/djangoapps/track/views/tests/test_views.py
+1
-1
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+1
-1
common/lib/xmodule/xmodule/tests/test_library_content.py
+2
-2
lms/djangoapps/bulk_email/tests/test_course_optout.py
+1
-1
lms/djangoapps/bulk_email/tests/test_email.py
+2
-2
lms/djangoapps/bulk_email/tests/test_err_handling.py
+1
-1
lms/djangoapps/bulk_email/tests/test_models.py
+1
-1
lms/djangoapps/bulk_email/tests/test_tasks.py
+1
-1
lms/djangoapps/courseware/tests/test_module_render.py
+3
-3
lms/djangoapps/django_comment_client/base/tests.py
+19
-19
lms/djangoapps/django_comment_client/forum/tests.py
+22
-22
lms/djangoapps/edxnotes/tests.py
+25
-25
lms/djangoapps/instructor/tests/test_api.py
+3
-3
lms/djangoapps/instructor_task/tests/test_api.py
+1
-1
lms/djangoapps/lti_provider/tests/test_users.py
+2
-2
lms/djangoapps/verify_student/tests/test_views.py
+6
-2
openedx/core/djangoapps/course_groups/tests/test_cohorts.py
+1
-1
No files found.
cms/djangoapps/contentstore/tests/test_libraries.py
View file @
43ac38aa
...
@@ -387,7 +387,7 @@ class TestLibraries(LibraryTestCase):
...
@@ -387,7 +387,7 @@ class TestLibraries(LibraryTestCase):
html_block
=
modulestore
()
.
get_item
(
lc_block
.
children
[
0
])
html_block
=
modulestore
()
.
get_item
(
lc_block
.
children
[
0
])
self
.
assertEqual
(
html_block
.
data
,
data2
)
self
.
assertEqual
(
html_block
.
data
,
data2
)
@patch
(
"xmodule.library_tools.SearchEngine.get_search_engine"
,
Mock
(
return_value
=
None
))
@patch
(
"xmodule.library_tools.SearchEngine.get_search_engine"
,
Mock
(
return_value
=
None
,
autospec
=
True
))
def
test_refreshes_children_if_capa_type_change
(
self
):
def
test_refreshes_children_if_capa_type_change
(
self
):
""" Tests that children are automatically refreshed if capa type field changes """
""" Tests that children are automatically refreshed if capa type field changes """
name1
,
name2
=
"Option Problem"
,
"Multiple Choice Problem"
name1
,
name2
=
"Option Problem"
,
"Multiple Choice Problem"
...
...
common/djangoapps/track/views/tests/test_views.py
View file @
43ac38aa
...
@@ -19,7 +19,7 @@ class TestTrackViews(EventTrackingTestCase):
...
@@ -19,7 +19,7 @@ class TestTrackViews(EventTrackingTestCase):
self
.
request_factory
=
RequestFactory
()
self
.
request_factory
=
RequestFactory
()
patcher
=
patch
(
'track.views.tracker'
)
patcher
=
patch
(
'track.views.tracker'
,
autospec
=
True
)
self
.
mock_tracker
=
patcher
.
start
()
self
.
mock_tracker
=
patcher
.
start
()
self
.
addCleanup
(
patcher
.
stop
)
self
.
addCleanup
(
patcher
.
stop
)
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
43ac38aa
...
@@ -158,7 +158,7 @@ def xml_store_config(data_dir, source_dirs=None):
...
@@ -158,7 +158,7 @@ def xml_store_config(data_dir, source_dirs=None):
return
store
return
store
@patch
(
'xmodule.modulestore.django.create_modulestore_instance'
)
@patch
(
'xmodule.modulestore.django.create_modulestore_instance'
,
autospec
=
True
)
def
drop_mongo_collections
(
mock_create
):
def
drop_mongo_collections
(
mock_create
):
"""
"""
If using a Mongo-backed modulestore & contentstore, drop the collections.
If using a Mongo-backed modulestore & contentstore, drop the collections.
...
...
common/lib/xmodule/xmodule/tests/test_library_content.py
View file @
43ac38aa
...
@@ -242,7 +242,7 @@ class LibraryContentModuleTestMixin(object):
...
@@ -242,7 +242,7 @@ class LibraryContentModuleTestMixin(object):
self
.
assertNotIn
(
LibraryContentDescriptor
.
display_name
,
non_editable_metadata_fields
)
self
.
assertNotIn
(
LibraryContentDescriptor
.
display_name
,
non_editable_metadata_fields
)
@patch
(
'xmodule.library_tools.SearchEngine.get_search_engine'
,
Mock
(
return_value
=
None
))
@patch
(
'xmodule.library_tools.SearchEngine.get_search_engine'
,
Mock
(
return_value
=
None
,
autospec
=
True
))
class
TestLibraryContentModuleNoSearchIndex
(
LibraryContentModuleTestMixin
,
LibraryContentTest
):
class
TestLibraryContentModuleNoSearchIndex
(
LibraryContentModuleTestMixin
,
LibraryContentTest
):
"""
"""
Tests for library container when no search index is available.
Tests for library container when no search index is available.
...
@@ -254,7 +254,7 @@ class TestLibraryContentModuleNoSearchIndex(LibraryContentModuleTestMixin, Libra
...
@@ -254,7 +254,7 @@ class TestLibraryContentModuleNoSearchIndex(LibraryContentModuleTestMixin, Libra
search_index_mock
=
Mock
(
spec
=
SearchEngine
)
# pylint: disable=invalid-name
search_index_mock
=
Mock
(
spec
=
SearchEngine
)
# pylint: disable=invalid-name
@patch
(
'xmodule.library_tools.SearchEngine.get_search_engine'
,
Mock
(
return_value
=
search_index_mock
))
@patch
(
'xmodule.library_tools.SearchEngine.get_search_engine'
,
Mock
(
return_value
=
search_index_mock
,
autospec
=
True
))
class
TestLibraryContentModuleWithSearchIndex
(
LibraryContentModuleTestMixin
,
LibraryContentTest
):
class
TestLibraryContentModuleWithSearchIndex
(
LibraryContentModuleTestMixin
,
LibraryContentTest
):
"""
"""
Tests for library container with mocked search engine response.
Tests for library container with mocked search engine response.
...
...
lms/djangoapps/bulk_email/tests/test_course_optout.py
View file @
43ac38aa
...
@@ -18,7 +18,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
...
@@ -18,7 +18,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
class
TestOptoutCourseEmails
(
ModuleStoreTestCase
):
class
TestOptoutCourseEmails
(
ModuleStoreTestCase
):
"""
"""
Test that optouts are referenced in sending course email.
Test that optouts are referenced in sending course email.
...
...
lms/djangoapps/bulk_email/tests/test_email.py
View file @
43ac38aa
...
@@ -88,7 +88,7 @@ class EmailSendFromDashboardTestCase(ModuleStoreTestCase):
...
@@ -88,7 +88,7 @@ class EmailSendFromDashboardTestCase(ModuleStoreTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
class
TestEmailSendFromDashboardMockedHtmlToText
(
EmailSendFromDashboardTestCase
):
class
TestEmailSendFromDashboardMockedHtmlToText
(
EmailSendFromDashboardTestCase
):
"""
"""
Tests email sending with mocked html_to_text.
Tests email sending with mocked html_to_text.
...
@@ -108,7 +108,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
...
@@ -108,7 +108,7 @@ class TestEmailSendFromDashboardMockedHtmlToText(EmailSendFromDashboardTestCase)
# We should get back a HttpResponseForbidden (status code 403)
# We should get back a HttpResponseForbidden (status code 403)
self
.
assertContains
(
response
,
"Email is not enabled for this course."
,
status_code
=
403
)
self
.
assertContains
(
response
,
"Email is not enabled for this course."
,
status_code
=
403
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
def
test_send_to_self
(
self
):
def
test_send_to_self
(
self
):
"""
"""
Make sure email send to myself goes to myself.
Make sure email send to myself goes to myself.
...
...
lms/djangoapps/bulk_email/tests/test_err_handling.py
View file @
43ac38aa
...
@@ -37,7 +37,7 @@ class EmailTestException(Exception):
...
@@ -37,7 +37,7 @@ class EmailTestException(Exception):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestEmailErrors
(
ModuleStoreTestCase
):
class
TestEmailErrors
(
ModuleStoreTestCase
):
"""
"""
...
...
lms/djangoapps/bulk_email/tests/test_models.py
View file @
43ac38aa
...
@@ -15,7 +15,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
...
@@ -15,7 +15,7 @@ from opaque_keys.edx.locations import SlashSeparatedCourseKey
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
class
CourseEmailTest
(
TestCase
):
class
CourseEmailTest
(
TestCase
):
"""Test the CourseEmail model."""
"""Test the CourseEmail model."""
...
...
lms/djangoapps/bulk_email/tests/test_tasks.py
View file @
43ac38aa
...
@@ -76,7 +76,7 @@ def my_update_subtask_status(entry_id, current_task_id, new_subtask_status):
...
@@ -76,7 +76,7 @@ def my_update_subtask_status(entry_id, current_task_id, new_subtask_status):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
class
TestBulkEmailInstructorTask
(
InstructorTaskCourseTestCase
):
class
TestBulkEmailInstructorTask
(
InstructorTaskCourseTestCase
):
"""Tests instructor task that send bulk email."""
"""Tests instructor task that send bulk email."""
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
43ac38aa
...
@@ -1351,7 +1351,7 @@ class XmlViewInStudioTest(ViewInStudioTest):
...
@@ -1351,7 +1351,7 @@ class XmlViewInStudioTest(ViewInStudioTest):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISPLAY_DEBUG_INFO_TO_STAFF'
:
True
,
'DISPLAY_HISTOGRAMS_TO_STAFF'
:
True
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISPLAY_DEBUG_INFO_TO_STAFF'
:
True
,
'DISPLAY_HISTOGRAMS_TO_STAFF'
:
True
})
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
))
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
,
autospec
=
True
))
class
TestStaffDebugInfo
(
ModuleStoreTestCase
):
class
TestStaffDebugInfo
(
ModuleStoreTestCase
):
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
"""Tests to verify that Staff Debug Info panel and histograms are displayed to staff."""
...
@@ -1483,7 +1483,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -1483,7 +1483,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
course_key
=
ToyCourseFactory
.
create
()
.
id
self
.
course_key
=
ToyCourseFactory
.
create
()
.
id
self
.
course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
course
=
modulestore
()
.
get_course
(
self
.
course_key
)
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
))
@patch
(
'courseware.module_render.has_access'
,
Mock
(
return_value
=
True
,
autospec
=
True
))
def
_get_anonymous_id
(
self
,
course_id
,
xblock_class
):
def
_get_anonymous_id
(
self
,
course_id
,
xblock_class
):
location
=
course_id
.
make_usage_key
(
'dummy_category'
,
'dummy_name'
)
location
=
course_id
.
make_usage_key
(
'dummy_category'
,
'dummy_name'
)
descriptor
=
Mock
(
descriptor
=
Mock
(
...
@@ -1550,7 +1550,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
...
@@ -1550,7 +1550,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'track.views.tracker'
)
@patch
(
'track.views.tracker'
,
autospec
=
True
)
class
TestModuleTrackingContext
(
ModuleStoreTestCase
):
class
TestModuleTrackingContext
(
ModuleStoreTestCase
):
"""
"""
Ensure correct tracking information is included in events emitted during XBlock callback handling.
Ensure correct tracking information is included in events emitted during XBlock callback handling.
...
...
lms/djangoapps/django_comment_client/base/tests.py
View file @
43ac38aa
...
@@ -48,7 +48,7 @@ class MockRequestSetupMixin(object):
...
@@ -48,7 +48,7 @@ class MockRequestSetupMixin(object):
mock_request
.
return_value
=
self
.
_create_response_mock
(
data
)
mock_request
.
return_value
=
self
.
_create_response_mock
(
data
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
CreateThreadGroupIdTestCase
(
class
CreateThreadGroupIdTestCase
(
MockRequestSetupMixin
,
MockRequestSetupMixin
,
CohortedTestCase
,
CohortedTestCase
,
...
@@ -83,7 +83,7 @@ class CreateThreadGroupIdTestCase(
...
@@ -83,7 +83,7 @@ class CreateThreadGroupIdTestCase(
self
.
_assert_json_response_contains_group_info
(
response
)
self
.
_assert_json_response_contains_group_info
(
response
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
@disable_signal
(
views
,
'thread_edited'
)
@disable_signal
(
views
,
'thread_edited'
)
@disable_signal
(
views
,
'thread_voted'
)
@disable_signal
(
views
,
'thread_voted'
)
@disable_signal
(
views
,
'thread_deleted'
)
@disable_signal
(
views
,
'thread_deleted'
)
...
@@ -348,7 +348,7 @@ class ViewsTestCaseMixin(object):
...
@@ -348,7 +348,7 @@ class ViewsTestCaseMixin(object):
@ddt.ddt
@ddt.ddt
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
@disable_signal
(
views
,
'thread_created'
)
@disable_signal
(
views
,
'thread_created'
)
@disable_signal
(
views
,
'thread_edited'
)
@disable_signal
(
views
,
'thread_edited'
)
class
ViewsQueryCountTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
,
ViewsTestCaseMixin
):
class
ViewsQueryCountTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
,
ViewsTestCaseMixin
):
...
@@ -401,7 +401,7 @@ class ViewsQueryCountTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSet
...
@@ -401,7 +401,7 @@ class ViewsQueryCountTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSet
@ddt.ddt
@ddt.ddt
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
ViewsTestCase
(
class
ViewsTestCase
(
UrlResetMixin
,
UrlResetMixin
,
ModuleStoreTestCase
,
ModuleStoreTestCase
,
...
@@ -984,7 +984,7 @@ class ViewsTestCase(
...
@@ -984,7 +984,7 @@ class ViewsTestCase(
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
@patch
(
"lms.lib.comment_client.utils.requests.request"
)
@patch
(
"lms.lib.comment_client.utils.requests.request"
,
autospec
=
True
)
@disable_signal
(
views
,
'comment_endorsed'
)
@disable_signal
(
views
,
'comment_endorsed'
)
class
ViewPermissionsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
):
class
ViewPermissionsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
...
@@ -1088,7 +1088,7 @@ class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
...
@@ -1088,7 +1088,7 @@ class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
,):
def
_test_unicode_data
(
self
,
text
,
mock_request
,):
"""
"""
Test to make sure unicode data in a thread doesn't break it.
Test to make sure unicode data in a thread doesn't break it.
...
@@ -1118,7 +1118,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
...
@@ -1118,7 +1118,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'django_comment_client.utils.get_discussion_categories_ids'
,
return_value
=
[
"test_commentable"
])
@patch
(
'django_comment_client.utils.get_discussion_categories_ids'
,
return_value
=
[
"test_commentable"
])
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
,
mock_get_discussion_id_map
):
def
_test_unicode_data
(
self
,
text
,
mock_request
,
mock_get_discussion_id_map
):
self
.
_set_mock_request_data
(
mock_request
,
{
self
.
_set_mock_request_data
(
mock_request
,
{
"user_id"
:
str
(
self
.
student
.
id
),
"user_id"
:
str
(
self
.
student
.
id
),
...
@@ -1147,7 +1147,7 @@ class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
...
@@ -1147,7 +1147,7 @@ class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
commentable_id
=
"non_team_dummy_id"
commentable_id
=
"non_team_dummy_id"
self
.
_set_mock_request_data
(
mock_request
,
{
self
.
_set_mock_request_data
(
mock_request
,
{
...
@@ -1182,7 +1182,7 @@ class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
...
@@ -1182,7 +1182,7 @@ class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
self
.
_set_mock_request_data
(
mock_request
,
{
self
.
_set_mock_request_data
(
mock_request
,
{
"user_id"
:
str
(
self
.
student
.
id
),
"user_id"
:
str
(
self
.
student
.
id
),
...
@@ -1211,7 +1211,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
...
@@ -1211,7 +1211,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
"""
"""
Create a comment with unicode in it.
Create a comment with unicode in it.
...
@@ -1239,7 +1239,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
...
@@ -1239,7 +1239,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
@ddt.ddt
@ddt.ddt
@patch
(
"lms.lib.comment_client.utils.requests.request"
)
@patch
(
"lms.lib.comment_client.utils.requests.request"
,
autospec
=
True
)
@disable_signal
(
views
,
'thread_voted'
)
@disable_signal
(
views
,
'thread_voted'
)
@disable_signal
(
views
,
'thread_edited'
)
@disable_signal
(
views
,
'thread_edited'
)
@disable_signal
(
views
,
'comment_created'
)
@disable_signal
(
views
,
'comment_created'
)
...
@@ -1515,7 +1515,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1515,7 +1515,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
CourseAccessRoleFactory
(
course_id
=
self
.
course
.
id
,
user
=
self
.
student
,
role
=
'Wizard'
)
CourseAccessRoleFactory
(
course_id
=
self
.
course
.
id
,
user
=
self
.
student
,
role
=
'Wizard'
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_thread_event
(
self
,
__
,
mock_emit
):
def
test_thread_event
(
self
,
__
,
mock_emit
):
request
=
RequestFactory
()
.
post
(
request
=
RequestFactory
()
.
post
(
"dummy_url"
,
{
"dummy_url"
,
{
...
@@ -1544,7 +1544,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1544,7 +1544,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
self
.
assertEquals
(
event
[
'anonymous_to_peers'
],
False
)
self
.
assertEquals
(
event
[
'anonymous_to_peers'
],
False
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_response_event
(
self
,
mock_request
,
mock_emit
):
def
test_response_event
(
self
,
mock_request
,
mock_emit
):
"""
"""
Check to make sure an event is fired when a user responds to a thread.
Check to make sure an event is fired when a user responds to a thread.
...
@@ -1570,7 +1570,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1570,7 +1570,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
self
.
assertEqual
(
event
[
'options'
][
'followed'
],
True
)
self
.
assertEqual
(
event
[
'options'
][
'followed'
],
True
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_comment_event
(
self
,
mock_request
,
mock_emit
):
def
test_comment_event
(
self
,
mock_request
,
mock_emit
):
"""
"""
Ensure an event is fired when someone comments on a response.
Ensure an event is fired when someone comments on a response.
...
@@ -1597,7 +1597,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1597,7 +1597,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
self
.
assertEqual
(
event
[
'options'
][
'followed'
],
False
)
self
.
assertEqual
(
event
[
'options'
][
'followed'
],
False
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
@ddt.data
((
@ddt.data
((
'create_thread'
,
'create_thread'
,
'edx.forum.thread.created'
,
{
'edx.forum.thread.created'
,
{
...
@@ -1649,7 +1649,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1649,7 +1649,7 @@ class ForumEventTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
)
)
@ddt.unpack
@ddt.unpack
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'eventtracking.tracker.emit'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_thread_voted_event
(
self
,
view_name
,
obj_id_name
,
obj_type
,
mock_request
,
mock_emit
):
def
test_thread_voted_event
(
self
,
view_name
,
obj_id_name
,
obj_type
,
mock_request
,
mock_emit
):
undo
=
view_name
.
startswith
(
'undo'
)
undo
=
view_name
.
startswith
(
'undo'
)
...
@@ -1704,7 +1704,7 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1704,7 +1704,7 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
request
.
view_name
=
"users"
request
.
view_name
=
"users"
return
views
.
users
(
request
,
course_id
=
course_id
.
to_deprecated_string
())
return
views
.
users
(
request
,
course_id
=
course_id
.
to_deprecated_string
())
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_finds_exact_match
(
self
,
mock_request
):
def
test_finds_exact_match
(
self
,
mock_request
):
self
.
set_post_counts
(
mock_request
)
self
.
set_post_counts
(
mock_request
)
response
=
self
.
make_request
(
username
=
"other"
)
response
=
self
.
make_request
(
username
=
"other"
)
...
@@ -1714,7 +1714,7 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1714,7 +1714,7 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
[{
"id"
:
self
.
other_user
.
id
,
"username"
:
self
.
other_user
.
username
}]
[{
"id"
:
self
.
other_user
.
id
,
"username"
:
self
.
other_user
.
username
}]
)
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_finds_no_match
(
self
,
mock_request
):
def
test_finds_no_match
(
self
,
mock_request
):
self
.
set_post_counts
(
mock_request
)
self
.
set_post_counts
(
mock_request
)
response
=
self
.
make_request
(
username
=
"othor"
)
response
=
self
.
make_request
(
username
=
"othor"
)
...
@@ -1751,7 +1751,7 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
...
@@ -1751,7 +1751,7 @@ class UsersEndpointTestCase(ModuleStoreTestCase, MockRequestSetupMixin):
self
.
assertIn
(
"errors"
,
content
)
self
.
assertIn
(
"errors"
,
content
)
self
.
assertNotIn
(
"users"
,
content
)
self
.
assertNotIn
(
"users"
,
content
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_requires_matched_user_has_forum_content
(
self
,
mock_request
):
def
test_requires_matched_user_has_forum_content
(
self
,
mock_request
):
self
.
set_post_counts
(
mock_request
,
0
,
0
)
self
.
set_post_counts
(
mock_request
,
0
,
0
)
response
=
self
.
make_request
(
username
=
"other"
)
response
=
self
.
make_request
(
username
=
"other"
)
...
...
lms/djangoapps/django_comment_client/forum/tests.py
View file @
43ac38aa
...
@@ -216,7 +216,7 @@ class PartialDictMatcher(object):
...
@@ -216,7 +216,7 @@ class PartialDictMatcher(object):
])
])
@patch
(
'requests.request'
)
@patch
(
'requests.request'
,
autospec
=
True
)
class
SingleThreadTestCase
(
ModuleStoreTestCase
):
class
SingleThreadTestCase
(
ModuleStoreTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
SingleThreadTestCase
,
self
)
.
setUp
(
create_user
=
False
)
super
(
SingleThreadTestCase
,
self
)
.
setUp
(
create_user
=
False
)
...
@@ -327,7 +327,7 @@ class SingleThreadTestCase(ModuleStoreTestCase):
...
@@ -327,7 +327,7 @@ class SingleThreadTestCase(ModuleStoreTestCase):
@ddt.ddt
@ddt.ddt
@patch
(
'requests.request'
)
@patch
(
'requests.request'
,
autospec
=
True
)
class
SingleThreadQueryCountTestCase
(
ModuleStoreTestCase
):
class
SingleThreadQueryCountTestCase
(
ModuleStoreTestCase
):
"""
"""
Ensures the number of modulestore queries and number of sql queries are
Ensures the number of modulestore queries and number of sql queries are
...
@@ -394,7 +394,7 @@ class SingleThreadQueryCountTestCase(ModuleStoreTestCase):
...
@@ -394,7 +394,7 @@ class SingleThreadQueryCountTestCase(ModuleStoreTestCase):
call_single_thread
()
call_single_thread
()
@patch
(
'requests.request'
)
@patch
(
'requests.request'
,
autospec
=
True
)
class
SingleCohortedThreadTestCase
(
CohortedTestCase
):
class
SingleCohortedThreadTestCase
(
CohortedTestCase
):
def
_create_mock_cohorted_thread
(
self
,
mock_request
):
def
_create_mock_cohorted_thread
(
self
,
mock_request
):
self
.
mock_text
=
"dummy content"
self
.
mock_text
=
"dummy content"
...
@@ -453,7 +453,7 @@ class SingleCohortedThreadTestCase(CohortedTestCase):
...
@@ -453,7 +453,7 @@ class SingleCohortedThreadTestCase(CohortedTestCase):
self
.
assertRegexpMatches
(
html
,
r'"group_name": "student_cohort"'
)
self
.
assertRegexpMatches
(
html
,
r'"group_name": "student_cohort"'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
SingleThreadAccessTestCase
(
CohortedTestCase
):
class
SingleThreadAccessTestCase
(
CohortedTestCase
):
def
call_view
(
self
,
mock_request
,
commentable_id
,
user
,
group_id
,
thread_group_id
=
None
,
pass_group_id
=
True
):
def
call_view
(
self
,
mock_request
,
commentable_id
,
user
,
group_id
,
thread_group_id
=
None
,
pass_group_id
=
True
):
thread_id
=
"test_thread_id"
thread_id
=
"test_thread_id"
...
@@ -540,7 +540,7 @@ class SingleThreadAccessTestCase(CohortedTestCase):
...
@@ -540,7 +540,7 @@ class SingleThreadAccessTestCase(CohortedTestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
SingleThreadGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
class
SingleThreadGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
cs_endpoint
=
"/threads"
cs_endpoint
=
"/threads"
...
@@ -592,7 +592,7 @@ class SingleThreadGroupIdTestCase(CohortedTestCase, CohortedTopicGroupIdTestMixi
...
@@ -592,7 +592,7 @@ class SingleThreadGroupIdTestCase(CohortedTestCase, CohortedTopicGroupIdTestMixi
)
)
@patch
(
'requests.request'
)
@patch
(
'requests.request'
,
autospec
=
True
)
class
SingleThreadContentGroupTestCase
(
ContentGroupTestCase
):
class
SingleThreadContentGroupTestCase
(
ContentGroupTestCase
):
def
assert_can_access
(
self
,
user
,
discussion_id
,
thread_id
,
should_have_access
):
def
assert_can_access
(
self
,
user
,
discussion_id
,
thread_id
,
should_have_access
):
"""
"""
...
@@ -704,7 +704,7 @@ class SingleThreadContentGroupTestCase(ContentGroupTestCase):
...
@@ -704,7 +704,7 @@ class SingleThreadContentGroupTestCase(ContentGroupTestCase):
self
.
assert_can_access
(
self
.
beta_user
,
self
.
alpha_module
.
discussion_id
,
thread_id
,
True
)
self
.
assert_can_access
(
self
.
beta_user
,
self
.
alpha_module
.
discussion_id
,
thread_id
,
True
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
InlineDiscussionContextTestCase
(
ModuleStoreTestCase
):
class
InlineDiscussionContextTestCase
(
ModuleStoreTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
InlineDiscussionContextTestCase
,
self
)
.
setUp
()
super
(
InlineDiscussionContextTestCase
,
self
)
.
setUp
()
...
@@ -740,7 +740,7 @@ class InlineDiscussionContextTestCase(ModuleStoreTestCase):
...
@@ -740,7 +740,7 @@ class InlineDiscussionContextTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
json_response
[
'discussion_data'
][
0
][
'context'
],
ThreadContext
.
STANDALONE
)
self
.
assertEqual
(
json_response
[
'discussion_data'
][
0
][
'context'
],
ThreadContext
.
STANDALONE
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
InlineDiscussionGroupIdTestCase
(
class
InlineDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
,
CohortedTopicGroupIdTestMixin
,
...
@@ -791,7 +791,7 @@ class InlineDiscussionGroupIdTestCase(
...
@@ -791,7 +791,7 @@ class InlineDiscussionGroupIdTestCase(
)
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
ForumFormDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
class
ForumFormDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
cs_endpoint
=
"/threads"
cs_endpoint
=
"/threads"
...
@@ -841,7 +841,7 @@ class ForumFormDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGroupIdT
...
@@ -841,7 +841,7 @@ class ForumFormDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGroupIdT
)
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
UserProfileDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
class
UserProfileDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
cs_endpoint
=
"/active_threads"
cs_endpoint
=
"/active_threads"
...
@@ -1007,7 +1007,7 @@ class UserProfileDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGroupI
...
@@ -1007,7 +1007,7 @@ class UserProfileDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGroupI
verify_group_id_not_present
(
profiled_user
=
self
.
moderator
,
pass_group_id
=
False
)
verify_group_id_not_present
(
profiled_user
=
self
.
moderator
,
pass_group_id
=
False
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
FollowedThreadsDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
class
FollowedThreadsDiscussionGroupIdTestCase
(
CohortedTestCase
,
CohortedTopicGroupIdTestMixin
):
cs_endpoint
=
"/subscribed_threads"
cs_endpoint
=
"/subscribed_threads"
...
@@ -1044,7 +1044,7 @@ class FollowedThreadsDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGr
...
@@ -1044,7 +1044,7 @@ class FollowedThreadsDiscussionGroupIdTestCase(CohortedTestCase, CohortedTopicGr
)
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
InlineDiscussionTestCase
(
ModuleStoreTestCase
):
class
InlineDiscussionTestCase
(
ModuleStoreTestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
InlineDiscussionTestCase
,
self
)
.
setUp
()
super
(
InlineDiscussionTestCase
,
self
)
.
setUp
()
...
@@ -1102,7 +1102,7 @@ class InlineDiscussionTestCase(ModuleStoreTestCase):
...
@@ -1102,7 +1102,7 @@ class InlineDiscussionTestCase(ModuleStoreTestCase):
self
.
verify_response
(
response
)
self
.
verify_response
(
response
)
@patch
(
'requests.request'
)
@patch
(
'requests.request'
,
autospec
=
True
)
class
UserProfileTestCase
(
ModuleStoreTestCase
):
class
UserProfileTestCase
(
ModuleStoreTestCase
):
TEST_THREAD_TEXT
=
'userprofile-test-text'
TEST_THREAD_TEXT
=
'userprofile-test-text'
...
@@ -1219,7 +1219,7 @@ class UserProfileTestCase(ModuleStoreTestCase):
...
@@ -1219,7 +1219,7 @@ class UserProfileTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
405
)
self
.
assertEqual
(
response
.
status_code
,
405
)
@patch
(
'requests.request'
)
@patch
(
'requests.request'
,
autospec
=
True
)
class
CommentsServiceRequestHeadersTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
class
CommentsServiceRequestHeadersTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -1289,7 +1289,7 @@ class InlineDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
...
@@ -1289,7 +1289,7 @@ class InlineDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
...
@@ -1312,7 +1312,7 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
...
@@ -1312,7 +1312,7 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
...
@@ -1327,7 +1327,7 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
...
@@ -1327,7 +1327,7 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
@ddt.ddt
@ddt.ddt
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
class
ForumDiscussionXSSTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
class
ForumDiscussionXSSTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
def
setUp
(
self
):
def
setUp
(
self
):
...
@@ -1384,7 +1384,7 @@ class ForumDiscussionSearchUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin
...
@@ -1384,7 +1384,7 @@ class ForumDiscussionSearchUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
data
=
{
data
=
{
...
@@ -1410,7 +1410,7 @@ class SingleThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
...
@@ -1410,7 +1410,7 @@ class SingleThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
thread_id
=
"test_thread_id"
thread_id
=
"test_thread_id"
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
,
thread_id
=
thread_id
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
,
thread_id
=
thread_id
)
...
@@ -1433,7 +1433,7 @@ class UserProfileUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
...
@@ -1433,7 +1433,7 @@ class UserProfileUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
...
@@ -1455,7 +1455,7 @@ class FollowedThreadsUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
...
@@ -1455,7 +1455,7 @@ class FollowedThreadsUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
CourseEnrollmentFactory
(
user
=
self
.
student
,
course_id
=
self
.
course
.
id
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
_test_unicode_data
(
self
,
text
,
mock_request
):
def
_test_unicode_data
(
self
,
text
,
mock_request
):
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
text
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
request
=
RequestFactory
()
.
get
(
"dummy_url"
)
...
@@ -1482,7 +1482,7 @@ class EnrollmentTestCase(ModuleStoreTestCase):
...
@@ -1482,7 +1482,7 @@ class EnrollmentTestCase(ModuleStoreTestCase):
self
.
student
=
UserFactory
.
create
()
self
.
student
=
UserFactory
.
create
()
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
,
autospec
=
True
)
def
test_unenrolled
(
self
,
mock_request
):
def
test_unenrolled
(
self
,
mock_request
):
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
'dummy'
)
mock_request
.
side_effect
=
make_mock_request_impl
(
course
=
self
.
course
,
text
=
'dummy'
)
request
=
RequestFactory
()
.
get
(
'dummy_url'
)
request
=
RequestFactory
()
.
get
(
'dummy_url'
)
...
...
lms/djangoapps/edxnotes/tests.py
View file @
43ac38aa
...
@@ -79,10 +79,10 @@ class EdxNotesDecoratorTest(ModuleStoreTestCase):
...
@@ -79,10 +79,10 @@ class EdxNotesDecoratorTest(ModuleStoreTestCase):
self
.
problem
=
TestProblem
(
self
.
course
)
self
.
problem
=
TestProblem
(
self
.
course
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
'ENABLE_EDXNOTES'
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
'ENABLE_EDXNOTES'
:
True
})
@patch
(
"edxnotes.decorators.get_public_endpoint"
)
@patch
(
"edxnotes.decorators.get_public_endpoint"
,
autospec
=
True
)
@patch
(
"edxnotes.decorators.get_token_url"
)
@patch
(
"edxnotes.decorators.get_token_url"
,
autospec
=
True
)
@patch
(
"edxnotes.decorators.get_edxnotes_id_token"
)
@patch
(
"edxnotes.decorators.get_edxnotes_id_token"
,
autospec
=
True
)
@patch
(
"edxnotes.decorators.generate_uid"
)
@patch
(
"edxnotes.decorators.generate_uid"
,
autospec
=
True
)
def
test_edxnotes_enabled
(
self
,
mock_generate_uid
,
mock_get_id_token
,
mock_get_token_url
,
mock_get_endpoint
):
def
test_edxnotes_enabled
(
self
,
mock_generate_uid
,
mock_get_id_token
,
mock_get_token_url
,
mock_get_endpoint
):
"""
"""
Tests if get_html is wrapped when feature flag is on and edxnotes are
Tests if get_html is wrapped when feature flag is on and edxnotes are
...
@@ -275,7 +275,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -275,7 +275,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
with
patch_edxnotes_api_settings
(
None
):
with
patch_edxnotes_api_settings
(
None
):
self
.
assertRaises
(
ImproperlyConfigured
,
get_endpoint_function
)
self
.
assertRaises
(
ImproperlyConfigured
,
get_endpoint_function
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_get_notes_correct_data
(
self
,
mock_get
):
def
test_get_notes_correct_data
(
self
,
mock_get
):
"""
"""
Tests the result if correct data is received.
Tests the result if correct data is received.
...
@@ -347,7 +347,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -347,7 +347,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
json
.
loads
(
helpers
.
get_notes
(
self
.
user
,
self
.
course
))
json
.
loads
(
helpers
.
get_notes
(
self
.
user
,
self
.
course
))
)
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_get_notes_json_error
(
self
,
mock_get
):
def
test_get_notes_json_error
(
self
,
mock_get
):
"""
"""
Tests the result if incorrect json is received.
Tests the result if incorrect json is received.
...
@@ -355,7 +355,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -355,7 +355,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
mock_get
.
return_value
.
content
=
"Error"
mock_get
.
return_value
.
content
=
"Error"
self
.
assertIsNone
(
helpers
.
get_notes
(
self
.
user
,
self
.
course
))
self
.
assertIsNone
(
helpers
.
get_notes
(
self
.
user
,
self
.
course
))
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_get_notes_empty_collection
(
self
,
mock_get
):
def
test_get_notes_empty_collection
(
self
,
mock_get
):
"""
"""
Tests the result if an empty collection is received.
Tests the result if an empty collection is received.
...
@@ -363,7 +363,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -363,7 +363,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
mock_get
.
return_value
.
content
=
json
.
dumps
([])
mock_get
.
return_value
.
content
=
json
.
dumps
([])
self
.
assertIsNone
(
helpers
.
get_notes
(
self
.
user
,
self
.
course
))
self
.
assertIsNone
(
helpers
.
get_notes
(
self
.
user
,
self
.
course
))
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_search_correct_data
(
self
,
mock_get
):
def
test_search_correct_data
(
self
,
mock_get
):
"""
"""
Tests the result if correct data is received.
Tests the result if correct data is received.
...
@@ -443,7 +443,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -443,7 +443,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
json
.
loads
(
helpers
.
search
(
self
.
user
,
self
.
course
,
"test"
))
json
.
loads
(
helpers
.
search
(
self
.
user
,
self
.
course
,
"test"
))
)
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_search_json_error
(
self
,
mock_get
):
def
test_search_json_error
(
self
,
mock_get
):
"""
"""
Tests the result if incorrect json is received.
Tests the result if incorrect json is received.
...
@@ -451,7 +451,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -451,7 +451,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
mock_get
.
return_value
.
content
=
"Error"
mock_get
.
return_value
.
content
=
"Error"
self
.
assertRaises
(
EdxNotesParseError
,
helpers
.
search
,
self
.
user
,
self
.
course
,
"test"
)
self
.
assertRaises
(
EdxNotesParseError
,
helpers
.
search
,
self
.
user
,
self
.
course
,
"test"
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_search_wrong_data_format
(
self
,
mock_get
):
def
test_search_wrong_data_format
(
self
,
mock_get
):
"""
"""
Tests the result if incorrect data structure is received.
Tests the result if incorrect data structure is received.
...
@@ -459,7 +459,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -459,7 +459,7 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
mock_get
.
return_value
.
content
=
json
.
dumps
({
"1"
:
2
})
mock_get
.
return_value
.
content
=
json
.
dumps
({
"1"
:
2
})
self
.
assertRaises
(
EdxNotesParseError
,
helpers
.
search
,
self
.
user
,
self
.
course
,
"test"
)
self
.
assertRaises
(
EdxNotesParseError
,
helpers
.
search
,
self
.
user
,
self
.
course
,
"test"
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_search_empty_collection
(
self
,
mock_get
):
def
test_search_empty_collection
(
self
,
mock_get
):
"""
"""
Tests no results.
Tests no results.
...
@@ -604,8 +604,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -604,8 +604,8 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
helpers
.
preprocess_collection
(
self
.
user
,
self
.
course
,
initial_collection
)
helpers
.
preprocess_collection
(
self
.
user
,
self
.
course
,
initial_collection
)
)
)
@patch
(
"edxnotes.helpers.has_access"
)
@patch
(
"edxnotes.helpers.has_access"
,
autospec
=
True
)
@patch
(
"edxnotes.helpers.modulestore"
)
@patch
(
"edxnotes.helpers.modulestore"
,
autospec
=
True
)
def
test_preprocess_collection_no_unit
(
self
,
mock_modulestore
,
mock_has_access
):
def
test_preprocess_collection_no_unit
(
self
,
mock_modulestore
,
mock_has_access
):
"""
"""
Tests the result if the unit does not exist.
Tests the result if the unit does not exist.
...
@@ -690,9 +690,9 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -690,9 +690,9 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
@override_settings
(
EDXNOTES_PUBLIC_API
=
"http://example.com"
)
@override_settings
(
EDXNOTES_PUBLIC_API
=
"http://example.com"
)
@override_settings
(
EDXNOTES_INTERNAL_API
=
"http://example.com"
)
@override_settings
(
EDXNOTES_INTERNAL_API
=
"http://example.com"
)
@patch
(
"edxnotes.helpers.anonymous_id_for_user"
)
@patch
(
"edxnotes.helpers.anonymous_id_for_user"
,
autospec
=
True
)
@patch
(
"edxnotes.helpers.get_edxnotes_id_token"
)
@patch
(
"edxnotes.helpers.get_edxnotes_id_token"
,
autospec
=
True
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_send_request_with_query_string
(
self
,
mock_get
,
mock_get_id_token
,
mock_anonymous_id_for_user
):
def
test_send_request_with_query_string
(
self
,
mock_get
,
mock_get_id_token
,
mock_anonymous_id_for_user
):
"""
"""
Tests that requests are send with correct information.
Tests that requests are send with correct information.
...
@@ -719,9 +719,9 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
...
@@ -719,9 +719,9 @@ class EdxNotesHelpersTest(ModuleStoreTestCase):
@override_settings
(
EDXNOTES_PUBLIC_API
=
"http://example.com"
)
@override_settings
(
EDXNOTES_PUBLIC_API
=
"http://example.com"
)
@override_settings
(
EDXNOTES_INTERNAL_API
=
"http://example.com"
)
@override_settings
(
EDXNOTES_INTERNAL_API
=
"http://example.com"
)
@patch
(
"edxnotes.helpers.anonymous_id_for_user"
)
@patch
(
"edxnotes.helpers.anonymous_id_for_user"
,
autospec
=
True
)
@patch
(
"edxnotes.helpers.get_edxnotes_id_token"
)
@patch
(
"edxnotes.helpers.get_edxnotes_id_token"
,
autospec
=
True
)
@patch
(
"edxnotes.helpers.requests.get"
)
@patch
(
"edxnotes.helpers.requests.get"
,
autospec
=
True
)
def
test_send_request_without_query_string
(
self
,
mock_get
,
mock_get_id_token
,
mock_anonymous_id_for_user
):
def
test_send_request_without_query_string
(
self
,
mock_get
,
mock_get_id_token
,
mock_anonymous_id_for_user
):
"""
"""
Tests that requests are send with correct information.
Tests that requests are send with correct information.
...
@@ -876,7 +876,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
...
@@ -876,7 +876,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch
(
"edxnotes.views.get_notes"
)
@patch
(
"edxnotes.views.get_notes"
,
autospec
=
True
)
def
test_edxnotes_view_404_service_unavailable
(
self
,
mock_get_notes
):
def
test_edxnotes_view_404_service_unavailable
(
self
,
mock_get_notes
):
"""
"""
Tests that 404 status code is received if EdxNotes service is unavailable.
Tests that 404 status code is received if EdxNotes service is unavailable.
...
@@ -887,7 +887,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
...
@@ -887,7 +887,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch
(
"edxnotes.views.search"
)
@patch
(
"edxnotes.views.search"
,
autospec
=
True
)
def
test_search_notes_successfully_respond
(
self
,
mock_search
):
def
test_search_notes_successfully_respond
(
self
,
mock_search
):
"""
"""
Tests that `search_notes` successfully respond if EdxNotes feature is enabled.
Tests that `search_notes` successfully respond if EdxNotes feature is enabled.
...
@@ -905,7 +905,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
...
@@ -905,7 +905,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
False
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
False
})
@patch
(
"edxnotes.views.search"
)
@patch
(
"edxnotes.views.search"
,
autospec
=
True
)
def
test_search_notes_is_disabled
(
self
,
mock_search
):
def
test_search_notes_is_disabled
(
self
,
mock_search
):
"""
"""
Tests that 404 status code is received if EdxNotes feature is disabled.
Tests that 404 status code is received if EdxNotes feature is disabled.
...
@@ -918,7 +918,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
...
@@ -918,7 +918,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch
(
"edxnotes.views.search"
)
@patch
(
"edxnotes.views.search"
,
autospec
=
True
)
def
test_search_404_service_unavailable
(
self
,
mock_search
):
def
test_search_404_service_unavailable
(
self
,
mock_search
):
"""
"""
Tests that 404 status code is received if EdxNotes service is unavailable.
Tests that 404 status code is received if EdxNotes service is unavailable.
...
@@ -930,7 +930,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
...
@@ -930,7 +930,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
self
.
assertIn
(
"error"
,
response
.
content
)
self
.
assertIn
(
"error"
,
response
.
content
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch
(
"edxnotes.views.search"
)
@patch
(
"edxnotes.views.search"
,
autospec
=
True
)
def
test_search_notes_without_required_parameters
(
self
,
mock_search
):
def
test_search_notes_without_required_parameters
(
self
,
mock_search
):
"""
"""
Tests that 400 status code is received if the required parameters were not sent.
Tests that 400 status code is received if the required parameters were not sent.
...
@@ -944,7 +944,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
...
@@ -944,7 +944,7 @@ class EdxNotesViewsTest(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
400
)
self
.
assertEqual
(
response
.
status_code
,
400
)
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_EDXNOTES"
:
True
})
@patch
(
"edxnotes.views.search"
)
@patch
(
"edxnotes.views.search"
,
autospec
=
True
)
def
test_search_notes_exception
(
self
,
mock_search
):
def
test_search_notes_exception
(
self
,
mock_search
):
"""
"""
Tests that 500 status code is received if invalid data was received from
Tests that 500 status code is received if invalid data was received from
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
43ac38aa
...
@@ -192,7 +192,7 @@ class TestCommonExceptions400(TestCase):
...
@@ -192,7 +192,7 @@ class TestCommonExceptions400(TestCase):
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestInstructorAPIDenyLevels
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestInstructorAPIDenyLevels
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
...
@@ -3234,7 +3234,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE
...
@@ -3234,7 +3234,7 @@ class TestEntranceExamInstructorAPIRegradeTask(SharedModuleStoreTestCase, LoginE
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestInstructorSendEmail
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestInstructorSendEmail
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
...
@@ -3484,7 +3484,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
...
@@ -3484,7 +3484,7 @@ class TestInstructorAPITaskLists(SharedModuleStoreTestCase, LoginEnrollmentTestC
@attr
(
'shard_1'
)
@attr
(
'shard_1'
)
@patch.object
(
instructor_task
.
api
,
'get_instructor_task_history'
)
@patch.object
(
instructor_task
.
api
,
'get_instructor_task_history'
,
autospec
=
True
)
class
TestInstructorEmailContentList
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
class
TestInstructorEmailContentList
(
SharedModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
"""
Test the instructor email content history endpoint.
Test the instructor email content history endpoint.
...
...
lms/djangoapps/instructor_task/tests/test_api.py
View file @
43ac38aa
...
@@ -167,7 +167,7 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
...
@@ -167,7 +167,7 @@ class InstructorTaskModuleSubmitTest(InstructorTaskModuleTestCase):
self
.
_test_submit_task
(
submit_delete_problem_state_for_all_students
)
self
.
_test_submit_task
(
submit_delete_problem_state_for_all_students
)
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
))
@patch
(
'bulk_email.models.html_to_text'
,
Mock
(
return_value
=
'Mocking CourseEmail.text_message'
,
autospec
=
True
))
class
InstructorTaskCourseSubmitTest
(
TestReportMixin
,
InstructorTaskCourseTestCase
):
class
InstructorTaskCourseSubmitTest
(
TestReportMixin
,
InstructorTaskCourseTestCase
):
"""Tests API methods that involve the submission of course-based background tasks."""
"""Tests API methods that involve the submission of course-based background tasks."""
...
...
lms/djangoapps/lti_provider/tests/test_users.py
View file @
43ac38aa
...
@@ -70,8 +70,8 @@ class UserManagementHelperTest(TestCase):
...
@@ -70,8 +70,8 @@ class UserManagementHelperTest(TestCase):
)
)
@patch
(
'lti_provider.users.switch_user'
)
@patch
(
'lti_provider.users.switch_user'
,
autospec
=
True
)
@patch
(
'lti_provider.users.create_lti_user'
)
@patch
(
'lti_provider.users.create_lti_user'
,
autospec
=
True
)
class
AuthenticateLtiUserTest
(
TestCase
):
class
AuthenticateLtiUserTest
(
TestCase
):
"""
"""
Tests for the authenticate_lti_user function in users.py
Tests for the authenticate_lti_user function in users.py
...
...
lms/djangoapps/verify_student/tests/test_views.py
View file @
43ac38aa
...
@@ -1156,7 +1156,7 @@ class CheckoutTestMixin(object):
...
@@ -1156,7 +1156,7 @@ class CheckoutTestMixin(object):
self
.
assertEqual
(
data
,
{
'foo'
:
'bar'
})
self
.
assertEqual
(
data
,
{
'foo'
:
'bar'
})
@patch
(
'lms.djangoapps.verify_student.views.checkout_with_shoppingcart'
,
return_value
=
TEST_PAYMENT_DATA
)
@patch
(
'lms.djangoapps.verify_student.views.checkout_with_shoppingcart'
,
return_value
=
TEST_PAYMENT_DATA
,
autospec
=
True
)
class
TestCreateOrderShoppingCart
(
CheckoutTestMixin
,
ModuleStoreTestCase
):
class
TestCreateOrderShoppingCart
(
CheckoutTestMixin
,
ModuleStoreTestCase
):
""" Test view behavior when the shoppingcart is used. """
""" Test view behavior when the shoppingcart is used. """
...
@@ -1170,7 +1170,11 @@ class TestCreateOrderShoppingCart(CheckoutTestMixin, ModuleStoreTestCase):
...
@@ -1170,7 +1170,11 @@ class TestCreateOrderShoppingCart(CheckoutTestMixin, ModuleStoreTestCase):
@override_settings
(
ECOMMERCE_API_URL
=
TEST_API_URL
,
ECOMMERCE_API_SIGNING_KEY
=
TEST_API_SIGNING_KEY
)
@override_settings
(
ECOMMERCE_API_URL
=
TEST_API_URL
,
ECOMMERCE_API_SIGNING_KEY
=
TEST_API_SIGNING_KEY
)
@patch
(
'lms.djangoapps.verify_student.views.checkout_with_ecommerce_service'
,
return_value
=
TEST_PAYMENT_DATA
)
@patch
(
'lms.djangoapps.verify_student.views.checkout_with_ecommerce_service'
,
return_value
=
TEST_PAYMENT_DATA
,
autospec
=
True
,
)
class
TestCreateOrderEcommerceService
(
CheckoutTestMixin
,
ModuleStoreTestCase
):
class
TestCreateOrderEcommerceService
(
CheckoutTestMixin
,
ModuleStoreTestCase
):
""" Test view behavior when the ecommerce service is used. """
""" Test view behavior when the ecommerce service is used. """
...
...
openedx/core/djangoapps/course_groups/tests/test_cohorts.py
View file @
43ac38aa
...
@@ -25,7 +25,7 @@ from ..tests.helpers import (
...
@@ -25,7 +25,7 @@ from ..tests.helpers import (
)
)
@patch
(
"openedx.core.djangoapps.course_groups.cohorts.tracker"
)
@patch
(
"openedx.core.djangoapps.course_groups.cohorts.tracker"
,
autospec
=
True
)
class
TestCohortSignals
(
TestCase
):
class
TestCohortSignals
(
TestCase
):
"""
"""
Test cases to validate event emissions for various cohort-related workflows
Test cases to validate event emissions for various cohort-related workflows
...
...
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