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
17379f40
Commit
17379f40
authored
Dec 02, 2014
by
Jesse Zoldak
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6078 from edx/zoldak/modulestore-test-refactor
Clean up all modulestore testcases
parents
0f3bce02
121b3130
Hide whitespace changes
Inline
Side-by-side
Showing
89 changed files
with
866 additions
and
780 deletions
+866
-780
cms/djangoapps/contentstore/tests/utils.py
+13
-7
common/djangoapps/course_groups/tests/test_cohorts.py
+13
-19
common/djangoapps/course_groups/tests/test_views.py
+17
-11
common/djangoapps/embargo/tests/test_forms.py
+2
-2
common/djangoapps/external_auth/tests/test_shib.py
+12
-14
common/djangoapps/external_auth/tests/test_ssl.py
+6
-10
common/djangoapps/geoinfo/tests/test_middleware.py
+6
-8
common/djangoapps/reverification/tests/test_models.py
+2
-2
common/djangoapps/student/tests/test_bulk_email_settings.py
+12
-10
common/djangoapps/student/tests/test_login.py
+7
-10
common/djangoapps/student/tests/tests.py
+24
-21
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
+58
-14
common/lib/xmodule/xmodule/modulestore/tests/test_assetstore.py
+4
-3
common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py
+6
-4
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
+8
-6
common/lib/xmodule/xmodule/modulestore/tests/test_publish.py
+4
-1
common/lib/xmodule/xmodule/modulestore/tests/test_split_migrator.py
+5
-1
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
+5
-2
common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py
+9
-6
lms/djangoapps/branding/tests.py
+7
-8
lms/djangoapps/bulk_email/tests/test_course_optout.py
+3
-4
lms/djangoapps/bulk_email/tests/test_email.py
+6
-8
lms/djangoapps/bulk_email/tests/test_err_handling.py
+9
-12
lms/djangoapps/bulk_email/tests/test_forms.py
+11
-13
lms/djangoapps/class_dashboard/tests/test_dashboard_data.py
+7
-6
lms/djangoapps/class_dashboard/tests/test_views.py
+6
-7
lms/djangoapps/course_wiki/tests/test_access.py
+2
-2
lms/djangoapps/course_wiki/tests/test_middleware.py
+2
-2
lms/djangoapps/course_wiki/tests/tests.py
+2
-2
lms/djangoapps/courseware/management/commands/tests/test_dump_course.py
+17
-21
lms/djangoapps/courseware/tests/__init__.py
+1
-1
lms/djangoapps/courseware/tests/modulestore_config.py
+0
-31
lms/djangoapps/courseware/tests/test_about.py
+26
-22
lms/djangoapps/courseware/tests/test_access.py
+7
-9
lms/djangoapps/courseware/tests/test_course_info.py
+19
-9
lms/djangoapps/courseware/tests/test_courses.py
+58
-24
lms/djangoapps/courseware/tests/test_draft_modulestore.py
+5
-2
lms/djangoapps/courseware/tests/test_grades.py
+4
-5
lms/djangoapps/courseware/tests/test_i18n.py
+5
-3
lms/djangoapps/courseware/tests/test_lti_integration.py
+9
-12
lms/djangoapps/courseware/tests/test_masquerade.py
+10
-9
lms/djangoapps/courseware/tests/test_microsites.py
+6
-7
lms/djangoapps/courseware/tests/test_middleware.py
+2
-2
lms/djangoapps/courseware/tests/test_module_render.py
+36
-28
lms/djangoapps/courseware/tests/test_navigation.py
+5
-7
lms/djangoapps/courseware/tests/test_split_module.py
+4
-5
lms/djangoapps/courseware/tests/test_submitting_problems.py
+9
-14
lms/djangoapps/courseware/tests/test_tabs.py
+13
-11
lms/djangoapps/courseware/tests/test_view_authentication.py
+10
-14
lms/djangoapps/courseware/tests/test_views.py
+28
-26
lms/djangoapps/courseware/tests/tests.py
+12
-18
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
+5
-5
lms/djangoapps/dashboard/tests/test_support.py
+8
-9
lms/djangoapps/dashboard/tests/test_sysadmin.py
+9
-9
lms/djangoapps/django_comment_client/base/tests.py
+9
-9
lms/djangoapps/django_comment_client/forum/tests.py
+26
-30
lms/djangoapps/django_comment_client/tests/test_models.py
+19
-10
lms/djangoapps/django_comment_client/tests/test_utils.py
+22
-9
lms/djangoapps/django_comment_client/tests/utils.py
+3
-3
lms/djangoapps/instructor/management/tests/test_openended_commands.py
+23
-11
lms/djangoapps/instructor/tests/test_access.py
+5
-5
lms/djangoapps/instructor/tests/test_api.py
+47
-48
lms/djangoapps/instructor/tests/test_ecommerce.py
+7
-8
lms/djangoapps/instructor/tests/test_email.py
+7
-11
lms/djangoapps/instructor/tests/test_enrollment.py
+3
-3
lms/djangoapps/instructor/tests/test_hint_manager.py
+2
-2
lms/djangoapps/instructor/tests/test_legacy_anon_csv.py
+2
-2
lms/djangoapps/instructor/tests/test_legacy_download_csv.py
+2
-2
lms/djangoapps/instructor/tests/test_legacy_email.py
+3
-4
lms/djangoapps/instructor/tests/test_legacy_enrollment.py
+2
-2
lms/djangoapps/instructor/tests/test_legacy_forum_admin.py
+2
-2
lms/djangoapps/instructor/tests/test_legacy_reset.py
+2
-2
lms/djangoapps/instructor/tests/test_legacy_xss.py
+2
-2
lms/djangoapps/instructor/tests/test_spoc_gradebook.py
+2
-2
lms/djangoapps/instructor/tests/test_tools.py
+5
-5
lms/djangoapps/instructor_task/tests/test_api.py
+2
-4
lms/djangoapps/instructor_task/tests/test_base.py
+9
-11
lms/djangoapps/instructor_task/tests/test_integration.py
+1
-1
lms/djangoapps/licenses/tests.py
+2
-2
lms/djangoapps/mobile_api/course_info/tests.py
+4
-3
lms/djangoapps/mobile_api/video_outlines/tests.py
+12
-12
lms/djangoapps/notifier_api/tests.py
+1
-1
lms/djangoapps/oauth2_handler/tests.py
+4
-5
lms/djangoapps/open_ended_grading/tests.py
+35
-26
lms/djangoapps/shoppingcart/tests/test_context_processor.py
+6
-5
lms/djangoapps/shoppingcart/tests/test_reports.py
+5
-5
lms/djangoapps/staticbook/tests.py
+2
-2
lms/djangoapps/verify_student/tests/test_models.py
+12
-10
lms/djangoapps/verify_student/tests/test_ssencrypt.py
+0
-3
No files found.
cms/djangoapps/contentstore/tests/utils.py
View file @
17379f40
...
...
@@ -2,23 +2,24 @@
'''
Utilities for contentstore tests
'''
import
json
from
django.
test.client
import
Client
from
django.
conf
import
settings
from
django.contrib.auth.models
import
User
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
,
AssetLocation
from
contentstore.utils
import
reverse_url
from
student.models
import
Registration
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.contentstore.django
import
contentstore
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.inheritance
import
own_metadata
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
student.models
import
Registration
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
,
AssetLocation
from
contentstore.utils
import
reverse_url
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
django.conf
import
settings
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
...
...
@@ -66,7 +67,12 @@ class AjaxEnabledTestClient(Client):
return
self
.
get
(
path
,
data
or
{},
follow
,
HTTP_ACCEPT
=
"application/json"
,
**
extra
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
class
CourseTestCase
(
ModuleStoreTestCase
):
"""
Base class for Studio tests that require a logged in user and a course.
Also provides helper methods for manipulating and verifying the course.
"""
def
setUp
(
self
):
"""
These tests need a user in the DB so that the django Test Client can log them in.
...
...
common/djangoapps/course_groups/tests/test_cohorts.py
View file @
17379f40
import
django.test
from
django.contrib.auth.models
import
User
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.http
import
Http404
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
mock
import
call
,
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
from
course_groups.models
import
CourseUserGroup
from
course_groups
import
cohorts
from
course_groups.models
import
CourseUserGroup
from
course_groups.tests.helpers
import
topic_name_to_id
,
config_course_cohorts
,
CohortFactory
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_TOY_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
mixed_store_config
# NOTE: running this with the lms.envs.test config works without
# manually overriding the modulestore. However, running with
# cms.envs.test doesn't.
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
TEST_MAPPING
=
{
'edX/toy/2012_Fall'
:
'xml'
}
TEST_DATA_MIXED_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
TEST_MAPPING
)
@patch
(
"course_groups.cohorts.tracker"
)
class
TestCohortSignals
(
django
.
test
.
TestCase
):
class
TestCohortSignals
(
TestCase
):
def
setUp
(
self
):
self
.
course_key
=
SlashSeparatedCourseKey
(
"dummy"
,
"dummy"
,
"dummy"
)
...
...
@@ -123,9 +115,11 @@ class TestCohortSignals(django.test.TestCase):
self
.
assertFalse
(
mock_tracker
.
emit
.
called
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
TestCohorts
(
django
.
test
.
TestCase
):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
)
class
TestCohorts
(
TestCase
):
"""
Test the cohorts feature
"""
def
setUp
(
self
):
"""
Make sure that course is reloaded every time--clear out the modulestore.
...
...
common/djangoapps/course_groups/tests/test_views.py
View file @
17379f40
"""
Tests for course group views
"""
from
collections
import
namedtuple
import
json
from
django.contrib.auth.models
import
User
from
django.http
import
Http404
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
course_groups.tests.helpers
import
config_course_cohorts
,
CohortFactory
from
collections
import
namedtuple
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
django.http
import
Http404
from
django.contrib.auth.models
import
User
from
courseware.tests.tests
import
TEST_DATA_MIXED_MODULESTORE
from
course_groups.cohorts
import
(
get_cohort
,
CohortAssignmentType
,
get_cohort_by_name
,
DEFAULT_COHORT_NAME
)
from
course_groups.models
import
CourseUserGroup
from
course_groups.tests.helpers
import
config_course_cohorts
,
CohortFactory
from
course_groups.views
import
(
list_cohorts
,
add_cohort
,
users_in_cohort
,
add_users_to_cohort
,
remove_user_from_cohort
)
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
course_groups.models
import
CourseUserGroup
from
course_groups.views
import
list_cohorts
,
add_cohort
,
users_in_cohort
,
add_users_to_cohort
,
remove_user_from_cohort
from
course_groups.cohorts
import
get_cohort
,
CohortAssignmentType
,
get_cohort_by_name
,
DEFAULT_COHORT_NAME
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
CohortViewsTestCase
(
ModuleStoreTestCase
):
"""
Base class which sets up a course and staff/non-staff users.
...
...
common/djangoapps/embargo/tests/test_forms.py
View file @
17379f40
...
...
@@ -13,10 +13,10 @@ from embargo.models import EmbargoedCourse, EmbargoedState, IPFilter
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
EmbargoCourseFormTest
(
ModuleStoreTestCase
):
"""Test the course form properly validates course IDs"""
...
...
common/djangoapps/external_auth/tests/test_shib.py
View file @
17379f40
...
...
@@ -4,9 +4,8 @@ Tests for Shibboleth Authentication
@jbau
"""
import
unittest
from
mock
import
patch
from
ddt
import
ddt
,
data
from
ddt
import
ddt
,
data
from
django.conf
import
settings
from
django.http
import
HttpResponseRedirect
from
django.test
import
TestCase
...
...
@@ -15,22 +14,21 @@ from django.test.utils import override_settings
from
django.core.urlresolvers
import
reverse
from
django.contrib.auth.models
import
AnonymousUser
,
User
from
django.utils.importlib
import
import_module
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
mixed_store_config
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
ModuleStoreEnum
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
edxmako.tests
import
mako_middleware_process_request
from
external_auth.models
import
ExternalAuthMap
from
external_auth.views
import
shib_login
,
course_specific_login
,
course_specific_register
,
_flatten_to_ascii
from
external_auth.views
import
(
shib_login
,
course_specific_login
,
course_specific_register
,
_flatten_to_ascii
)
from
mock
import
patch
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.views
import
create_account
,
change_enrollment
from
student.models
import
UserProfile
,
Registration
,
CourseEnrollment
from
student.models
import
UserProfile
,
CourseEnrollment
from
student.tests.factories
import
UserFactory
from
edxmako.tests
import
mako_middleware_process_request
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore
import
ModuleStoreEnum
TEST_DATA_MIXED_MODULESTORE
=
mixed_store_config
(
settings
.
COMMON_TEST_DATA_ROOT
,
{})
# Shib is supposed to provide 'REMOTE_USER', 'givenName', 'sn', 'mail', 'Shib-Identity-Provider'
# attributes via request.META. We can count on 'Shib-Identity-Provider', and 'REMOTE_USER' being present
...
...
@@ -75,7 +73,7 @@ def gen_all_identities():
@ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
,
SESSION_ENGINE
=
'django.contrib.sessions.backends.cache'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
,
SESSION_ENGINE
=
'django.contrib.sessions.backends.cache'
)
class
ShibSPTest
(
ModuleStoreTestCase
):
"""
Tests for the Shibboleth SP, which communicates via request.META
...
...
common/djangoapps/external_auth/tests/test_ssl.py
View file @
17379f40
...
...
@@ -2,7 +2,6 @@
Provides unit tests for SSL based authentication portions
of the external_auth app.
"""
import
unittest
from
django.conf
import
settings
...
...
@@ -13,17 +12,16 @@ from django.core.urlresolvers import reverse
from
django.test.client
import
Client
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
mock
import
Mock
import
external_auth.views
from
edxmako.middleware
import
MakoMiddleware
from
external_auth.models
import
ExternalAuthMap
from
opaque_keys
import
InvalidKeyError
import
external_auth.views
from
mock
import
Mock
from
student.models
import
CourseEnrollment
from
student.roles
import
CourseStaffRole
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
(
ModuleStoreTestCase
,
mixed_store_config
)
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
FEATURES_WITH_SSL_AUTH
=
settings
.
FEATURES
.
copy
()
...
...
@@ -35,8 +33,6 @@ FEATURES_WITH_SSL_AUTH_AUTO_ACTIVATE['BYPASS_ACTIVATION_EMAIL_FOR_EXTAUTH'] = Tr
FEATURES_WITHOUT_SSL_AUTH
=
settings
.
FEATURES
.
copy
()
FEATURES_WITHOUT_SSL_AUTH
[
'AUTH_USE_CERTIFICATES'
]
=
False
TEST_DATA_MIXED_MODULESTORE
=
mixed_store_config
(
settings
.
COMMON_TEST_DATA_ROOT
,
{})
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH
)
class
SSLClientTest
(
ModuleStoreTestCase
):
...
...
@@ -325,7 +321,7 @@ class SSLClientTest(ModuleStoreTestCase):
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
@override_settings
(
FEATURES
=
FEATURES_WITH_SSL_AUTH_AUTO_ACTIVATE
,
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
def
test_ssl_lms_redirection
(
self
):
"""
Auto signup auth user and ensure they return to the original
...
...
common/djangoapps/geoinfo/tests/test_middleware.py
View file @
17379f40
"""
Tests for CountryMiddleware.
"""
from
mock
import
Mock
,
patch
from
mock
import
patch
import
pygeoip
from
django.contrib.sessions.middleware
import
SessionMiddleware
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.test.client
import
RequestFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
,
AnonymousUserFactory
from
django.contrib.sessions.middleware
import
SessionMiddleware
from
geoinfo.middleware
import
CountryMiddleware
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.tests.factories
import
UserFactory
,
AnonymousUserFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CountryMiddlewareTests
(
TestCase
):
"""
Tests of CountryMiddleware.
...
...
common/djangoapps/reverification/tests/test_models.py
View file @
17379f40
...
...
@@ -7,14 +7,14 @@ import pytz
from
django.core.exceptions
import
ValidationError
from
django.test.utils
import
override_settings
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
reverification.models
import
MidcourseReverificationWindow
from
reverification.tests.factories
import
MidcourseReverificationWindowFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestMidcourseReverificationWindow
(
ModuleStoreTestCase
):
""" Tests for MidcourseReverificationWindow objects """
...
...
common/djangoapps/student/tests/test_bulk_email_settings.py
View file @
17379f40
...
...
@@ -4,25 +4,27 @@ that bulk email is always disabled for non-Mongo backed courses, regardless
of email feature flag, and that the view is conditionally available when
Course Auth is turned on.
"""
import
unittest
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
import
unittest
from
django.test.utils
import
override_settings
from
mock
import
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
bulk_email.models
import
CourseAuthorization
from
mock
import
patch
# This import is for an lms djangoapp.
# Its testcases are only run under lms.
from
bulk_email.models
import
CourseAuthorization
# pylint: disable=import-error
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardEmailView
(
ModuleStoreTestCase
):
"""
...
...
@@ -88,7 +90,7 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase):
self
.
assertTrue
(
self
.
email_modal_link
in
response
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardEmailViewXMLBacked
(
ModuleStoreTestCase
):
"""
...
...
common/djangoapps/student/tests/test_login.py
View file @
17379f40
...
...
@@ -3,7 +3,6 @@ Tests for student activation and login
'''
import
json
import
unittest
from
mock
import
patch
from
django.test
import
TestCase
from
django.test.client
import
Client
...
...
@@ -12,23 +11,21 @@ from django.conf import settings
from
django.core.cache
import
cache
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
django.http
import
HttpResponseBadRequest
,
HttpResponse
from
external_auth.models
import
ExternalAuthMap
import
httpretty
from
mock
import
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
social.apps.django_app.default.models
import
UserSocialAuth
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.tests.factories
import
UserFactory
,
RegistrationFactory
,
UserProfileFactory
from
student.views
import
(
_parse_course_id_from_string
,
_get_course_enrollment_domain
,
login_oauth_token
,
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
mixed_store_config
from
xmodule.modulestore.django
import
modulestore
from
external_auth.models
import
ExternalAuthMap
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
TEST_DATA_MIXED_MODULESTORE
=
mixed_store_config
(
settings
.
COMMON_TEST_DATA_ROOT
,
{})
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
class
LoginTest
(
TestCase
):
...
...
@@ -345,7 +342,7 @@ class UtilFnTest(TestCase):
self
.
assertIsNone
(
_parse_course_id_from_string
(
NON_COURSE_URL
))
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
ExternalAuthShibTest
(
ModuleStoreTestCase
):
"""
Tests how login_user() interacts with ExternalAuth, in particular Shib
...
...
common/djangoapps/student/tests/tests.py
View file @
17379f40
...
...
@@ -5,35 +5,38 @@ when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
import
logging
import
unittest
from
datetime
import
datetime
,
timedelta
import
logging
import
pytz
import
unittest
from
django.conf
import
settings
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
django.test.client
import
RequestFactory
,
Client
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.core.urlresolvers
import
reverse
from
django.contrib.sessions.middleware
import
SessionMiddleware
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.tests
import
TEST_DATA_MIXED_MODULESTORE
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
,
Client
from
django.test.utils
import
override_settings
from
mock
import
Mock
,
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.models
import
anonymous_id_for_user
,
user_by_anonymous_id
,
CourseEnrollment
,
unique_id_for_user
from
student.models
import
(
anonymous_id_for_user
,
user_by_anonymous_id
,
CourseEnrollment
,
unique_id_for_user
)
from
student.views
import
(
process_survey_link
,
_cert_info
,
change_enrollment
,
complete_course_mode_info
)
from
student.tests.factories
import
UserFactory
,
CourseModeFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
# These imports refer to lms djangoapps.
# Their testcases are only run under lms.
from
bulk_email.models
import
Optout
# pylint: disable=import-error
from
certificates.models
import
CertificateStatuses
# pylint: disable=import-error
from
certificates.tests.factories
import
GeneratedCertificateFactory
# pylint: disable=import-error
import
shoppingcart
# pylint: disable=import-error
from
certificates.models
import
CertificateStatuses
from
certificates.tests.factories
import
GeneratedCertificateFactory
import
shoppingcart
from
bulk_email.models
import
Optout
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -176,7 +179,7 @@ class CourseEndingTest(TestCase):
self
.
assertIsNone
(
_cert_info
(
user
,
course2
,
cert_status
))
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
DashboardTest
(
ModuleStoreTestCase
):
"""
Tests for dashboard utility functions
...
...
@@ -580,7 +583,7 @@ class EnrollInCourseTest(TestCase):
self
.
assert_enrollment_mode_change_event_was_emitted
(
user
,
course_id
,
"honor"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
ChangeEnrollmentViewTest
(
ModuleStoreTestCase
):
"""Tests the student.views.change_enrollment view"""
...
...
@@ -663,7 +666,7 @@ class ChangeEnrollmentViewTest(ModuleStoreTestCase):
self
.
assertEqual
(
enrollment_mode
,
u'honor'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
PaidRegistrationTest
(
ModuleStoreTestCase
):
"""
Tests for paid registration functionality (not verified student), involves shoppingcart
...
...
@@ -696,7 +699,7 @@ class PaidRegistrationTest(ModuleStoreTestCase):
shoppingcart
.
models
.
Order
.
get_cart_for_user
(
self
.
user
),
self
.
course
.
id
))
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
AnonymousLookupTable
(
ModuleStoreTestCase
):
"""
Tests for anonymous_id_functions
...
...
common/lib/xmodule/xmodule/modulestore/tests/django_utils.py
View file @
17379f40
...
...
@@ -2,21 +2,25 @@
"""
Modulestore configuration for test cases.
"""
import
datetime
import
pytz
from
tempfile
import
mkdtemp
from
uuid
import
uuid4
from
django.test
import
TestCase
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.test
import
TestCase
from
request_cache.middleware
import
RequestCache
from
xmodule.contentstore.django
import
_CONTENTSTORE
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
xmodule.modulestore
import
ModuleStoreEnum
import
datetime
import
pytz
from
request_cache.middleware
import
RequestCache
from
xmodule.tabs
import
CoursewareTab
,
CourseInfoTab
,
StaticTab
,
DiscussionTab
,
ProgressTab
,
WikiTab
from
xmodule.modulestore.tests.sample_courses
import
default_block_info_tree
,
TOY_BLOCK_INFO_TREE
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
xmodule.modulestore.tests.sample_courses
import
default_block_info_tree
,
TOY_BLOCK_INFO_TREE
from
xmodule.tabs
import
CoursewareTab
,
CourseInfoTab
,
StaticTab
,
DiscussionTab
,
ProgressTab
,
WikiTab
def
mixed_store_config
(
data_dir
,
mappings
,
include_xml
=
Tru
e
):
def
mixed_store_config
(
data_dir
,
mappings
,
include_xml
=
False
,
xml_course_dirs
=
Non
e
):
"""
Return a `MixedModuleStore` configuration, which provides
access to both Mongo- and XML-backed courses.
...
...
@@ -36,9 +40,13 @@ def mixed_store_config(data_dir, mappings, include_xml=True):
Keyword Args:
include_xml (boolean): If True, include an XML modulestore in the configuration.
Note that this will require importing multiple XML courses from disk,
so unless your tests really needs XML course fixtures or is explicitly
testing mixed modulestore, set this to False.
xml_course_dirs (list): The directories containing XML courses to load from disk.
note: For the courses to be loaded into the XML modulestore and accessible do the following:
* include_xml should be True
* xml_course_dirs should be the list of directories (relative to data_dir)
containing the courses you want to load
* mappings should be configured, pointing the xml courses to the xml modulestore
"""
stores
=
[
...
...
@@ -47,7 +55,7 @@ def mixed_store_config(data_dir, mappings, include_xml=True):
]
if
include_xml
:
stores
.
append
(
xml_store_config
(
data_dir
)[
'default'
])
stores
.
append
(
xml_store_config
(
data_dir
,
course_dirs
=
xml_course_dirs
)[
'default'
])
store
=
{
'default'
:
{
...
...
@@ -80,7 +88,7 @@ def draft_mongo_store_config(data_dir):
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
'collection'
:
'modulestore
_
{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
},
'OPTIONS'
:
modulestore_options
}
...
...
@@ -107,7 +115,7 @@ def split_mongo_store_config(data_dir):
'host'
:
MONGO_HOST
,
'port'
:
MONGO_PORT_NUM
,
'db'
:
'test_xmodule'
,
'collection'
:
'modulestore{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
'collection'
:
'modulestore
_
{0}'
.
format
(
uuid4
()
.
hex
[:
5
]),
},
'OPTIONS'
:
modulestore_options
}
...
...
@@ -119,6 +127,9 @@ def split_mongo_store_config(data_dir):
def
xml_store_config
(
data_dir
,
course_dirs
=
None
):
"""
Defines default module store using XMLModuleStore.
Note: you should pass in a list of course_dirs that you care about,
otherwise all courses in the data_dir will be processed.
"""
store
=
{
'default'
:
{
...
...
@@ -134,6 +145,39 @@ def xml_store_config(data_dir, course_dirs=None):
return
store
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
# This is an XML only modulestore with only the toy course loaded
TEST_DATA_XML_MODULESTORE
=
xml_store_config
(
TEST_DATA_DIR
,
course_dirs
=
[
'toy'
])
# This modulestore will provide both a mixed mongo editable modulestore, and
# an XML store with just the toy course loaded.
TEST_DATA_MIXED_TOY_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
{
'edX/toy/2012_Fall'
:
'xml'
,
},
include_xml
=
True
,
xml_course_dirs
=
[
'toy'
]
)
# This modulestore will provide both a mixed mongo editable modulestore, and
# an XML store with common/test/data/2014 loaded, which is a course that is closed.
TEST_DATA_MIXED_CLOSED_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
{
'edX/detached_pages/2014'
:
'xml'
,
},
include_xml
=
True
,
xml_course_dirs
=
[
'2014'
]
)
# This modulestore will provide both a mixed mongo editable modulestore, and
# an XML store with common/test/data/graded loaded, which is a course that is graded.
TEST_DATA_MIXED_GRADED_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
{
'edX/graded/2012_Fall'
:
'xml'
,
},
include_xml
=
True
,
xml_course_dirs
=
[
'graded'
]
)
# All store requests now go through mixed
# Use this modulestore if you specifically want to test mongo and not a mocked modulestore.
# This modulestore definition below will not load any xml courses.
TEST_DATA_MONGO_MODULESTORE
=
mixed_store_config
(
mkdtemp
(),
{},
include_xml
=
False
)
# Unit tests that are not specifically testing the modulestore implementation but just need course context can use a mocked modulestore.
# Use this modulestore if you do not care about the underlying implementation.
# TODO: acutally mock out the modulestore for this in a subsequent PR.
TEST_DATA_MOCK_MODULESTORE
=
mixed_store_config
(
mkdtemp
(),
{},
include_xml
=
False
)
class
ModuleStoreTestCase
(
TestCase
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_assetstore.py
View file @
17379f40
...
...
@@ -3,17 +3,17 @@ Tests for assetstore using any of the modulestores for metadata. May extend to t
too.
"""
from
datetime
import
datetime
,
timedelta
import
ddt
from
nose.plugins.attrib
import
attr
import
pytz
import
unittest
import
ddt
from
xmodule.assetstore
import
AssetMetadata
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.test_cross_modulestore_import_export
import
(
MIXED_MODULESTORE_BOTH_SETUP
,
MODULESTORE_SETUPS
,
MongoContentstoreBuilder
,
XmlModulestoreBuilder
,
MixedModulestoreBuilder
,
MongoModulestoreBuilder
XmlModulestoreBuilder
,
MixedModulestoreBuilder
)
...
...
@@ -43,6 +43,7 @@ class AssetStoreTestData(object):
)
@attr
(
'mongo'
)
@ddt.ddt
class
TestMongoAssetMetadataStorage
(
unittest
.
TestCase
):
"""
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_cross_modulestore_import_export.py
View file @
17379f40
...
...
@@ -11,16 +11,17 @@ and then for each combination of modulestores, performing the sequence:
4) Compare all modules in the source and destination modulestores to make sure that they line up
"""
import
ddt
from
contextlib
import
contextmanager
,
nested
import
itertools
from
path
import
path
import
random
from
contextlib
import
contextmanager
,
nested
from
shutil
import
rmtree
from
tempfile
import
mkdtemp
from
path
import
path
from
xmodule.tests
import
CourseComparisonTest
import
ddt
from
nose.plugins.attrib
import
attr
from
xmodule.tests
import
CourseComparisonTest
from
xmodule.modulestore.mongo.base
import
ModuleStoreEnum
from
xmodule.modulestore.mongo.draft
import
DraftModuleStore
from
xmodule.modulestore.mixed
import
MixedModuleStore
...
...
@@ -289,6 +290,7 @@ COURSE_DATA_NAMES = (
@ddt.ddt
@attr
(
'mongo'
)
class
CrossStoreXMLRoundtrip
(
CourseComparisonTest
):
"""
This class exists to test XML import and export between different modulestore
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_mixed_modulestore.py
View file @
17379f40
...
...
@@ -2,25 +2,26 @@
"""
Unit tests for the Mixed Modulestore, with DDT for the various stores (Split, Draft, XML)
"""
from
collections
import
namedtuple
import
datetime
import
ddt
import
itertools
import
pymongo
from
collections
import
namedtuple
from
importlib
import
import_module
from
pytz
import
UTC
import
itertools
import
mimetypes
from
uuid
import
uuid4
# Mixed modulestore depends on django, so we'll manually configure some django settings
# before importing the module
# TODO remove this import and the configuration -- xmodule should not depend on django!
from
django.conf
import
settings
from
nose.plugins.attrib
import
attr
import
pymongo
from
pytz
import
UTC
from
xmodule.modulestore.edit_info
import
EditInfoMixin
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
xmodule.modulestore.tests.test_cross_modulestore_import_export
import
MongoContentstoreBuilder
from
xmodule.contentstore.content
import
StaticContent
import
mimetypes
from
opaque_keys.edx.keys
import
CourseKey
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
nose
import
SkipTest
...
...
@@ -43,6 +44,7 @@ from xmodule.tests import DATA_DIR, CourseComparisonTest
@ddt.ddt
@attr
(
'mongo'
)
class
TestMixedModuleStore
(
CourseComparisonTest
):
"""
Quasi-superclass which tests Location based apps against both split and mongo dbs (Locator and
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_publish.py
View file @
17379f40
"""
Test the publish code (mostly testing that publishing doesn't result in orphans)
"""
from
nose.plugins.attrib
import
attr
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
xmodule.modulestore.tests.test_split_w_old_mongo
import
SplitWMongoCourseBoostrapper
from
xmodule.modulestore.tests.factories
import
check_mongo_calls
,
mongo_uses_error_check
from
xmodule.modulestore
import
ModuleStoreEnum
@attr
(
'mongo'
)
class
TestPublish
(
SplitWMongoCourseBoostrapper
):
"""
Test the publish code (primary causing orphans)
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_migrator.py
View file @
17379f40
...
...
@@ -2,14 +2,18 @@
Tests for split_migrator
"""
import
uuid
import
random
import
uuid
import
mock
from
nose.plugins.attrib
import
attr
from
xblock.fields
import
Reference
,
ReferenceList
,
ReferenceValueDict
from
xmodule.modulestore.split_migrator
import
SplitMigrator
from
xmodule.modulestore.tests.test_split_w_old_mongo
import
SplitWMongoCourseBoostrapper
@attr
(
'mongo'
)
class
TestMigration
(
SplitWMongoCourseBoostrapper
):
"""
Test the split migrator
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py
View file @
17379f40
...
...
@@ -2,13 +2,15 @@
Test split modulestore w/o using any django stuff.
"""
import
datetime
from
importlib
import
import_module
from
path
import
path
import
random
import
re
import
unittest
import
uuid
from
contracts
import
contract
from
importlib
import
import_module
from
path
import
path
from
nose.plugins.attrib
import
attr
from
xblock.fields
import
Reference
,
ReferenceList
,
ReferenceValueDict
from
xmodule.course_module
import
CourseDescriptor
...
...
@@ -33,6 +35,7 @@ BRANCH_NAME_DRAFT = ModuleStoreEnum.BranchName.draft
BRANCH_NAME_PUBLISHED
=
ModuleStoreEnum
.
BranchName
.
published
@attr
(
'mongo'
)
class
SplitModuleTest
(
unittest
.
TestCase
):
'''
The base set of tests manually populates a db w/ courses which have
...
...
common/lib/xmodule/xmodule/modulestore/tests/test_split_w_old_mongo.py
View file @
17379f40
import
unittest
import
mock
import
datetime
import
uuid
import
random
import
unittest
import
uuid
from
nose.plugins.attrib
import
attr
import
mock
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
opaque_keys.edx.locator
import
CourseLocator
,
BlockUsageLocator
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.modulestore.mongo
import
DraftMongoModuleStore
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.inheritance
import
InheritanceMixin
from
xmodule.modulestore.mongo
import
DraftMongoModuleStore
from
xmodule.modulestore.split_mongo.split
import
SplitMongoModuleStore
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
xmodule.modulestore.tests.test_cross_modulestore_import_export
import
MemoryCache
@attr
(
'mongo'
)
class
SplitWMongoCourseBoostrapper
(
unittest
.
TestCase
):
"""
Helper for tests which need to construct split mongo & old mongo based courses to get interesting internal structure.
...
...
lms/djangoapps/branding/tests.py
View file @
17379f40
...
...
@@ -2,20 +2,19 @@
Tests for branding page
"""
import
datetime
from
django.http
import
HttpResponseRedirect
from
pytz
import
UTC
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.http
import
HttpResponseRedirect
from
django.test.utils
import
override_settings
from
django.test.client
import
RequestFactory
from
pytz
import
UTC
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
import
student.views
from
branding.views
import
index
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
edxmako.tests
import
mako_middleware_process_request
import
student.views
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
FEATURES_WITH_STARTDATE
=
settings
.
FEATURES
.
copy
()
FEATURES_WITH_STARTDATE
[
'DISABLE_START_DATES'
]
=
False
...
...
@@ -23,7 +22,7 @@ FEATURES_WO_STARTDATE = settings.FEATURES.copy()
FEATURES_WO_STARTDATE
[
'DISABLE_START_DATES'
]
=
True
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AnonymousIndexPageTest
(
ModuleStoreTestCase
):
"""
Tests that anonymous users can access the '/' page, Need courses with start date
...
...
lms/djangoapps/bulk_email/tests/test_course_optout.py
View file @
17379f40
...
...
@@ -3,6 +3,7 @@
Unit tests for student optouts from course email
"""
import
json
from
mock
import
patch
from
django.core
import
mail
from
django.core.management
import
call_command
...
...
@@ -10,16 +11,14 @@ from django.core.urlresolvers import reverse
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.tests.factories
import
UserFactory
,
AdminFactory
,
CourseEnrollmentFactory
from
student.models
import
CourseEnrollment
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
mock
import
patch
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestOptoutCourseEmails
(
ModuleStoreTestCase
):
"""
...
...
lms/djangoapps/bulk_email/tests/test_email.py
View file @
17379f40
...
...
@@ -3,7 +3,6 @@
Unit tests for sending course email
"""
import
json
from
mock
import
patch
from
django.conf
import
settings
...
...
@@ -12,16 +11,15 @@ from django.core.urlresolvers import reverse
from
django.core.management
import
call_command
from
django.test.utils
import
override_settings
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
courseware.tests.factories
import
StaffFactory
,
InstructorFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
bulk_email.models
import
Optout
from
courseware.tests.factories
import
StaffFactory
,
InstructorFactory
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
instructor_task.subtasks
import
update_subtask_status
from
student.roles
import
CourseStaffRole
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
STAFF_COUNT
=
3
STUDENT_COUNT
=
10
...
...
@@ -44,7 +42,7 @@ class MockCourseEmailResult(object):
return
mock_update_subtask_status
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestEmailSendFromDashboard
(
ModuleStoreTestCase
):
"""
...
...
lms/djangoapps/bulk_email/tests/test_err_handling.py
View file @
17379f40
...
...
@@ -2,28 +2,21 @@
"""
Unit tests for handling email sending errors
"""
import
json
from
itertools
import
cycle
from
mock
import
patch
from
smtplib
import
SMTPDataError
,
SMTPServerDisconnected
,
SMTPConnectError
from
celery.states
import
SUCCESS
,
RETRY
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.core.management
import
call_command
from
django.core.urlresolvers
import
reverse
from
django.db
import
DatabaseError
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.tests.factories
import
UserFactory
,
AdminFactory
,
CourseEnrollmentFactory
import
json
from
mock
import
patch
from
smtplib
import
SMTPDataError
,
SMTPServerDisconnected
,
SMTPConnectError
from
bulk_email.models
import
CourseEmail
,
SEND_TO_ALL
from
bulk_email.tasks
import
perform_delegate_email_batches
,
send_course_email
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
instructor_task.models
import
InstructorTask
from
instructor_task.subtasks
import
(
initialize_subtask_info
,
...
...
@@ -33,6 +26,10 @@ from instructor_task.subtasks import (
DuplicateTaskException
,
MAX_DATABASE_LOCK_RETRIES
,
)
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.tests.factories
import
UserFactory
,
AdminFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
class
EmailTestException
(
Exception
):
...
...
@@ -40,7 +37,7 @@ class EmailTestException(Exception):
pass
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestEmailErrors
(
ModuleStoreTestCase
):
"""
...
...
lms/djangoapps/bulk_email/tests/test_forms.py
View file @
17379f40
...
...
@@ -2,25 +2,23 @@
"""
Unit tests for bulk-email-related forms.
"""
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
ModuleStoreEnum
from
django.test.utils
import
override_settings
from
mock
import
patch
from
bulk_email.models
import
CourseAuthorization
,
CourseEmailTemplate
from
bulk_email.forms
import
CourseAuthorizationAdminForm
,
CourseEmailTemplateForm
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
)
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore
import
ModuleStoreEnum
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CourseAuthorizationFormTest
(
ModuleStoreTestCase
):
"""Test the CourseAuthorizationAdminForm form for Mongo-backed courses."""
...
...
@@ -124,7 +122,7 @@ class CourseAuthorizationFormTest(ModuleStoreTestCase):
form
.
save
()
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
class
CourseAuthorizationXMLFormTest
(
ModuleStoreTestCase
):
"""Check that XML courses cannot be authorized for email."""
...
...
@@ -147,7 +145,7 @@ class CourseAuthorizationXMLFormTest(ModuleStoreTestCase):
form
.
save
()
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CourseEmailTemplateFormTest
(
ModuleStoreTestCase
):
"""Test the CourseEmailTemplateForm that is used in the Django admin subsystem."""
...
...
lms/djangoapps/class_dashboard/tests/test_dashboard_data.py
View file @
17379f40
...
...
@@ -3,17 +3,18 @@ Tests for class dashboard (Metrics tab in instructor dashboard)
"""
import
json
from
mock
import
patch
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.test.client
import
RequestFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
mock
import
patch
from
capa.tests.response_xml_factory
import
StringResponseXMLFactory
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
courseware.tests.factories
import
StudentModuleFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
,
AdminFactory
from
capa.tests.response_xml_factory
import
StringResponseXMLFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
class_dashboard.dashboard_data
import
(
get_problem_grade_distribution
,
get_sequential_open_distrib
,
get_problem_set_grade_distrib
,
get_d3_problem_grade_distrib
,
...
...
@@ -26,7 +27,7 @@ from class_dashboard.views import has_instructor_access_for_class
USER_COUNT
=
11
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestGetProblemGradeDistribution
(
ModuleStoreTestCase
):
"""
Tests related to class_dashboard/dashboard_data.py
...
...
lms/djangoapps/class_dashboard/tests/test_views.py
View file @
17379f40
"""
Tests for class dashboard (Metrics tab in instructor dashboard)
"""
from
mock
import
patch
from
django.test.utils
import
override_settings
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
AdminFactory
from
django.utils
import
simplejson
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
mock
import
patch
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
class_dashboard
import
views
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestViews
(
ModuleStoreTestCase
):
"""
Tests related to class_dashboard/views.py
...
...
lms/djangoapps/course_wiki/tests/test_access.py
View file @
17379f40
...
...
@@ -9,7 +9,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from
django.test.utils
import
override_settings
from
courseware.tests.factories
import
InstructorFactory
,
StaffFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
wiki.models
import
URLPath
from
course_wiki.views
import
get_or_create_root
...
...
@@ -17,7 +17,7 @@ from course_wiki.utils import user_is_article_course_staff, course_wiki_slug
from
course_wiki
import
settings
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestWikiAccessBase
(
ModuleStoreTestCase
):
"""Base class for testing wiki access."""
def
setUp
(
self
):
...
...
lms/djangoapps/course_wiki/tests/test_middleware.py
View file @
17379f40
...
...
@@ -10,11 +10,11 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.factories
import
InstructorFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
course_wiki.views
import
get_or_create_root
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestWikiAccessMiddleware
(
ModuleStoreTestCase
):
"""Tests for WikiAccessMiddleware."""
...
...
lms/djangoapps/course_wiki/tests/tests.py
View file @
17379f40
...
...
@@ -2,13 +2,13 @@ from django.core.urlresolvers import reverse
from
django.test.utils
import
override_settings
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
mock
import
patch
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
WikiRedirectTestCase
(
LoginEnrollmentTestCase
):
"""
Tests for wiki course redirection.
...
...
lms/djangoapps/courseware/management/commands/tests/test_dump_course.py
View file @
17379f40
...
...
@@ -3,33 +3,37 @@
"""Tests for Django management commands"""
import
json
from
path
import
path
import
shutil
from
StringIO
import
StringIO
import
tarfile
from
tempfile
import
mkdtemp
from
path
import
path
from
django.conf
import
settings
from
django.core.management
import
call_command
from
django.test.utils
import
override_settings
from
django.test.testcases
import
TestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_XML_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO_MODULESTORE
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
mixed_store_config
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
django.conf
import
settings
DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
TEST_COURSE_ID
=
'edX/simple/2012_Fall'
XML_COURSE_DIRS
=
[
'toy'
,
'simple'
,
'open_ended'
]
MAPPINGS
=
{
'edX/toy/2012_Fall'
:
'xml'
,
'edX/simple/2012_Fall'
:
'xml'
,
'edX/open_ended/2012_Fall'
:
'xml'
,
}
TEST_DATA_MIXED_XML_MODULESTORE
=
mixed_store_config
(
DATA_DIR
,
MAPPINGS
,
include_xml
=
True
,
xml_course_dirs
=
XML_COURSE_DIRS
)
class
CommandsTestBase
(
TestCase
):
"""
...
...
@@ -58,7 +62,7 @@ class CommandsTestBase(TestCase):
courses
=
store
.
get_courses
()
# NOTE: if xml store owns these, it won't import them into mongo
if
SlashSeparatedCourseKey
.
from_deprecated_string
(
TEST_COURSE_ID
)
not
in
[
c
.
id
for
c
in
courses
]:
import_from_xml
(
store
,
ModuleStoreEnum
.
UserID
.
mgmt_command
,
DATA_DIR
,
[
'toy'
,
'simple'
,
'open_ended'
]
)
import_from_xml
(
store
,
ModuleStoreEnum
.
UserID
.
mgmt_command
,
DATA_DIR
,
XML_COURSE_DIRS
)
return
[
course
.
id
for
course
in
store
.
get_courses
()]
...
...
@@ -194,7 +198,7 @@ class CommandsTestBase(TestCase):
assert_in
(
'edX-simple-2012_Fall/sequential/Lecture_2.xml'
,
names
)
@override_settings
(
MODULESTORE
=
TEST_DATA_XML_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_
MIXED_
XML_MODULESTORE
)
class
CommandsXMLTestCase
(
CommandsTestBase
,
ModuleStoreTestCase
):
"""
Test case for management commands using the xml modulestore.
...
...
@@ -205,14 +209,6 @@ class CommandsXMLTestCase(CommandsTestBase, ModuleStoreTestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
class
CommandsMongoTestCase
(
CommandsTestBase
,
ModuleStoreTestCase
):
"""
Test case for management commands using the mongo modulestore.
"""
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
CommandsMixedTestCase
(
CommandsTestBase
,
ModuleStoreTestCase
):
"""
Test case for management commands. Using the mixed modulestore.
Test case for management commands using the mixed mongo modulestore.
"""
lms/djangoapps/courseware/tests/__init__.py
View file @
17379f40
...
...
@@ -13,7 +13,7 @@ from django.test.client import Client
from
edxmako.shortcuts
import
render_to_string
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MONGO_MODULESTORE
from
xblock.field_data
import
DictFieldData
from
xmodule.tests
import
get_test_system
,
get_test_descriptor_system
from
opaque_keys.edx.locations
import
Location
...
...
lms/djangoapps/courseware/tests/modulestore_config.py
deleted
100644 → 0
View file @
0f3bce02
"""
Define test configuration for modulestores.
"""
from
xmodule.modulestore.tests.django_utils
import
xml_store_config
,
\
mixed_store_config
from
django.conf
import
settings
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
TEST_DATA_XML_MODULESTORE
=
xml_store_config
(
TEST_DATA_DIR
)
# Map all XML course fixtures so they are accessible through
# the MixedModuleStore
MAPPINGS
=
{
'edX/simple/2012_Fall'
:
'xml'
,
'edX/toy/2012_Fall'
:
'xml'
,
'edX/toy/TT_2012_Fall'
:
'xml'
,
'edX/test_end/2012_Fall'
:
'xml'
,
'edX/test_about_blob_end_date/2012_Fall'
:
'xml'
,
'edX/graded/2012_Fall'
:
'xml'
,
'edX/open_ended/2012_Fall'
:
'xml'
,
'edX/due_date/2013_fall'
:
'xml'
,
'edX/open_ended_nopath/2012_Fall'
:
'xml'
,
'edX/detached_pages/2014'
:
'xml'
,
}
TEST_DATA_MIXED_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
MAPPINGS
)
# All store requests now go through mixed
# Some tests require that no XML courses exist. So provide the following constant with no course Mappings.
TEST_DATA_MONGO_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
{})
lms/djangoapps/courseware/tests/test_about.py
View file @
17379f40
"""
Test the about xblock
"""
import
mock
from
mock
import
patch
import
pytz
import
datetime
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
import
pytz
from
.helpers
import
LoginEnrollmentTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCa
se
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO_MODULESTORE
,
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
django.conf
import
settings
from
django.core.urlresolvers
import
rever
se
from
django.test.utils
import
override_settings
from
mock
import
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentAllowedFactory
from
course_modes.models
import
CourseMode
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_CLOSED_MODULESTORE
)
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentAllowedFactory
from
shoppingcart.models
import
Order
,
PaidCourseRegistration
from
xmodule.course_module
import
CATALOG_VISIBILITY_ABOUT
,
CATALOG_VISIBILITY_NONE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
.helpers
import
LoginEnrollmentTestCase
# HTML for registration button
REG_STR
=
"<form id=
\"
class_enroll_form
\"
method=
\"
post
\"
data-remote=
\"
true
\"
action=
\"
/change_enrollment
\"
>"
SHIB_ERROR_STR
=
"The currently logged-in user account does not have permission to enroll in this course."
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AboutTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Tests about xblock.
...
...
@@ -120,8 +121,11 @@ class AboutTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertTrue
(
target_url
.
endswith
(
info_url
))
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
CLOSED_
MODULESTORE
)
class
AboutTestCaseXML
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Tests for the course about page
"""
# The following XML test course (which lives at common/test/data/2014)
# is closed; we're testing that an about page still appears when
# the course is already closed
...
...
@@ -131,7 +135,7 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
# common/test/data/2014/about/overview.html
xml_data
=
"about page 463139"
@
mock.
patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_logged_in_xml
(
self
):
self
.
setup_user
()
url
=
reverse
(
'about_course'
,
args
=
[
self
.
xml_course_id
.
to_deprecated_string
()])
...
...
@@ -139,7 +143,7 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
self
.
xml_data
,
resp
.
content
)
@
mock.
patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_anonymous_user_xml
(
self
):
url
=
reverse
(
'about_course'
,
args
=
[
self
.
xml_course_id
.
to_deprecated_string
()])
resp
=
self
.
client
.
get
(
url
)
...
...
@@ -147,7 +151,7 @@ class AboutTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertIn
(
self
.
xml_data
,
resp
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AboutWithCappedEnrollmentsTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
This test case will check the About page when a course has a capped enrollment
...
...
@@ -197,7 +201,7 @@ class AboutWithCappedEnrollmentsTestCase(LoginEnrollmentTestCase, ModuleStoreTes
self
.
assertNotIn
(
REG_STR
,
resp
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AboutWithInvitationOnly
(
ModuleStoreTestCase
):
"""
This test case will check the About page when a course is invitation only.
...
...
@@ -244,7 +248,7 @@ class AboutWithInvitationOnly(ModuleStoreTestCase):
@patch.dict
(
settings
.
FEATURES
,
{
'RESTRICT_ENROLL_BY_REG_METHOD'
:
True
})
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AboutTestCaseShibCourse
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Test cases covering about page behavior for courses that use shib enrollment domain ("shib courses")
...
...
@@ -283,7 +287,7 @@ class AboutTestCaseShibCourse(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertIn
(
REG_STR
,
resp
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AboutWithClosedEnrollment
(
ModuleStoreTestCase
):
"""
This test case will check the About page for a course that has enrollment start/end
...
...
@@ -319,7 +323,7 @@ class AboutWithClosedEnrollment(ModuleStoreTestCase):
self
.
assertNotIn
(
REG_STR
,
resp
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_SHOPPING_CART'
:
True
})
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_PAID_COURSE_REGISTRATION'
:
True
})
class
AboutPurchaseCourseTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
...
...
lms/djangoapps/courseware/tests/test_access.py
View file @
17379f40
import
courseware.access
as
access
import
datetime
import
mock
from
mock
import
Mock
import
pytz
from
django.test
import
TestCase
from
mock
import
Mock
,
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
import
courseware.access
as
access
from
courseware.tests.factories
import
UserFactory
,
StaffFactory
,
InstructorFactory
from
student.tests.factories
import
AnonymousUserFactory
,
CourseEnrollmentAllowedFactory
import
pytz
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.course_module
import
(
CATALOG_VISIBILITY_CATALOG_AND_ABOUT
,
CATALOG_VISIBILITY_ABOUT
,
CATALOG_VISIBILITY_NONE
)
CATALOG_VISIBILITY_NONE
)
# pylint: disable=missing-docstring
# pylint: disable=protected-access
...
...
@@ -115,7 +113,7 @@ class AccessTestCase(TestCase):
with
self
.
assertRaises
(
ValueError
):
access
.
_has_access_descriptor
(
user
,
'not_load_or_staff'
,
descriptor
)
@
mock.
patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test__has_access_descriptor_staff_lock
(
self
):
"""
Tests that "visible_to_staff_only" overrides start date.
...
...
lms/djangoapps/courseware/tests/test_course_info.py
View file @
17379f40
"""
Test the course_info xblock
"""
import
mock
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
import
mock
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
.helpers
import
LoginEnrollmentTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_CLOSED_MODULESTORE
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
.helpers
import
LoginEnrollmentTestCase
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
CourseInfoTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Tests for the Course Info page
"""
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
self
.
page
=
ItemFactory
.
create
(
...
...
@@ -41,12 +48,15 @@ class CourseInfoTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertNotIn
(
"OOGIE BLOOGIE"
,
resp
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
CLOSED_
MODULESTORE
)
class
CourseInfoTestCaseXML
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Tests for the Course Info page for an XML course
"""
# The following XML test course (which lives at common/test/data/2014)
# is closed; we're testing that a course info page still appears when
# the course is already closed
xml_course_
id
=
'edX/detached_pages/2014'
xml_course_
key
=
SlashSeparatedCourseKey
(
'edX'
,
'detached_pages'
,
'2014'
)
# this text appears in that course's course info page
# common/test/data/2014/info/updates.html
...
...
@@ -55,14 +65,14 @@ class CourseInfoTestCaseXML(LoginEnrollmentTestCase, ModuleStoreTestCase):
@mock.patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_logged_in_xml
(
self
):
self
.
setup_user
()
url
=
reverse
(
'info'
,
args
=
[
self
.
xml_course_
id
])
url
=
reverse
(
'info'
,
args
=
[
self
.
xml_course_
key
.
to_deprecated_string
()
])
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertIn
(
self
.
xml_data
,
resp
.
content
)
@mock.patch.dict
(
'django.conf.settings.FEATURES'
,
{
'DISABLE_START_DATES'
:
False
})
def
test_anonymous_user_xml
(
self
):
url
=
reverse
(
'info'
,
args
=
[
self
.
xml_course_
id
])
url
=
reverse
(
'info'
,
args
=
[
self
.
xml_course_
key
.
to_deprecated_string
()
])
resp
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
resp
.
status_code
,
200
)
self
.
assertNotIn
(
self
.
xml_data
,
resp
.
content
)
lms/djangoapps/courseware/tests/test_courses.py
View file @
17379f40
...
...
@@ -2,34 +2,38 @@
"""
Tests for course access
"""
from
django.conf
import
settings
from
django.test.utils
import
override_settings
import
mock
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
django.test.utils
import
override_settings
from
courseware.courses
import
(
get_course_by_id
,
get_cms_course_link
,
course_image_url
,
get_course_info_section
,
get_course_about_section
,
get_cms_block_link
)
from
courseware.tests.helpers
import
get_request_for_user
from
student.tests.factories
import
UserFactory
import
xmodule.modulestore.django
as
store_django
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.tests.xml
import
factories
as
xml
from
xmodule.tests.xml
import
XModuleXmlImportTest
from
courseware.courses
import
(
get_course_by_id
,
get_cms_course_link
,
course_image_url
,
get_course_info_section
,
get_course_about_section
,
get_cms_block_link
)
from
courseware.tests.helpers
import
get_request_for_user
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
,
TEST_DATA_MIXED_MODULESTORE
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
CMS_BASE_TEST
=
'testcms'
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
class
CoursesTest
(
ModuleStoreTestCase
):
"""Test methods related to fetching courses."""
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
,
CMS_BASE
=
CMS_BASE_TEST
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
,
CMS_BASE
=
CMS_BASE_TEST
)
def
test_get_cms_course_block_link
(
self
):
"""
...
...
@@ -71,7 +75,7 @@ class ModuleStoreBranchSettingTest(ModuleStoreTestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
,
CMS_BASE
=
CMS_BASE_TEST
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
,
CMS_BASE
=
CMS_BASE_TEST
)
class
MongoCourseImageTestCase
(
ModuleStoreTestCase
):
"""Tests for course image URLs when using a mongo modulestore."""
...
...
@@ -144,35 +148,43 @@ class XmlCourseImageTestCase(XModuleXmlImportTest):
self
.
assertEquals
(
course_image_url
(
course
),
u'/static/xml_test_course/before after.jpg'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
CoursesRenderTest
(
ModuleStoreTestCase
):
"""Test methods related to rendering courses content."""
toy_course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
def
test_get_course_info_section_render
(
self
):
course
=
get_course_by_id
(
self
.
toy_course_key
)
request
=
get_request_for_user
(
UserFactory
.
create
())
# TODO: this test relies on the specific setup of the toy course.
# It should be rewritten to build the course it needs and then test that.
def
setUp
(
self
):
"""
Set up the course and user context
"""
super
(
CoursesRenderTest
,
self
)
.
setUp
()
store
=
store_django
.
modulestore
()
course_items
=
import_from_xml
(
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'toy'
])
course_key
=
course_items
[
0
]
.
id
self
.
course
=
get_course_by_id
(
course_key
)
self
.
request
=
get_request_for_user
(
UserFactory
.
create
())
def
test_get_course_info_section_render
(
self
):
# Test render works okay
course_info
=
get_course_info_section
(
request
,
course
,
'handouts'
)
self
.
assertEqual
(
course_info
,
"<a href='/static/toy/handouts/
sample_handout.txt'>Sample</a>"
)
course_info
=
get_course_info_section
(
self
.
request
,
self
.
course
,
'handouts'
)
self
.
assertEqual
(
course_info
,
u"<a href='/c4x/edX/toy/asset/handouts_
sample_handout.txt'>Sample</a>"
)
# Test when render raises an exception
with
mock
.
patch
(
'courseware.courses.get_module'
)
as
mock_module_render
:
mock_module_render
.
return_value
=
mock
.
MagicMock
(
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
)
course_info
=
get_course_info_section
(
request
,
course
,
'handouts'
)
course_info
=
get_course_info_section
(
self
.
request
,
self
.
course
,
'handouts'
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_info
)
@mock.patch
(
'courseware.courses.get_request_for_thread'
)
def
test_get_course_about_section_render
(
self
,
mock_get_request
):
course
=
get_course_by_id
(
self
.
toy_course_key
)
request
=
get_request_for_user
(
UserFactory
.
create
())
mock_get_request
.
return_value
=
request
mock_get_request
.
return_value
=
self
.
request
# Test render works okay
course_about
=
get_course_about_section
(
course
,
'short_description'
)
course_about
=
get_course_about_section
(
self
.
course
,
'short_description'
)
self
.
assertEqual
(
course_about
,
"A course about toys."
)
# Test when render raises an exception
...
...
@@ -180,5 +192,27 @@ class CoursesRenderTest(ModuleStoreTestCase):
mock_module_render
.
return_value
=
mock
.
MagicMock
(
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
)
course_about
=
get_course_about_section
(
course
,
'short_description'
)
course_about
=
get_course_about_section
(
self
.
course
,
'short_description'
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_about
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
)
class
XmlCoursesRenderTest
(
ModuleStoreTestCase
):
"""Test methods related to rendering courses content for an XML course."""
toy_course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
def
test_get_course_info_section_render
(
self
):
course
=
get_course_by_id
(
self
.
toy_course_key
)
request
=
get_request_for_user
(
UserFactory
.
create
())
# Test render works okay. Note the href is different in XML courses.
course_info
=
get_course_info_section
(
request
,
course
,
'handouts'
)
self
.
assertEqual
(
course_info
,
"<a href='/static/toy/handouts/sample_handout.txt'>Sample</a>"
)
# Test when render raises an exception
with
mock
.
patch
(
'courseware.courses.get_module'
)
as
mock_module_render
:
mock_module_render
.
return_value
=
mock
.
MagicMock
(
render
=
mock
.
Mock
(
side_effect
=
Exception
(
'Render failed!'
))
)
course_info
=
get_course_info_section
(
request
,
course
,
'handouts'
)
self
.
assertIn
(
"this module is temporarily unavailable"
,
course_info
)
lms/djangoapps/courseware/tests/test_draft_modulestore.py
View file @
17379f40
...
...
@@ -4,11 +4,14 @@ from django.test.utils import override_settings
from
xmodule.modulestore.django
import
modulestore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestDraftModuleStore
(
TestCase
):
"""
Test the draft modulestore
"""
def
test_get_items_with_course_items
(
self
):
store
=
modulestore
()
...
...
lms/djangoapps/courseware/tests/test_grades.py
View file @
17379f40
...
...
@@ -4,14 +4,13 @@ Test grade calculation.
from
django.http
import
Http404
from
django.test.utils
import
override_settings
from
mock
import
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
courseware.grades
import
grade
,
iterate_grades_for
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.grades
import
grade
,
iterate_grades_for
def
_grade_with_errors
(
student
,
request
,
course
,
keep_raw_scores
=
False
):
...
...
@@ -28,7 +27,7 @@ def _grade_with_errors(student, request, course, keep_raw_scores=False):
return
grade
(
student
,
request
,
course
,
keep_raw_scores
=
keep_raw_scores
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestGradeIteration
(
ModuleStoreTestCase
):
"""
Test iteration through student gradesets.
...
...
lms/djangoapps/courseware/tests/test_i18n.py
View file @
17379f40
"""
Tests i18n in courseware
"""
import
re
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
import
re
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
,
LANGUAGES
=
((
'eo'
,
'Esperanto'
),))
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
,
LANGUAGES
=
((
'eo'
,
'Esperanto'
),))
class
I18nTestCase
(
TestCase
):
"""
Tests for i18n
...
...
lms/djangoapps/courseware/tests/test_lti_integration.py
View file @
17379f40
"""LTI integration tests"""
import
oauthlib
from
collections
import
OrderedDict
import
json
import
mock
import
oauthlib
import
urllib
import
json
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.x_module
import
STUDENT_VIEW
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
courseware.tests
import
BaseTestXmodule
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
courseware.views
import
get_course_lti_endpoints
from
lms.lib.xblock.runtime
import
quote_slashes
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.x_module
import
STUDENT_VIEW
class
TestLTI
(
BaseTestXmodule
):
...
...
@@ -126,7 +123,7 @@ class TestLTI(BaseTestXmodule):
self
.
assertEqual
(
generated_content
,
expected_content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestLTIModuleListing
(
ModuleStoreTestCase
):
"""
a test for the rest endpoint that lists LTI modules in a course
...
...
lms/djangoapps/courseware/tests/test_masquerade.py
View file @
17379f40
...
...
@@ -7,32 +7,33 @@ Notes for running by hand:
./manage.py lms --settings test test lms/djangoapps/courseware
"""
import
json
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.tests.factories
import
StaffFactory
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
lms.lib.xblock.runtime
import
quote_slashes
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.django
import
modulestore
,
clear_existing_modulestores
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_GRADED_MODULESTORE
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
# TODO: the "abtest" node in the sample course "graded" is currently preventing
# it from being successfully loaded in the mongo modulestore.
# Fix this testcase class to not depend on that course, and let it use
# the mocked modulestore instead of the XML.
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_GRADED_MODULESTORE
)
class
TestStaffMasqueradeAsStudent
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Check for staff being able to masquerade as student.
"""
def
setUp
(
self
):
# Clear out the modulestores, causing them to reload
clear_existing_modulestores
()
self
.
graded_course
=
modulestore
()
.
get_course
(
SlashSeparatedCourseKey
(
"edX"
,
"graded"
,
"2012_Fall"
))
# Create staff account
...
...
lms/djangoapps/courseware/tests/test_microsites.py
View file @
17379f40
"""
Tests related to the Microsites feature
"""
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
course_modes.models
import
CourseMode
from
xmodule.course_module
import
(
CATALOG_VISIBILITY_CATALOG_AND_ABOUT
,
CATALOG_VISIBILITY_NONE
)
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestMicrosites
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
This is testing of the Microsite feature
...
...
lms/djangoapps/courseware/tests/test_middleware.py
View file @
17379f40
...
...
@@ -8,14 +8,14 @@ from django.test.client import RequestFactory
from
django.http
import
Http404
from
mock
import
patch
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
import
courseware.courses
as
courses
from
courseware.middleware
import
RedirectUnenrolledMiddleware
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
CoursewareMiddlewareTestCase
(
ModuleStoreTestCase
):
"""Tests that courseware middleware is correctly redirected"""
...
...
lms/djangoapps/courseware/tests/test_module_render.py
View file @
17379f40
"""
Test for lms courseware app, module render unit
"""
import
ddt
from
functools
import
partial
from
mock
import
MagicMock
,
patch
,
Mock
import
json
import
ddt
from
django.http
import
Http404
,
HttpResponse
from
django.core.urlresolvers
import
reverse
from
django.conf
import
settings
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
django.contrib.auth.models
import
AnonymousUser
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactor
y
from
mock
import
MagicMock
,
patch
,
Mock
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKe
y
from
xblock.field_data
import
FieldData
from
xblock.runtime
import
Runtime
from
xblock.fields
import
ScopeIds
from
xblock.core
import
XBlock
from
xmodule.lti_module
import
LTIDescriptor
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
,
check_mongo_calls
from
xmodule.x_module
import
XModuleDescriptor
,
STUDENT_VIEW
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactory
from
courseware
import
module_render
as
render
from
courseware.courses
import
get_course_with_access
,
course_image_url
,
get_course_info_section
from
courseware.model_data
import
FieldDataCache
from
courseware.models
import
StudentModule
from
courseware.tests.factories
import
StudentModuleFactory
,
UserFactory
,
GlobalStaffFactory
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_XML_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
,
TEST_DATA_XML
_MODULESTORE
)
from
courseware.tests.test_submitting_problems
import
TestSubmittingProblems
from
student.models
import
anonymous_id_for_user
from
lms.lib.xblock.runtime
import
quote_slashes
from
student.models
import
anonymous_id_for_user
from
xmodule.lti_module
import
LTIDescriptor
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
,
check_mongo_calls
from
xmodule.x_module
import
XModuleDescriptor
,
STUDENT_VIEW
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
class
PureXBlock
(
XBlock
):
...
...
@@ -50,14 +50,20 @@ class PureXBlock(XBlock):
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
ModuleRenderTestCase
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Tests of courseware.module_render
"""
# TODO: this test relies on the specific setup of the toy course.
# It should be rewritten to build the course it needs and then test that.
def
setUp
(
self
):
self
.
course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
self
.
location
=
self
.
course_key
.
make_usage_key
(
'chapter'
,
'Overview'
)
"""
Set up the course and user context
"""
super
(
ModuleRenderTestCase
,
self
)
.
setUp
()
self
.
course_key
=
self
.
create_toy_course
()
self
.
toy_course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
mock_user
=
UserFactory
()
self
.
mock_user
.
id
=
1
...
...
@@ -182,14 +188,16 @@ class ModuleRenderTestCase(ModuleStoreTestCase, LoginEnrollmentTestCase):
render
.
get_module_for_descriptor
(
self
.
mock_user
,
request
,
descriptor
,
field_data_cache
,
self
.
toy_course
.
id
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestHandleXBlockCallback
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test the handle_xblock_callback function
"""
def
setUp
(
self
):
self
.
course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
)
super
(
TestHandleXBlockCallback
,
self
)
.
setUp
()
self
.
course_key
=
self
.
create_toy_course
()
self
.
location
=
self
.
course_key
.
make_usage_key
(
'chapter'
,
'Overview'
)
self
.
toy_course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
mock_user
=
UserFactory
()
...
...
@@ -335,7 +343,7 @@ class TestHandleXBlockCallback(ModuleStoreTestCase, LoginEnrollmentTestCase):
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestTOC
(
ModuleStoreTestCase
):
"""Check the Table of Contents for a course"""
def
setup_modulestore
(
self
,
default_ms
,
num_finds
,
num_sends
):
...
...
@@ -429,7 +437,7 @@ class TestTOC(ModuleStoreTestCase):
self
.
assertIn
(
toc_section
,
actual
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestHtmlModifiers
(
ModuleStoreTestCase
):
"""
Tests to verify that standard modifications to the output of XModule/XBlock
...
...
@@ -623,7 +631,7 @@ class ViewInStudioTest(ModuleStoreTestCase):
self
.
module
=
self
.
_get_module
(
course_key
,
descriptor
,
location
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
MongoViewInStudioTest
(
ViewInStudioTest
):
"""Test the 'View in Studio' link visibility in a mongo backed course."""
...
...
@@ -655,7 +663,7 @@ class MongoViewInStudioTest(ViewInStudioTest):
self
.
assertNotIn
(
'View Unit in Studio'
,
result_fragment
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
class
MixedViewInStudioTest
(
ViewInStudioTest
):
"""Test the 'View in Studio' link visibility in a mixed mongo backed course."""
...
...
@@ -695,7 +703,7 @@ class XmlViewInStudioTest(ViewInStudioTest):
self
.
assertNotIn
(
'View Unit in Studio'
,
result_fragment
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
@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
))
class
TestStaffDebugInfo
(
ModuleStoreTestCase
):
...
...
@@ -816,7 +824,7 @@ PER_STUDENT_ANONYMIZED_DESCRIPTORS = set(
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestAnonymousStudentId
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test that anonymous_student_id is set correctly across a variety of XBlock types
...
...
@@ -883,7 +891,7 @@ class TestAnonymousStudentId(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
@patch
(
'track.views.tracker'
)
class
TestModuleTrackingContext
(
ModuleStoreTestCase
):
"""
...
...
lms/djangoapps/courseware/tests/test_navigation.py
View file @
17379f40
...
...
@@ -2,21 +2,19 @@
This test file will run through some LMS test scenarios regarding access and navigation of the LMS
"""
import
time
from
django.conf
import
settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
courseware.tests.factories
import
GlobalStaffFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestNavigation
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Check that navigation state is saved properly.
...
...
lms/djangoapps/courseware/tests/test_split_module.py
View file @
17379f40
...
...
@@ -5,18 +5,17 @@ from django.core.urlresolvers import reverse
from
django.test.utils
import
override_settings
from
mock
import
MagicMock
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
courseware.module_render
import
get_module_for_descriptor
from
courseware.model_data
import
FieldDataCache
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.factories
import
ItemFactory
,
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
user_api.tests.factories
import
UserCourseTagFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
SplitTestBase
(
ModuleStoreTestCase
):
"""
Sets up a basic course and user for split test testing.
...
...
@@ -271,7 +270,7 @@ class TestSplitTestVert(SplitTestBase):
html1
=
self
.
_html
(
cond1vert
,
1
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
SplitTestPosition
(
ModuleStoreTestCase
):
"""
Check that we can change positions in a course with partitions defined
...
...
lms/djangoapps/courseware/tests/test_submitting_problems.py
View file @
17379f40
...
...
@@ -2,41 +2,35 @@
"""
Integration tests for submitting problem responses and getting grades.
"""
# text processing dependencies
import
json
import
os
from
textwrap
import
dedent
from
mock
import
patch
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.test.client
import
RequestFactory
from
django.core.urlresolvers
import
reverse
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
mock
import
patch
# Need access to internal func to put users in the right group
from
courseware
import
grades
from
courseware.models
import
StudentModule
#import factories and parent testcase modules
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
capa.tests.response_xml_factory
import
(
OptionResponseXMLFactory
,
CustomResponseXMLFactory
,
SchematicResponseXMLFactory
,
CodeResponseXMLFactory
,
)
from
courseware
import
grades
from
courseware.models
import
StudentModule
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
lms.lib.xblock.runtime
import
quote_slashes
from
student.tests.factories
import
UserFactory
from
student.models
import
anonymous_id_for_user
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.partitions.partitions
import
Group
,
UserPartition
from
user_api.tests.factories
import
UserCourseTagFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestSubmittingProblems
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Check that a course gets graded properly.
...
...
@@ -651,6 +645,7 @@ class ProblemWithUploadedFilesTest(TestSubmittingProblems):
self
.
assertItemsEqual
(
kwargs
[
'files'
]
.
keys
(),
filenames
.
split
())
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
class
TestPythonGradedResponse
(
TestSubmittingProblems
):
"""
Check that we can submit a schematic and custom response, and it answers properly.
...
...
lms/djangoapps/courseware/tests/test_tabs.py
View file @
17379f40
"""
Test cases for tabs.
"""
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
from
django.test.utils
import
override_settings
from
mock
import
MagicMock
,
Mock
,
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.courses
import
get_course_by_id
from
courseware.tests.helpers
import
get_request_for_user
,
LoginEnrollmentTestCase
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MIXED_TOY_MODULESTORE
,
TEST_DATA_MIXED_CLOSED_MODULESTORE
)
from
courseware.views
import
get_static_tab_contents
,
static_tab
from
django.http
import
Http404
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
student.tests.factories
import
UserFactory
from
xmodule.tabs
import
CourseTabList
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
courseware.tests.helpers
import
get_request_for_user
,
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
class
StaticTabDateTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""Test cases for Static Tab Dates."""
...
...
@@ -49,7 +49,6 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
with
self
.
assertRaises
(
Http404
):
static_tab
(
request
,
course_id
=
'edX/toy'
,
tab_slug
=
'new_tab'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
def
test_get_static_tab_contents
(
self
):
course
=
get_course_by_id
(
self
.
toy_course_key
)
request
=
get_request_for_user
(
UserFactory
.
create
())
...
...
@@ -69,8 +68,11 @@ class StaticTabDateTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase):
self
.
assertIn
(
"this module is temporarily unavailable"
,
static_tab
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
CLOSED_
MODULESTORE
)
class
StaticTabDateTestCaseXML
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Tests for the static tab dates of an XML course
"""
# The following XML test course (which lives at common/test/data/2014)
# is closed; we're testing that tabs still appear when
# the course is already closed
...
...
lms/djangoapps/courseware/tests/test_view_authentication.py
View file @
17379f40
import
datetime
import
pytz
from
mock
import
patch
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
mock
import
patch
# Need access to internal func to put users in the right group
from
courseware.access
import
has_access
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
courseware.tests.factories
import
(
BetaTesterFactory
,
StaffFactory
,
...
...
@@ -26,9 +17,12 @@ from courseware.tests.factories import (
OrgInstructorFactory
,
)
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestViewAuth
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Check that view authentication works properly.
...
...
@@ -395,9 +389,11 @@ class TestViewAuth(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertTrue
(
self
.
enroll
(
self
.
course
))
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestBetatesterAccess
(
ModuleStoreTestCase
):
"""
Tests for the beta tester feature
"""
def
setUp
(
self
):
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
...
...
lms/djangoapps/courseware/tests/test_views.py
View file @
17379f40
...
...
@@ -2,44 +2,39 @@
"""
Tests courseware views.py
"""
import
unittest
import
cgi
from
datetime
import
datetime
from
mock
import
MagicMock
,
patch
,
create_autospec
from
pytz
import
UTC
from
django.test
import
TestCase
from
django.http
import
Http404
from
django.test.utils
import
override_settings
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.test.client
import
RequestFactory
import
unittest
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
,
AnonymousUser
from
django.core.urlresolvers
import
reverse
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
AdminFactory
from
django.http
import
Http404
from
django.test
import
TestCase
from
django.test.client
import
RequestFactory
from
django.test.utils
import
override_settings
from
edxmako.middleware
import
MakoMiddleware
from
edxmako.tests
import
mako_middleware_process_request
from
opaque_keys.edx.locations
import
Location
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.tests.factories
import
UserFactory
from
mock
import
MagicMock
,
patch
,
create_autospec
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
import
courseware.views
as
views
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
)
from
course_modes.models
import
CourseMode
import
shoppingcart
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
AdminFactory
,
UserFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
util.tests.test_date_utils
import
fake_ugettext
,
fake_pgettext
from
util.views
import
ensure_valid_course_key
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
class
TestJumpTo
(
TestCase
):
"""
Check the jumpto link for a course.
...
...
@@ -57,6 +52,7 @@ class TestJumpTo(TestCase):
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@unittest.skip
def
test_jumpto_from_chapter
(
self
):
location
=
self
.
course_key
.
make_usage_key
(
'chapter'
,
'Overview'
)
jumpto_url
=
'{0}/{1}/jump_to/{2}'
.
format
(
'/courses'
,
self
.
course_key
.
to_deprecated_string
(),
location
.
to_deprecated_string
())
...
...
@@ -64,6 +60,7 @@ class TestJumpTo(TestCase):
response
=
self
.
client
.
get
(
jumpto_url
)
self
.
assertRedirects
(
response
,
expected
,
status_code
=
302
,
target_status_code
=
302
)
@unittest.skip
def
test_jumpto_id
(
self
):
jumpto_url
=
'{0}/{1}/jump_to_id/{2}'
.
format
(
'/courses'
,
self
.
course_key
.
to_deprecated_string
(),
'Overview'
)
expected
=
'courses/edX/toy/2012_Fall/courseware/Overview/'
...
...
@@ -77,7 +74,7 @@ class TestJumpTo(TestCase):
self
.
assertEqual
(
response
.
status_code
,
404
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
ViewsTestCase
(
TestCase
):
"""
Tests for views.py methods.
...
...
@@ -173,6 +170,7 @@ class ViewsTestCase(TestCase):
response
=
self
.
client
.
get
(
request_url
)
self
.
assertEqual
(
response
.
status_code
,
404
)
@unittest.skip
def
test_unicode_handling_in_url
(
self
):
url_parts
=
[
'/courses'
,
...
...
@@ -205,14 +203,17 @@ class ViewsTestCase(TestCase):
self
.
assertRaisesRegexp
(
Http404
,
'Invalid course_key or usage_key'
,
views
.
jump_to
,
request
,
'bar'
,
())
@unittest.skip
def
test_no_end_on_about_page
(
self
):
# Toy course has no course end date or about/end_date blob
self
.
verify_end_date
(
'edX/toy/TT_2012_Fall'
)
@unittest.skip
def
test_no_end_about_blob
(
self
):
# test_end has a course end date, no end_date HTML blob
self
.
verify_end_date
(
"edX/test_end/2012_Fall"
,
"Sep 17, 2015"
)
@unittest.skip
def
test_about_blob_end_date
(
self
):
# test_about_blob_end_date has both a course end date and an end_date HTML blob.
# HTML blob wins
...
...
@@ -424,7 +425,7 @@ class ViewsTestCase(TestCase):
# setting TIME_ZONE_DISPLAYED_FOR_DEADLINES explicitly
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
,
TIME_ZONE_DISPLAYED_FOR_DEADLINES
=
"UTC"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
,
TIME_ZONE_DISPLAYED_FOR_DEADLINES
=
"UTC"
)
class
BaseDueDateTests
(
ModuleStoreTestCase
):
"""
Base class that verifies that due dates are rendered correctly on a page
...
...
@@ -538,7 +539,7 @@ class TestAccordionDueDate(BaseDueDateTests):
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
StartDateTests
(
ModuleStoreTestCase
):
"""
Test that start dates are properly localized and displayed on the student
...
...
@@ -586,13 +587,14 @@ class StartDateTests(ModuleStoreTestCase):
@patch
(
'util.date_utils.ugettext'
,
fake_ugettext
(
translations
=
{
"SHORT_DATE_FORMAT"
:
"
%
Y-
%
b-
%
d"
,
}))
@unittest.skip
def
test_format_localized_in_xml_course
(
self
):
text
=
self
.
get_about_text
(
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'TT_2012_Fall'
))
# The start date is set in common/test/data/two_toys/policies/TT_2012_Fall/policy.json
self
.
assertIn
(
"2015-JULY-17"
,
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
ProgressPageTests
(
ModuleStoreTestCase
):
"""
Tests that verify that the progress page works correctly.
...
...
lms/djangoapps/courseware/tests/tests.py
View file @
17379f40
"""
Test for LMS courseware app.
"""
import
mock
from
mock
import
Mock
from
textwrap
import
dedent
from
unittest
import
TestCase
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
textwrap
import
dedent
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.modulestore.django
import
modulestore
import
mock
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_DIR
,
\
TEST_DATA_MONGO_MODULESTORE
,
\
TEST_DATA_MIXED_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_XML_MODULESTORE
as
XML_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_TOY_MODULESTORE
as
TOY_MODULESTORE
from
lms.lib.xblock.field_data
import
LmsFieldData
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
class
ActivateLoginTest
(
LoginEnrollmentTestCase
):
...
...
@@ -116,7 +112,7 @@ class PageLoaderTestCase(LoginEnrollmentTestCase):
self
.
assertNotIsInstance
(
descriptor
,
ErrorDescriptor
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
XML
_MODULESTORE
)
class
TestXmlCoursesLoad
(
ModuleStoreTestCase
,
PageLoaderTestCase
):
"""
Check that all pages in test courses load properly from XML.
...
...
@@ -133,6 +129,7 @@ class TestXmlCoursesLoad(ModuleStoreTestCase, PageLoaderTestCase):
self
.
check_all_pages_load
(
SlashSeparatedCourseKey
(
'edX'
,
'toy'
,
'2012_Fall'
))
@override_settings
(
MODULESTORE
=
TOY_MODULESTORE
)
class
TestMongoCoursesLoad
(
ModuleStoreTestCase
,
PageLoaderTestCase
):
"""
Check that all pages in test courses load properly from Mongo.
...
...
@@ -142,9 +139,6 @@ class TestMongoCoursesLoad(ModuleStoreTestCase, PageLoaderTestCase):
super
(
TestMongoCoursesLoad
,
self
)
.
setUp
()
self
.
setup_user
()
# Import the toy course
import_from_xml
(
self
.
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'toy'
])
@mock.patch
(
'xmodule.course_module.requests.get'
)
def
test_toy_textbooks_loads
(
self
,
mock_get
):
mock_get
.
return_value
.
text
=
dedent
(
"""
...
...
@@ -183,8 +177,8 @@ class TestLmsFieldData(TestCase):
# reached on any attribute access
# pylint: disable=protected-access
base_authored
=
Mock
()
base_student
=
Mock
()
base_authored
=
mock
.
Mock
()
base_student
=
mock
.
Mock
()
first_level
=
LmsFieldData
(
base_authored
,
base_student
)
second_level
=
LmsFieldData
(
first_level
,
base_student
)
self
.
assertEquals
(
second_level
.
_authored_data
,
first_level
.
_authored_data
)
...
...
lms/djangoapps/dashboard/management/commands/tests/test_git_add_course.py
View file @
17379f40
...
...
@@ -12,14 +12,14 @@ from django.conf import settings
from
django.core.management
import
call_command
from
django.core.management.base
import
CommandError
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
import
dashboard.git_import
as
git_import
from
dashboard.git_import
import
GitImportError
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
import
dashboard.git_import
as
git_import
from
dashboard.git_import
import
GitImportError
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
...
...
@@ -35,7 +35,7 @@ FEATURES_WITH_SSL_AUTH = settings.FEATURES.copy()
FEATURES_WITH_SSL_AUTH
[
'AUTH_USE_CERTIFICATES'
]
=
True
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@override_settings
(
MONGODB_LOG
=
TEST_MONGODB_LOG
)
@unittest.skipUnless
(
settings
.
FEATURES
.
get
(
'ENABLE_SYSADMIN_DASHBOARD'
),
"ENABLE_SYSADMIN_DASHBOARD not set"
)
...
...
lms/djangoapps/dashboard/tests/test_support.py
View file @
17379f40
"""
Tests for support dashboard
"""
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
import
datetime
from
django.contrib.auth.models
import
Permission
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
django.contrib.auth.models
import
Permission
from
shoppingcart.models
import
CertificateItem
,
Order
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
student.models
import
CourseEnrollment
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
course_modes.models
import
CourseMode
from
shoppingcart.models
import
CertificateItem
,
Order
from
student.models
import
CourseEnrollment
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
import
datetim
e
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCas
e
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
class
RefundTests
(
ModuleStoreTestCase
):
"""
Tests for the manual refund page
...
...
lms/djangoapps/dashboard/tests/test_sysadmin.py
View file @
17379f40
...
...
@@ -6,6 +6,7 @@ import os
import
re
import
shutil
import
unittest
from
util.date_utils
import
get_time_display
,
DEFAULT_DATE_TIME_FORMAT
from
django.conf
import
settings
from
django.contrib.auth.hashers
import
check_password
...
...
@@ -13,26 +14,24 @@ from django.contrib.auth.models import User
from
django.core.urlresolvers
import
reverse
from
django.test.client
import
Client
from
django.test.utils
import
override_settings
from
django.utils.timezone
import
utc
as
UTC
from
django.utils.translation
import
ugettext
as
_
import
mongoengine
from
django.utils.timezone
import
utc
as
UTC
from
util.date_utils
import
get_time_display
,
DEFAULT_DATE_TIME_FORMAT
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.roles
import
CourseStaffRole
,
GlobalStaff
from
courseware.tests.modulestore_config
import
TEST_DATA_DIR
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_XML_MODULESTORE
)
from
dashboard.models
import
CourseImportLog
from
dashboard.sysadmin
import
Users
from
dashboard.git_import
import
GitImportError
from
external_auth.models
import
ExternalAuthMap
from
student.roles
import
CourseStaffRole
,
GlobalStaff
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.xml
import
XMLModuleStore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.mongo_connection
import
MONGO_PORT_NUM
,
MONGO_HOST
from
xmodule.modulestore.tests.django_utils
import
xml_store_config
TEST_DATA_XML_MODULESTORE
=
xml_store_config
(
TEST_DATA_DIR
,
[
'empty'
])
from
xmodule.modulestore.xml
import
XMLModuleStore
TEST_MONGODB_LOG
=
{
...
...
@@ -406,6 +405,7 @@ class TestSysadmin(SysadminBaseTestCase):
@override_settings
(
MONGODB_LOG
=
TEST_MONGODB_LOG
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
@unittest.skipUnless
(
settings
.
FEATURES
.
get
(
'ENABLE_SYSADMIN_DASHBOARD'
),
"ENABLE_SYSADMIN_DASHBOARD not set"
)
class
TestSysAdminMongoCourseImport
(
SysadminBaseTestCase
):
...
...
lms/djangoapps/django_comment_client/base/tests.py
View file @
17379f40
...
...
@@ -10,7 +10,7 @@ from mock import patch, ANY, Mock
from
nose.tools
import
assert_true
,
assert_equal
# pylint: disable=no-name-in-module
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
django_comment_client.base
import
views
from
django_comment_client.tests.group_id
import
CohortedTopicGroupIdTestMixin
,
NonCohortedTopicGroupIdTestMixin
,
GroupIdAssertionMixin
from
django_comment_client.tests.utils
import
CohortedContentTestCase
...
...
@@ -162,7 +162,7 @@ class ThreadActionGroupIdTestCase(
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch
(
'lms.lib.comment_client.utils.requests.request'
)
class
ViewsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
):
...
...
@@ -750,7 +750,7 @@ class ViewsTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSetupMixin):
@patch
(
"lms.lib.comment_client.utils.requests.request"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
ViewPermissionsTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
,
MockRequestSetupMixin
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
def
setUp
(
self
):
...
...
@@ -844,7 +844,7 @@ class ViewPermissionsTestCase(UrlResetMixin, ModuleStoreTestCase, MockRequestSet
self
.
assertEqual
(
response
.
status_code
,
200
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CreateThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -866,7 +866,7 @@ class CreateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
self
.
assertEqual
(
mock_request
.
call_args
[
1
][
"data"
][
"title"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
UpdateThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -894,7 +894,7 @@ class UpdateThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockReq
self
.
assertEqual
(
mock_request
.
call_args
[
1
][
"data"
][
"commentable_id"
],
"test_commentable"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CreateCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -917,7 +917,7 @@ class CreateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
self
.
assertEqual
(
mock_request
.
call_args
[
1
][
"data"
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
UpdateCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -941,7 +941,7 @@ class UpdateCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, MockRe
self
.
assertEqual
(
mock_request
.
call_args
[
1
][
"data"
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CreateSubCommentUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
,
MockRequestSetupMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -965,7 +965,7 @@ class CreateSubCommentUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin, Moc
self
.
assertEqual
(
mock_request
.
call_args
[
1
][
"data"
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
UsersEndpointTestCase
(
ModuleStoreTestCase
,
MockRequestSetupMixin
):
def
set_post_counts
(
self
,
mock_request
,
threads_count
=
1
,
comments_count
=
1
):
...
...
lms/djangoapps/django_comment_client/forum/tests.py
View file @
17379f40
import
json
import
logging
from
django.core.urlresolvers
import
reverse
from
django.http
import
Http404
from
django.test.utils
import
override_settings
from
django.test.client
import
Client
,
RequestFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
django.test.utils
import
override_settings
from
edxmako.tests
import
mako_middleware_process_request
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
,
mixed_store_config
from
django.core.urlresolvers
import
reverse
from
util.testing
import
UrlResetMixin
from
mock
import
patch
,
Mock
,
ANY
,
call
from
nose.tools
import
assert_true
# pylint: disable=no-name-in-module
from
course_groups.models
import
CourseUserGroup
from
courseware.courses
import
UserNotEnrolled
from
django_comment_client.forum
import
views
from
django_comment_client.tests.group_id
import
(
CohortedTopicGroupIdTestMixin
,
NonCohortedTopicGroupIdTestMixin
)
from
django_comment_client.tests.unicode
import
UnicodeTestMixin
from
django_comment_client.tests.utils
import
CohortedContentTestCase
from
django_comment_client.forum
import
views
from
django_comment_client.utils
import
strip_none
from
courseware.tests.modulestore_config
import
TEST_DATA_DIR
from
courseware.courses
import
UserNotEnrolled
from
nose.tools
import
assert_true
# pylint: disable=no-name-in-module
from
mock
import
patch
,
Mock
,
ANY
,
call
from
course_groups.models
import
CourseUserGroup
TEST_DATA_MONGO_MODULESTORE
=
mixed_store_config
(
TEST_DATA_DIR
,
{},
include_xml
=
False
)
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
util.testing
import
UrlResetMixin
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
log
=
logging
.
getLogger
(
__name__
)
# pylint: disable=missing-docstring
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MOCK_MODULESTORE
)
class
ViewsExceptionTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
...
...
@@ -171,7 +167,7 @@ class PartialDictMatcher(object):
])
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch
(
'requests.request'
)
class
SingleThreadTestCase
(
ModuleStoreTestCase
):
def
setUp
(
self
):
...
...
@@ -280,7 +276,7 @@ class SingleThreadTestCase(ModuleStoreTestCase):
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch
(
'requests.request'
)
class
SingleCohortedThreadTestCase
(
CohortedContentTestCase
):
def
_create_mock_cohorted_thread
(
self
,
mock_request
):
...
...
@@ -773,7 +769,7 @@ class FollowedThreadsDiscussionGroupIdTestCase(CohortedContentTestCase, Cohorted
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
InlineDiscussionTestCase
(
ModuleStoreTestCase
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
(
org
=
"TestX"
,
number
=
"101"
,
display_name
=
"Test Course"
)
...
...
@@ -803,7 +799,7 @@ class InlineDiscussionTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
response_data
[
"discussion_data"
][
0
][
"courseware_title"
],
expected_courseware_title
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch
(
'requests.request'
)
class
UserProfileTestCase
(
ModuleStoreTestCase
):
...
...
@@ -915,7 +911,7 @@ class UserProfileTestCase(ModuleStoreTestCase):
self
.
assertEqual
(
response
.
status_code
,
405
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch
(
'requests.request'
)
class
CommentsServiceRequestHeadersTestCase
(
UrlResetMixin
,
ModuleStoreTestCase
):
@patch.dict
(
"django.conf.settings.FEATURES"
,
{
"ENABLE_DISCUSSION_SERVICE"
:
True
})
...
...
@@ -976,7 +972,7 @@ class CommentsServiceRequestHeadersTestCase(UrlResetMixin, ModuleStoreTestCase):
self
.
assert_all_calls_have_header
(
mock_request
,
"X-Edx-Api-Key"
,
"test_api_key"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
InlineDiscussionUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -996,7 +992,7 @@ class InlineDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
assertEqual
(
response_data
[
"discussion_data"
][
0
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
ForumFormDiscussionUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -1017,7 +1013,7 @@ class ForumFormDiscussionUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
assertEqual
(
response_data
[
"discussion_data"
][
0
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
ForumDiscussionSearchUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -1042,7 +1038,7 @@ class ForumDiscussionSearchUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin
self
.
assertEqual
(
response_data
[
"discussion_data"
][
0
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
SingleThreadUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -1064,7 +1060,7 @@ class SingleThreadUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
assertEqual
(
response_data
[
"content"
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
UserProfileUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -1085,7 +1081,7 @@ class UserProfileUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
assertEqual
(
response_data
[
"discussion_data"
][
0
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
FollowedThreadsUnicodeTestCase
(
ModuleStoreTestCase
,
UnicodeTestMixin
):
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
...
...
@@ -1106,7 +1102,7 @@ class FollowedThreadsUnicodeTestCase(ModuleStoreTestCase, UnicodeTestMixin):
self
.
assertEqual
(
response_data
[
"discussion_data"
][
0
][
"body"
],
text
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
EnrollmentTestCase
(
ModuleStoreTestCase
):
"""
Tests for the behavior of views depending on if the student is enrolled
...
...
lms/djangoapps/django_comment_client/tests/test_models.py
View file @
17379f40
import
django_comment_common.models
as
models
from
django.test
import
TestCase
"""
Tests for the django comment client integration models
"""
from
django.test.testcases
import
TestCase
from
django.test.utils
import
override_settings
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_TOY_MODULESTORE
import
django_comment_common.models
as
models
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
class
RoleClassTestCase
(
TestCase
):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_TOY_MODULESTORE
)
class
RoleClassTestCase
(
ModuleStoreTestCase
):
"""
Tests for roles of the comment client service integration
"""
def
setUp
(
self
):
# For course ID, syntax edx/classname/classdate is important
# because xmodel.course_module.id_to_location looks for a string to split
...
...
@@ -28,7 +35,7 @@ class RoleClassTestCase(TestCase):
def
render_template
():
pass
def
test
HasP
ermission
(
self
):
def
test
_has_p
ermission
(
self
):
# Whenever you add a permission to student_role,
# Roles with the same FORUM_ROLE in same class also receives the same
# permission.
...
...
@@ -37,8 +44,7 @@ class RoleClassTestCase(TestCase):
self
.
assertTrue
(
self
.
student_2_role
.
has_permission
(
"delete_thread"
))
self
.
assertFalse
(
self
.
TA_role
.
has_permission
(
"delete_thread"
))
def
testInheritPermissions
(
self
):
def
test_inherit_permission
(
self
):
self
.
TA_role
.
inherit_permissions
(
self
.
student_role
)
self
.
assertTrue
(
self
.
TA_role
.
has_permission
(
"delete_thread"
))
# Despite being from 2 different courses, TA_role_2 can still inherit
...
...
@@ -47,8 +53,11 @@ class RoleClassTestCase(TestCase):
class
PermissionClassTestCase
(
TestCase
):
"""
Tests for permissions of the comment client service integration
"""
def
setUp
(
self
):
self
.
permission
=
models
.
Permission
.
objects
.
get_or_create
(
name
=
"test"
)[
0
]
def
test
U
nicode
(
self
):
def
test
_u
nicode
(
self
):
self
.
assertEqual
(
str
(
self
.
permission
),
"test"
)
lms/djangoapps/django_comment_client/tests/test_utils.py
View file @
17379f40
# -*- coding: utf-8 -*-
import
json
import
mock
from
datetime
import
datetime
import
json
from
pytz
import
UTC
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test.utils
import
override_settings
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
edxmako
import
add_lookup
import
mock
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
django_comment_client.tests.factories
import
RoleFactory
from
django_comment_client.tests.unicode
import
UnicodeTestMixin
import
django_comment_client.utils
as
utils
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
edxmako
import
add_lookup
class
DictionaryTestCase
(
TestCase
):
...
...
@@ -41,8 +42,12 @@ class DictionaryTestCase(TestCase):
self
.
assertEqual
(
utils
.
merge_dict
(
d1
,
d2
),
expected
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
AccessUtilsTestCase
(
ModuleStoreTestCase
):
"""
Base testcase class for access and roles for the
comment client service integration
"""
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
()
self
.
course_id
=
self
.
course
.
id
...
...
@@ -78,8 +83,12 @@ class AccessUtilsTestCase(ModuleStoreTestCase):
self
.
assertFalse
(
ret
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CoursewareContextTestCase
(
ModuleStoreTestCase
):
"""
Base testcase class for courseware context for the
comment client service integration
"""
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
(
org
=
"TestX"
,
number
=
"101"
,
display_name
=
"Test Course"
)
self
.
discussion1
=
ItemFactory
.
create
(
...
...
@@ -135,8 +144,12 @@ class CoursewareContextTestCase(ModuleStoreTestCase):
assertThreadCorrect
(
threads
[
1
],
self
.
discussion2
,
"Subsection / Discussion 2"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CategoryMapTestCase
(
ModuleStoreTestCase
):
"""
Base testcase class for discussion categories for the
comment client service integration
"""
def
setUp
(
self
):
self
.
course
=
CourseFactory
.
create
(
org
=
"TestX"
,
number
=
"101"
,
display_name
=
"Test Course"
,
...
...
lms/djangoapps/django_comment_client/tests/utils.py
View file @
17379f40
from
django.test.utils
import
override_settings
from
mock
import
patch
from
course_groups.models
import
CourseUserGroup
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
django_comment_common.models
import
Role
from
django_comment_common.utils
import
seed_permissions_roles
from
mock
import
patch
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
CohortedContentTestCase
(
ModuleStoreTestCase
):
"""
Sets up a course with a student, a moderator and their cohorts.
...
...
lms/djangoapps/instructor/management/tests/test_openended_commands.py
View file @
17379f40
...
...
@@ -5,34 +5,41 @@ import json
from
mock
import
patch
from
pytz
import
UTC
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locations
import
Location
import
capa.xqueue_interface
as
xqueue_interface
from
opaque_keys.edx.locations
import
Location
from
courseware.courses
import
get_course_with_access
from
courseware.tests.factories
import
StudentModuleFactory
,
UserFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.open_ended_grading_classes.openendedchild
import
OpenEndedChild
from
xmodule.tests.test_util_open_ended
import
(
STATE_INITIAL
,
STATE_ACCESSING
,
STATE_POST_ASSESSMENT
)
from
courseware.courses
import
get_course_with_access
from
courseware.tests.factories
import
StudentModuleFactory
,
UserFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
student.models
import
anonymous_id_for_user
from
instructor.management.commands.openended_post
import
post_submission_for_student
from
instructor.management.commands.openended_stats
import
calculate_task_statistics
from
instructor.utils
import
get_module_for_student
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
OpenEndedPostTest
(
ModuleStoreTestCase
):
"""Test the openended_post management command."""
def
setUp
(
self
):
self
.
course_id
=
SlashSeparatedCourseKey
(
"edX"
,
"open_ended"
,
"2012_Fall"
)
self
.
user
=
UserFactory
()
store
=
modulestore
()
course_items
=
import_from_xml
(
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'open_ended'
])
# pylint: disable=maybe-no-member
self
.
course
=
course_items
[
0
]
self
.
course_id
=
self
.
course
.
id
self
.
problem_location
=
Location
(
"edX"
,
"open_ended"
,
"2012_Fall"
,
"combinedopenended"
,
"SampleQuestion"
)
self
.
self_assessment_task_number
=
0
self
.
open_ended_task_number
=
1
...
...
@@ -87,7 +94,7 @@ class OpenEndedPostTest(ModuleStoreTestCase):
mock_send_to_queue
.
return_value
=
(
0
,
"Successfully queued"
)
module
=
get_module_for_student
(
self
.
student_on_accessing
,
self
.
problem_location
)
task
=
module
.
child_module
.
get_task_number
(
self
.
open_ended_task_number
)
module
.
child_module
.
get_task_number
(
self
.
open_ended_task_number
)
student_response
=
"Here is an answer."
student_anonymous_id
=
anonymous_id_for_user
(
self
.
student_on_accessing
,
None
)
...
...
@@ -123,12 +130,17 @@ class OpenEndedPostTest(ModuleStoreTestCase):
self
.
assertFalse
(
result
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
OpenEndedStatsTest
(
ModuleStoreTestCase
):
"""Test the openended_stats management command."""
def
setUp
(
self
):
self
.
course_id
=
SlashSeparatedCourseKey
(
"edX"
,
"open_ended"
,
"2012_Fall"
)
self
.
user
=
UserFactory
()
store
=
modulestore
()
course_items
=
import_from_xml
(
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'open_ended'
])
# pylint: disable=maybe-no-member
self
.
course
=
course_items
[
0
]
self
.
course_id
=
self
.
course
.
id
self
.
problem_location
=
Location
(
"edX"
,
"open_ended"
,
"2012_Fall"
,
"combinedopenended"
,
"SampleQuestion"
)
self
.
task_number
=
1
self
.
invalid_task_number
=
3
...
...
lms/djangoapps/instructor/tests/test_access.py
View file @
17379f40
...
...
@@ -8,7 +8,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
django.test.utils
import
override_settings
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.roles
import
CourseBetaTesterRole
,
CourseStaffRole
from
django_comment_common.models
import
(
Role
,
...
...
@@ -19,7 +19,7 @@ from instructor.access import (allow_access,
update_forum_role
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAccessList
(
ModuleStoreTestCase
):
""" Test access listings. """
def
setUp
(
self
):
...
...
@@ -41,7 +41,7 @@ class TestInstructorAccessList(ModuleStoreTestCase):
self
.
assertEqual
(
set
(
beta_testers
),
set
(
self
.
beta_testers
))
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAccessAllow
(
ModuleStoreTestCase
):
""" Test access allow. """
def
setUp
(
self
):
...
...
@@ -75,7 +75,7 @@ class TestInstructorAccessAllow(ModuleStoreTestCase):
allow_access
(
self
.
course
,
user
,
'staff'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAccessRevoke
(
ModuleStoreTestCase
):
""" Test access revoke. """
def
setUp
(
self
):
...
...
@@ -109,7 +109,7 @@ class TestInstructorAccessRevoke(ModuleStoreTestCase):
revoke_access
(
self
.
course
,
user
,
'robot-not-a-level'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAccessForum
(
ModuleStoreTestCase
):
"""
Test forum access control.
...
...
lms/djangoapps/instructor/tests/test_api.py
View file @
17379f40
...
...
@@ -2,58 +2,57 @@
"""
Unit tests for instructor.api methods.
"""
import
unittest
import
json
import
requests
import
datetime
import
ddt
import
random
import
io
import
json
import
random
import
requests
from
unittest
import
TestCase
from
urllib
import
quote
from
django.test
import
TestCase
from
nose.tools
import
raises
from
mock
import
Mock
,
patch
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
django.contrib.auth.models
import
User
from
django.core
import
mail
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
django.core.urlresolvers
import
reverse
from
django.http
import
HttpRequest
,
HttpResponse
from
django_comment_common.models
import
FORUM_ROLE_COMMUNITY_TA
from
django_comment_common.utils
import
seed_permissions_roles
from
django.core
import
mail
from
django.test
import
RequestFactory
,
TestCase
from
django.test.utils
import
override_settings
from
django.utils.timezone
import
utc
from
django.test
import
RequestFactory
from
django.contrib.auth.models
import
User
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
mock
import
Mock
,
patch
from
nose.tools
import
raises
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
course_modes.models
import
CourseMode
from
courseware.models
import
StudentModule
from
courseware.tests.factories
import
StaffFactory
,
InstructorFactory
,
BetaTesterFactory
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
django_comment_common.models
import
FORUM_ROLE_COMMUNITY_TA
from
django_comment_common.utils
import
seed_permissions_roles
from
microsite_configuration
import
microsite
from
shoppingcart.models
import
(
RegistrationCodeRedemption
,
Order
,
PaidCourseRegistration
,
Coupon
,
Invoice
,
CourseRegistrationCode
)
from
student.models
import
(
CourseEnrollment
,
CourseEnrollmentAllowed
,
NonExistentCourseError
)
from
student.tests.factories
import
UserFactory
from
courseware.tests.factories
import
StaffFactory
,
InstructorFactory
,
BetaTesterFactory
from
student.roles
import
CourseBetaTesterRole
from
microsite_configuration
import
microsite
from
instructor.tests.utils
import
FakeContentTask
,
FakeEmail
,
FakeEmailInfo
from
student.models
import
CourseEnrollment
,
CourseEnrollmentAllowed
from
courseware.models
import
StudentModule
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
# modules which are mocked in test cases.
import
instructor_task.api
import
instructor.views.api
from
instructor.tests.utils
import
FakeContentTask
,
FakeEmail
,
FakeEmailInfo
from
instructor.views.api
import
generate_unique_password
from
instructor.views.api
import
_split_input_list
,
common_exceptions_400
from
instructor_task.api_helper
import
AlreadyRunningError
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
shoppingcart.models
import
(
RegistrationCodeRedemption
,
Order
,
PaidCourseRegistration
,
Coupon
,
Invoice
,
CourseRegistrationCode
)
from
course_modes.models
import
CourseMode
from
django.core.files.uploadedfile
import
SimpleUploadedFile
from
student.models
import
NonExistentCourseError
from
.test_tools
import
msk_from_problem_urlname
from
..views.tools
import
get_extended_due
...
...
@@ -96,7 +95,7 @@ def view_alreadyrunningerror(request): # pylint: disable=unused-argument
raise
AlreadyRunningError
()
class
TestCommonExceptions400
(
unittest
.
TestCase
):
class
TestCommonExceptions400
(
TestCase
):
"""
Testing the common_exceptions_400 decorator.
"""
...
...
@@ -136,7 +135,7 @@ class TestCommonExceptions400(unittest.TestCase):
self
.
assertIn
(
"Task is already running"
,
result
[
"error"
])
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestInstructorAPIDenyLevels
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
...
...
@@ -291,7 +290,7 @@ class TestInstructorAPIDenyLevels(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ALLOW_AUTOMATED_SIGNUPS'
:
True
})
class
TestInstructorAPIBulkAccountCreationAndEnrollment
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
...
...
@@ -528,7 +527,7 @@ class TestInstructorAPIBulkAccountCreationAndEnrollment(ModuleStoreTestCase, Log
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAPIEnrollment
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test enrollment modification endpoint.
...
...
@@ -1084,7 +1083,7 @@ class TestInstructorAPIEnrollment(ModuleStoreTestCase, LoginEnrollmentTestCase):
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAPIBulkBetaEnrollment
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test bulk beta modify access endpoint.
...
...
@@ -1397,7 +1396,7 @@ class TestInstructorAPIBulkBetaEnrollment(ModuleStoreTestCase, LoginEnrollmentTe
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAPILevelsAccess
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test endpoints whereby instructors can change permissions
...
...
@@ -1635,7 +1634,7 @@ class TestInstructorAPILevelsAccess(ModuleStoreTestCase, LoginEnrollmentTestCase
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_PAID_COURSE_REGISTRATION'
:
True
})
class
TestInstructorAPILevelsDataDump
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
...
...
@@ -2079,7 +2078,7 @@ class TestInstructorAPILevelsDataDump(ModuleStoreTestCase, LoginEnrollmentTestCa
self
.
assertEqual
(
response
.
status_code
,
400
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAPIRegradeTask
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test endpoints whereby instructors can change student grades.
...
...
@@ -2219,7 +2218,7 @@ class TestInstructorAPIRegradeTask(ModuleStoreTestCase, LoginEnrollmentTestCase)
self
.
assertTrue
(
act
.
called
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
settings
.
FEATURES
,
{
'ENABLE_INSTRUCTOR_EMAIL'
:
True
,
'REQUIRE_COURSE_EMAIL_AUTH'
:
False
})
class
TestInstructorSendEmail
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
...
...
@@ -2301,7 +2300,7 @@ class MockCompletionInfo(object):
return
False
,
'Task Errored In Some Way'
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorAPITaskLists
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test instructor task list endpoint.
...
...
@@ -2463,7 +2462,7 @@ class TestInstructorAPITaskLists(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
assertEqual
(
actual_tasks
,
expected_tasks
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.object
(
instructor_task
.
api
,
'get_instructor_task_history'
)
class
TestInstructorEmailContentList
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
...
...
@@ -2599,7 +2598,7 @@ class TestInstructorEmailContentList(ModuleStoreTestCase, LoginEnrollmentTestCas
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@override_settings
(
ANALYTICS_SERVER_URL
=
"http://robotanalyticsserver.netbot:900/"
)
@override_settings
(
ANALYTICS_API_KEY
=
"robot_api_key"
)
class
TestInstructorAPIAnalyticsProxy
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
...
...
@@ -2781,7 +2780,7 @@ class TestInstructorAPIHelpers(TestCase):
msk_from_problem_urlname
(
*
args
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestDueDateExtensions
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Test data dumps for reporting.
...
...
@@ -2970,7 +2969,7 @@ class TestDueDateExtensions(ModuleStoreTestCase, LoginEnrollmentTestCase):
self
.
user1
.
profile
.
name
,
self
.
user1
.
username
)})
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@override_settings
(
REGISTRATION_CODE_LENGTH
=
8
)
class
TestCourseRegistrationCodes
(
ModuleStoreTestCase
):
"""
...
...
lms/djangoapps/instructor/tests/test_ecommerce.py
View file @
17379f40
...
...
@@ -2,21 +2,20 @@
Unit tests for Ecommerce feature flag in new instructor dashboard.
"""
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
mock
import
patch
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
course_modes.models
import
CourseMode
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.roles
import
CourseFinanceAdminRole
from
shoppingcart.models
import
Coupon
,
PaidCourseRegistration
,
CourseRegistrationCode
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
course_modes.models
import
CourseMode
from
shoppingcart.models
import
Coupon
,
PaidCourseRegistration
,
CourseRegistrationCode
from
mock
import
patch
from
student.roles
import
CourseFinanceAdminRole
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestECommerceDashboardViews
(
ModuleStoreTestCase
):
"""
Check for E-commerce view on the new instructor dashboard
...
...
lms/djangoapps/instructor/tests/test_email.py
View file @
17379f40
...
...
@@ -4,24 +4,20 @@ Additionally tests that bulk email is always disabled for
non-Mongo backed courses, regardless of email feature flag, and
that the view is conditionally available when Course Auth is turned on.
"""
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
mock
import
patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
bulk_email.models
import
CourseAuthorization
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO_MODULESTORE
from
mock
import
patch
from
bulk_email.models
import
CourseAuthorization
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestNewInstructorDashboardEmailViewMongoBacked
(
ModuleStoreTestCase
):
"""
Check for email view on the new instructor dashboard
...
...
@@ -110,7 +106,7 @@ class TestNewInstructorDashboardEmailViewMongoBacked(ModuleStoreTestCase):
self
.
assertFalse
(
self
.
email_link
in
response
.
content
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestNewInstructorDashboardEmailViewXMLBacked
(
ModuleStoreTestCase
):
"""
Check for email view on the new instructor dashboard
...
...
lms/djangoapps/instructor/tests/test_enrollment.py
View file @
17379f40
...
...
@@ -11,7 +11,7 @@ from django.test import TestCase
from
django.test.utils
import
override_settings
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.models
import
CourseEnrollment
,
CourseEnrollmentAllowed
from
instructor.enrollment
import
(
...
...
@@ -286,7 +286,7 @@ class TestInstructorUnenrollDB(TestEnrollmentChangeBase):
return
self
.
_run_state_change_test
(
before_ideal
,
after_ideal
,
action
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorEnrollmentStudentModule
(
TestCase
):
""" Test student module manipulations. """
def
setUp
(
self
):
...
...
@@ -431,7 +431,7 @@ class TestSendBetaRoleEmail(TestCase):
send_beta_role_email
(
bad_action
,
self
.
user
,
self
.
email_params
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestGetEmailParams
(
ModuleStoreTestCase
):
"""
Test what URLs the function get_email_params returns under different
...
...
lms/djangoapps/instructor/tests/test_hint_manager.py
View file @
17379f40
...
...
@@ -6,7 +6,7 @@ from mock import patch, MagicMock
from
courseware.models
import
XModuleUserStateSummaryField
from
courseware.tests.factories
import
UserStateSummaryFactory
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
import
instructor.hint_manager
as
view
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -15,7 +15,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
# pylint: disable=missing-docstring
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
HintManagerTest
(
ModuleStoreTestCase
):
def
setUp
(
self
):
...
...
lms/djangoapps/instructor/tests/test_legacy_anon_csv.py
View file @
17379f40
...
...
@@ -16,7 +16,7 @@ from django.contrib.auth.models import User
from
django.core.urlresolvers
import
reverse
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
import
instructor.views.legacy
from
student.roles
import
CourseStaffRole
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -25,7 +25,7 @@ from xmodule.modulestore.tests.factories import CourseFactory
from
mock
import
Mock
,
patch
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorDashboardAnonCSV
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
'''
Check for download of csv
...
...
lms/djangoapps/instructor/tests/test_legacy_download_csv.py
View file @
17379f40
...
...
@@ -16,13 +16,13 @@ from django.contrib.auth.models import User
from
django.core.urlresolvers
import
reverse
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.roles
import
CourseStaffRole
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorDashboardGradeDownloadCSV
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
'''
Check for download of csv
...
...
lms/djangoapps/instructor/tests/test_legacy_email.py
View file @
17379f40
...
...
@@ -7,8 +7,9 @@ view is conditionally available when Course Auth is turned on.
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
mock
import
patch
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.tests.factories
import
AdminFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -16,10 +17,8 @@ from xmodule.modulestore import ModuleStoreEnum
from
bulk_email.models
import
CourseAuthorization
from
mock
import
patch
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorDashboardEmailView
(
ModuleStoreTestCase
):
"""
Check for email view displayed with flag
...
...
lms/djangoapps/instructor/tests/test_legacy_enrollment.py
View file @
17379f40
...
...
@@ -10,7 +10,7 @@ from django.test.utils import override_settings
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
,
AdminFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -22,7 +22,7 @@ USER_COUNT = 4
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorEnrollsStudent
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Check Enrollment/Unenrollment with/without auto-enrollment on activation and with/without email notification
...
...
lms/djangoapps/instructor/tests/test_legacy_forum_admin.py
View file @
17379f40
...
...
@@ -14,7 +14,7 @@ from django_comment_common.models import Role, FORUM_ROLE_ADMINISTRATOR, \
from
django_comment_client.utils
import
has_forum_access
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.roles
import
CourseStaffRole
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -32,7 +32,7 @@ def action_name(operation, rolename):
return
'{0} forum {1}'
.
format
(
operation
,
FORUM_ADMIN_ACTION_SUFFIX
[
rolename
])
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestInstructorDashboardForumAdmin
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
'''
Check for change in forum admin role memberships
...
...
lms/djangoapps/instructor/tests/test_legacy_reset.py
View file @
17379f40
...
...
@@ -8,7 +8,7 @@ from django.test.utils import override_settings
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
,
AdminFactory
,
CourseEnrollmentFactory
...
...
@@ -18,7 +18,7 @@ from submissions import api as sub_api
from
student.models
import
anonymous_id_for_user
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
InstructorResetStudentStateTest
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
"""
Reset student state from the legacy instructor dash.
...
...
lms/djangoapps/instructor/tests/test_legacy_xss.py
View file @
17379f40
...
...
@@ -7,7 +7,7 @@ from django.test.client import RequestFactory
from
django.test.utils
import
override_settings
from
markupsafe
import
escape
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
edxmako.tests
import
mako_middleware_process_request
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -18,7 +18,7 @@ from instructor.views import legacy
# pylint: disable=missing-docstring
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestXss
(
ModuleStoreTestCase
):
def
setUp
(
self
):
self
.
_request_factory
=
RequestFactory
()
...
...
lms/djangoapps/instructor/tests/test_spoc_gradebook.py
View file @
17379f40
...
...
@@ -7,7 +7,7 @@ from django.core.urlresolvers import reverse
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
,
AdminFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
capa.tests.response_xml_factory
import
StringResponseXMLFactory
from
courseware.tests.factories
import
StudentModuleFactory
from
xmodule.modulestore.django
import
modulestore
...
...
@@ -16,7 +16,7 @@ from xmodule.modulestore.django import modulestore
USER_COUNT
=
11
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestGradebook
(
ModuleStoreTestCase
):
"""
Test functionality of the spoc gradebook. Sets up a course with assignments and
...
...
lms/djangoapps/instructor/tests/test_tools.py
View file @
17379f40
...
...
@@ -12,7 +12,7 @@ from django.test.utils import override_settings
from
django.utils.timezone
import
utc
from
courseware.models
import
StudentModule
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.tests.factories
import
UserFactory
from
xmodule.fields
import
Date
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -97,7 +97,7 @@ class TestParseDatetime(unittest.TestCase):
tools
.
parse_datetime
(
'foo'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestFindUnit
(
ModuleStoreTestCase
):
"""
Test the find_unit function.
...
...
@@ -130,7 +130,7 @@ class TestFindUnit(ModuleStoreTestCase):
tools
.
find_unit
(
self
.
course
,
url
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestGetUnitsWithDueDate
(
ModuleStoreTestCase
):
"""
Test the get_units_with_due_date function.
...
...
@@ -178,7 +178,7 @@ class TestTitleOrUrl(unittest.TestCase):
self
.
assertEquals
(
tools
.
title_or_url
(
unit
),
'test:hello'
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestSetDueDateExtension
(
ModuleStoreTestCase
):
"""
Test the set_due_date_extensions function.
...
...
@@ -252,7 +252,7 @@ class TestSetDueDateExtension(ModuleStoreTestCase):
self
.
assertEqual
(
self
.
extended_due
(
self
.
homework
),
None
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestDataDumps
(
ModuleStoreTestCase
):
"""
Test data dumps for reporting.
...
...
lms/djangoapps/instructor_task/tests/test_api.py
View file @
17379f40
"""
Test for LMS instructor background task queue management
"""
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
bulk_email.models
import
CourseEmail
,
SEND_TO_ALL
from
courseware.tests.factories
import
UserFactory
from
xmodule.modulestore.exceptions
import
ItemNotFoundError
from
bulk_email.models
import
CourseEmail
,
SEND_TO_ALL
from
instructor_task.api
import
(
get_running_instructor_tasks
,
get_instructor_task_history
,
...
...
lms/djangoapps/instructor_task/tests/test_base.py
View file @
17379f40
...
...
@@ -3,29 +3,27 @@ Base test classes for LMS instructor-initiated background tasks
"""
import
os
import
shutil
import
json
from
uuid
import
uuid4
from
mock
import
Mock
import
shutil
from
uuid
import
uuid4
from
celery.states
import
SUCCESS
,
FAILURE
from
django.conf
import
settings
from
django.test.testcases
import
TestCase
from
django.contrib.auth.models
import
User
from
django.test.utils
import
override_settings
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactory
from
courseware.model_data
import
StudentModule
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
courseware.tests.tests
import
LoginEnrollmentTestCase
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.django
import
modulestore
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
opaque_keys.edx.locations
import
Location
,
SlashSeparatedCourseKey
from
student.tests.factories
import
CourseEnrollmentFactory
,
UserFactory
from
courseware.model_data
import
StudentModule
from
courseware.tests.tests
import
LoginEnrollmentTestCase
,
TEST_DATA_MONGO_MODULESTORE
from
instructor_task.api_helper
import
encode_problem_and_student_input
from
instructor_task.models
import
PROGRESS
,
QUEUING
...
...
@@ -99,7 +97,7 @@ class InstructorTaskTestCase(TestCase):
return
self
.
_create_entry
(
task_state
=
task_state
,
task_output
=
progress
,
student
=
student
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
InstructorTaskCourseTestCase
(
LoginEnrollmentTestCase
,
ModuleStoreTestCase
):
"""
Base test class for InstructorTask-related tests that require
...
...
@@ -184,7 +182,7 @@ class InstructorTaskCourseTestCase(LoginEnrollmentTestCase, ModuleStoreTestCase)
return
request
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
InstructorTaskModuleTestCase
(
InstructorTaskCourseTestCase
):
"""
Base test class for InstructorTask-related tests that require
...
...
lms/djangoapps/instructor_task/tests/test_integration.py
View file @
17379f40
...
...
@@ -6,8 +6,8 @@ paths actually work.
"""
import
csv
import
logging
import
json
import
logging
from
mock
import
patch
import
textwrap
...
...
lms/djangoapps/licenses/tests.py
View file @
17379f40
...
...
@@ -15,7 +15,7 @@ from django.core.management import call_command
from
django.core.urlresolvers
import
reverse
from
nose.tools
import
assert_true
# pylint: disable=no-name-in-module
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
licenses.models
import
CourseSoftware
,
UserLicense
from
student.tests.factories
import
UserFactory
...
...
@@ -144,7 +144,7 @@ class LicenseTestCase(TestCase):
self
.
assertEqual
(
302
,
response
.
status_code
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
CommandTest
(
ModuleStoreTestCase
):
'''Test management command for importing serial numbers'''
def
setUp
(
self
):
...
...
lms/djangoapps/mobile_api/course_info/tests.py
View file @
17379f40
...
...
@@ -4,13 +4,14 @@ Tests for course_info
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
from
rest_framework.test
import
APITestCase
from
courseware.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
courseware.tests.factories
import
UserFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
TestVideoOutline
(
ModuleStoreTestCase
,
APITestCase
):
"""
Tests for /api/mobile/v0.5/course_info/...
...
...
lms/djangoapps/mobile_api/video_outlines/tests.py
View file @
17379f40
"""
Tests for video outline API
"""
import
copy
import
ddt
from
uuid
import
uuid4
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.video_module
import
transcripts_utils
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.django
import
modulestore
from
courseware.tests.factories
import
UserFactory
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
django.core.urlresolvers
import
reverse
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
rest_framework.test
import
APITestCase
from
mobile_api.tests
import
ROLE_CASES
from
edxval
import
api
from
uuid
import
uuid4
from
rest_framework.test
import
APITestCase
import
copy
from
courseware.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
from
xmodule.video_module
import
transcripts_utils
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.django
import
modulestore
from
mobile_api.tests
import
ROLE_CASES
TEST_DATA_CONTENTSTORE
=
copy
.
deepcopy
(
settings
.
CONTENTSTORE
)
TEST_DATA_CONTENTSTORE
[
'DOC_STORE_CONFIG'
][
'db'
]
=
'test_xcontent_
%
s'
%
uuid4
()
.
hex
@ddt.ddt
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
,
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
,
CONTENTSTORE
=
TEST_DATA_CONTENTSTORE
)
class
TestVideoOutline
(
ModuleStoreTestCase
,
APITestCase
):
"""
Tests for /api/mobile/v0.5/video_outlines/
...
...
lms/djangoapps/notifier_api/tests.py
View file @
17379f40
...
...
@@ -16,7 +16,7 @@ from student.tests.factories import UserFactory, CourseEnrollmentFactory
from
user_api.models
import
UserPreference
from
user_api.tests.factories
import
UserPreferenceFactory
from
util.testing
import
UrlResetMixin
from
xmodule.modulestore.tests.django_utils
import
mixed_store_config
,
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
lms/djangoapps/oauth2_handler/tests.py
View file @
17379f40
# pylint: disable=missing-docstring
from
django.core.cache
import
cache
from
django.test.utils
import
override_settings
from
courseware.tests.tests
import
TEST_DATA_MIXED_MODULESTORE
from
lang_pref
import
LANGUAGE_KEY
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_TOY_MODULESTORE
from
student.models
import
anonymous_id_for_user
from
student.models
import
UserProfile
from
student.roles
import
CourseStaffRole
,
CourseInstructorRole
from
student.tests.factories
import
UserFactory
,
UserProfileFactory
from
user_api.models
import
UserPreference
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
# Will also run default tests for IDTokens and UserInfo
from
oauth2_provider.tests
import
IDTokenTestCase
,
UserInfoTestCase
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
class
BaseTestMixin
(
ModuleStoreTestCase
):
profile
=
None
...
...
lms/djangoapps/open_ended_grading/tests.py
View file @
17379f40
...
...
@@ -3,7 +3,6 @@ Tests for open ended grading interfaces
./manage.py lms --settings test test lms/djangoapps/open_ended_grading
"""
from
django.test
import
RequestFactory
import
json
import
logging
...
...
@@ -11,30 +10,36 @@ import logging
from
django.conf
import
settings
from
django.contrib.auth.models
import
User
from
django.core.urlresolvers
import
reverse
from
django.test
import
RequestFactory
from
django.test.utils
import
override_settings
from
edxmako.shortcuts
import
render_to_string
from
edxmako.tests
import
mako_middleware_process_request
from
mock
import
MagicMock
,
patch
,
Mock
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xblock.field_data
import
DictFieldData
from
xblock.fields
import
ScopeIds
from
courseware.tests
import
factories
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
lms.lib.xblock.runtime
import
LmsModuleSystem
from
student.roles
import
CourseStaffRole
from
student.models
import
unique_id_for_user
from
xmodule
import
peer_grading_module
from
xmodule.error_module
import
ErrorDescriptor
from
xmodule.modulestore.django
import
modulestore
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
(
TEST_DATA_MOCK_MODULESTORE
,
TEST_DATA_MIXED_TOY_MODULESTORE
)
from
xmodule.modulestore.xml_importer
import
import_from_xml
from
xmodule.open_ended_grading_classes
import
peer_grading_service
,
controller_query_service
from
xmodule.tests
import
test_util_open_ended
from
courseware.tests
import
factories
from
courseware.tests.helpers
import
LoginEnrollmentTestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
lms.lib.xblock.runtime
import
LmsModuleSystem
from
student.roles
import
CourseStaffRole
from
edxmako.shortcuts
import
render_to_string
from
edxmako.tests
import
mako_middleware_process_request
from
student.models
import
unique_id_for_user
from
open_ended_grading
import
staff_grading_service
,
views
,
utils
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
log
=
logging
.
getLogger
(
__name__
)
...
...
@@ -99,7 +104,7 @@ class StudentProblemListMockQuery(object):
}
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_
TOY_
MODULESTORE
)
class
TestStaffGradingService
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
'''
Check that staff grading service proxy works. Basically just checking the
...
...
@@ -252,7 +257,7 @@ class TestStaffGradingService(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestPeerGradingService
(
ModuleStoreTestCase
,
LoginEnrollmentTestCase
):
'''
Check that staff grading service proxy works. Basically just checking the
...
...
@@ -439,17 +444,17 @@ class TestPeerGradingService(ModuleStoreTestCase, LoginEnrollmentTestCase):
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestPanel
(
ModuleStoreTestCase
):
"""
Run tests on the open ended panel
"""
def
setUp
(
self
):
# Toy courses should be loaded
self
.
course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'open_ended'
,
'2012_Fall'
)
self
.
course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
user
=
factories
.
UserFactory
()
store
=
modulestore
()
course_items
=
import_from_xml
(
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'open_ended'
])
# pylint: disable=maybe-no-member
self
.
course
=
course_items
[
0
]
self
.
course_key
=
self
.
course
.
id
def
test_open_ended_panel
(
self
):
"""
...
...
@@ -483,15 +488,17 @@ class TestPanel(ModuleStoreTestCase):
self
.
assertRegexpMatches
(
response
.
content
,
"Here is a list of open ended problems for this course."
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestPeerGradingFound
(
ModuleStoreTestCase
):
"""
Test to see if peer grading modules can be found properly.
"""
def
setUp
(
self
):
self
.
course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'open_ended_nopath'
,
'2012_Fall'
)
self
.
course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
user
=
factories
.
UserFactory
()
store
=
modulestore
()
course_items
=
import_from_xml
(
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'open_ended_nopath'
])
# pylint: disable=maybe-no-member
self
.
course
=
course_items
[
0
]
self
.
course_key
=
self
.
course
.
id
def
test_peer_grading_nopath
(
self
):
"""
...
...
@@ -503,17 +510,19 @@ class TestPeerGradingFound(ModuleStoreTestCase):
self
.
assertEqual
(
found
,
False
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
IXED
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_M
OCK
_MODULESTORE
)
class
TestStudentProblemList
(
ModuleStoreTestCase
):
"""
Test if the student problem list correctly fetches and parses problems.
"""
def
setUp
(
self
):
# Load an open ended course with several problems.
self
.
course_key
=
SlashSeparatedCourseKey
(
'edX'
,
'open_ended'
,
'2012_Fall'
)
self
.
course
=
modulestore
()
.
get_course
(
self
.
course_key
)
self
.
user
=
factories
.
UserFactory
()
store
=
modulestore
()
course_items
=
import_from_xml
(
store
,
self
.
user
.
id
,
TEST_DATA_DIR
,
[
'open_ended'
])
# pylint: disable=maybe-no-member
self
.
course
=
course_items
[
0
]
self
.
course_key
=
self
.
course
.
id
# Enroll our user in our course and make them an instructor.
make_instructor
(
self
.
course
,
self
.
user
.
email
)
...
...
lms/djangoapps/shoppingcart/tests/test_context_processor.py
View file @
17379f40
"""
Unit tests for shoppingcart context_processor
"""
from
mock
import
patch
,
Mock
from
django.conf
import
settings
from
django.contrib.auth.models
import
AnonymousUser
from
django.test.utils
import
override_settings
from
mock
import
patch
,
Mock
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
course_modes.tests.factories
import
CourseModeFactory
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
from
course_modes.tests.factories
import
CourseModeFactory
from
shoppingcart.models
import
Order
,
PaidCourseRegistration
from
shoppingcart.context_processor
import
user_has_cart_context_processor
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
UserCartContextProcessorUnitTest
(
ModuleStoreTestCase
):
"""
Unit test for shoppingcart context_processor
...
...
lms/djangoapps/shoppingcart/tests/test_reports.py
View file @
17379f40
...
...
@@ -3,16 +3,16 @@
"""
Tests for the Shopping Cart Models
"""
import
datetime
import
pytz
import
StringIO
from
textwrap
import
dedent
import
pytz
import
datetime
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
course_modes.models
import
CourseMode
from
courseware.tests.tests
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
shoppingcart.models
import
(
Order
,
CertificateItem
,
PaidCourseRegistration
,
PaidCourseRegistrationAnnotation
,
CourseRegCodeItemAnnotation
)
from
shoppingcart.views
import
initialize_report
...
...
@@ -22,7 +22,7 @@ from xmodule.modulestore.tests.django_utils import ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
ReportTypeTests
(
ModuleStoreTestCase
):
"""
Tests for the models used to generate certificate status reports
...
...
@@ -179,7 +179,7 @@ class ReportTypeTests(ModuleStoreTestCase):
self
.
assertEqual
(
csv
.
replace
(
'
\r\n
'
,
'
\n
'
)
.
strip
(),
self
.
CORRECT_UNI_REVENUE_SHARE_CSV
.
strip
())
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
ItemizedPurchaseReportTest
(
ModuleStoreTestCase
):
"""
Tests for the models used to generate itemized purchase reports
...
...
lms/djangoapps/staticbook/tests.py
View file @
17379f40
...
...
@@ -10,7 +10,7 @@ import requests
from
django.test.utils
import
override_settings
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
courseware.tests.modulestore_config
import
TEST_DATA_MONGO
_MODULESTORE
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK
_MODULESTORE
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
...
...
@@ -46,7 +46,7 @@ HTML_BOOK = {
}
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
class
StaticBookTest
(
ModuleStoreTestCase
):
"""
Helpers for the static book tests.
...
...
lms/djangoapps/verify_student/tests/test_models.py
View file @
17379f40
# -*- coding: utf-8 -*-
from
datetime
import
timedelta
,
datetime
import
json
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
nose.tools
import
assert_is_none
,
assert_equals
,
assert_raises
,
assert_true
,
assert_false
from
mock
import
patch
import
requests.exceptions
import
pytz
from
django.conf
import
settings
from
django.test
import
TestCase
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
django.test.utils
import
override_settings
from
django.conf
import
settings
import
requests.exceptions
from
mock
import
patch
from
nose.tools
import
assert_is_none
,
assert_equals
,
assert_raises
,
assert_true
,
assert_false
# pylint: disable=E0611
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MOCK_MODULESTORE
from
reverification.tests.factories
import
MidcourseReverificationWindowFactory
from
student.tests.factories
import
UserFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
verify_student.models
import
(
SoftwareSecurePhotoVerification
,
VerificationException
,
)
from
reverification.tests.factories
import
MidcourseReverificationWindowFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
FAKE_SETTINGS
=
{
"SOFTWARE_SECURE"
:
{
...
...
@@ -418,7 +420,7 @@ class TestPhotoVerification(TestCase):
self
.
assertEquals
(
parsed_error_msg
,
"There was an error verifying your ID photos."
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
NGO
_MODULESTORE
)
@override_settings
(
MODULESTORE
=
TEST_DATA_MO
CK
_MODULESTORE
)
@patch.dict
(
settings
.
VERIFY_STUDENT
,
FAKE_SETTINGS
)
@patch
(
'verify_student.models.S3Connection'
,
new
=
MockS3Connection
)
@patch
(
'verify_student.models.Key'
,
new
=
MockKey
)
...
...
lms/djangoapps/verify_student/tests/test_ssencrypt.py
View file @
17379f40
import
base64
from
nose.tools
import
assert_equals
from
verify_student.ssencrypt
import
(
...
...
@@ -7,7 +6,6 @@ from verify_student.ssencrypt import (
rsa_decrypt
,
rsa_encrypt
,
random_aes_key
)
def
test_aes
():
key_str
=
"32fe72aaf2abb44de9e161131b5435c8d37cbdb6f5df242ae860b283115f2dae"
key
=
key_str
.
decode
(
"hex"
)
...
...
@@ -29,7 +27,6 @@ def test_aes():
assert_roundtrip
(
""
)
assert_roundtrip
(
"
\xe9\xe1
a
\x13\x1b
T5
\xc8
"
)
# Random, non-ASCII text
def
test_rsa
():
# Make up some garbage keys for testing purposes.
pub_key_str
=
"""-----BEGIN PUBLIC KEY-----
...
...
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