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
e2ed8ff7
Commit
e2ed8ff7
authored
Feb 03, 2016
by
Toby Lawrence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch to SharedModuleStoreTestCase in the 'student' app where possible.
parent
9ae0dada
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
26 deletions
+60
-26
common/djangoapps/student/tests/test_admin_views.py
+7
-3
common/djangoapps/student/tests/test_bulk_email_settings.py
+7
-5
common/djangoapps/student/tests/test_certificates.py
+12
-6
common/djangoapps/student/tests/test_enrollment.py
+7
-2
common/djangoapps/student/tests/test_login_registration_forms.py
+15
-6
common/djangoapps/student/tests/test_refunds.py
+5
-1
common/djangoapps/student/tests/test_views.py
+7
-3
No files found.
common/djangoapps/student/tests/test_admin_views.py
View file @
e2ed8ff7
...
...
@@ -3,19 +3,23 @@ Tests student admin.py
"""
from
django.core.urlresolvers
import
reverse
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
Shared
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
class
AdminCourseRolesPageTest
(
ModuleStoreTestCase
):
class
AdminCourseRolesPageTest
(
Shared
ModuleStoreTestCase
):
"""Test the django admin course roles form saving data in db.
"""
@classmethod
def
setUpClass
(
cls
):
super
(
AdminCourseRolesPageTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
(
org
=
'edx'
)
def
setUp
(
self
):
super
(
AdminCourseRolesPageTest
,
self
)
.
setUp
()
self
.
user
=
UserFactory
.
create
(
is_staff
=
True
,
is_superuser
=
True
)
self
.
user
.
save
()
self
.
course
=
CourseFactory
.
create
(
org
=
'edx'
)
def
test_save_valid_data
(
self
):
...
...
common/djangoapps/student/tests/test_bulk_email_settings.py
View file @
e2ed8ff7
...
...
@@ -12,7 +12,7 @@ from mock import patch
from
opaque_keys.edx.locations
import
SlashSeparatedCourseKey
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
Shared
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
TEST_DATA_MIXED_TOY_MODULESTORE
from
xmodule.modulestore.tests.factories
import
CourseFactory
...
...
@@ -22,16 +22,18 @@ from bulk_email.models import CourseAuthorization # pylint: disable=import-erro
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardEmailView
(
ModuleStoreTestCase
):
class
TestStudentDashboardEmailView
(
Shared
ModuleStoreTestCase
):
"""
Check for email view displayed with flag
"""
@classmethod
def
setUpClass
(
cls
):
super
(
TestStudentDashboardEmailView
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
super
(
TestStudentDashboardEmailView
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
# Create student account
student
=
UserFactory
.
create
()
CourseEnrollmentFactory
.
create
(
user
=
student
,
course_id
=
self
.
course
.
id
)
...
...
@@ -84,7 +86,7 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase):
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardEmailViewXMLBacked
(
ModuleStoreTestCase
):
class
TestStudentDashboardEmailViewXMLBacked
(
Shared
ModuleStoreTestCase
):
"""
Check for email view on student dashboard, with XML backed course.
"""
...
...
common/djangoapps/student/tests/test_certificates.py
View file @
e2ed8ff7
...
...
@@ -8,8 +8,9 @@ from django.conf import settings
from
django.core.urlresolvers
import
reverse
from
mock
import
patch
from
django.test.utils
import
override_settings
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
Shared
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
certificates.tests.factories
import
GeneratedCertificateFactory
# pylint: disable=import-error
...
...
@@ -30,23 +31,28 @@ def _fake_is_request_in_microsite():
@ddt.ddt
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
CertificateDisplayTest
(
ModuleStoreTestCase
):
class
CertificateDisplayTest
(
Shared
ModuleStoreTestCase
):
"""Tests display of certificates on the student dashboard. """
USERNAME
=
"test_user"
PASSWORD
=
"password"
DOWNLOAD_URL
=
"http://www.example.com/certificate.pdf"
@classmethod
def
setUpClass
(
cls
):
super
(
CertificateDisplayTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
()
cls
.
course
.
certificates_display_behavior
=
"early_with_info"
with
cls
.
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
cls
.
course
.
id
):
cls
.
store
.
update_item
(
cls
.
course
,
cls
.
USERNAME
)
def
setUp
(
self
):
super
(
CertificateDisplayTest
,
self
)
.
setUp
()
self
.
user
=
UserFactory
.
create
(
username
=
self
.
USERNAME
,
password
=
self
.
PASSWORD
)
result
=
self
.
client
.
login
(
username
=
self
.
USERNAME
,
password
=
self
.
PASSWORD
)
self
.
assertTrue
(
result
,
msg
=
"Could not log in"
)
self
.
course
=
CourseFactory
()
self
.
course
.
certificates_display_behavior
=
"early_with_info"
self
.
update_course
(
self
.
course
,
self
.
user
.
username
)
@ddt.data
(
'verified'
,
'professional'
)
@patch.dict
(
'django.conf.settings.FEATURES'
,
{
'CERTIFICATES_HTML_VIEW'
:
False
})
def
test_display_verified_certificate
(
self
,
enrollment_mode
):
...
...
common/djangoapps/student/tests/test_enrollment.py
View file @
e2ed8ff7
...
...
@@ -8,7 +8,7 @@ from mock import patch
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
course_modes.models
import
CourseMode
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
Shared
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
util.testing
import
UrlResetMixin
from
embargo.test_utils
import
restrict_course
...
...
@@ -18,7 +18,7 @@ from student.models import CourseEnrollment
@ddt.ddt
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
EnrollmentTest
(
UrlResetMixin
,
ModuleStoreTestCase
):
class
EnrollmentTest
(
UrlResetMixin
,
Shared
ModuleStoreTestCase
):
"""
Test student enrollment, especially with different course modes.
"""
...
...
@@ -27,6 +27,11 @@ class EnrollmentTest(UrlResetMixin, ModuleStoreTestCase):
EMAIL
=
"bob@example.com"
PASSWORD
=
"edx"
@classmethod
def
setUpClass
(
cls
):
super
(
EnrollmentTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
@patch.dict
(
settings
.
FEATURES
,
{
'EMBARGO'
:
True
})
def
setUp
(
self
):
""" Create a course and user, then log in. """
...
...
common/djangoapps/student/tests/test_login_registration_forms.py
View file @
e2ed8ff7
...
...
@@ -10,8 +10,7 @@ from django.core.urlresolvers import reverse
from
util.testing
import
UrlResetMixin
from
xmodule.modulestore.tests.factories
import
CourseFactory
from
third_party_auth.tests.testutil
import
ThirdPartyAuthTestMixin
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
SharedModuleStoreTestCase
# This relies on third party auth being enabled in the test
# settings with the feature flag `ENABLE_THIRD_PARTY_AUTH`
...
...
@@ -38,14 +37,19 @@ def _finish_auth_url(params):
@ddt.ddt
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
LoginFormTest
(
ThirdPartyAuthTestMixin
,
UrlResetMixin
,
ModuleStoreTestCase
):
class
LoginFormTest
(
ThirdPartyAuthTestMixin
,
UrlResetMixin
,
Shared
ModuleStoreTestCase
):
"""Test rendering of the login form. """
@classmethod
def
setUpClass
(
cls
):
super
(
LoginFormTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
@patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_COMBINED_LOGIN_REGISTRATION"
:
False
})
def
setUp
(
self
):
super
(
LoginFormTest
,
self
)
.
setUp
(
'lms.urls'
)
self
.
url
=
reverse
(
"signin_user"
)
self
.
course
=
CourseFactory
.
create
()
self
.
course_id
=
unicode
(
self
.
course
.
id
)
self
.
courseware_url
=
reverse
(
"courseware"
,
args
=
[
self
.
course_id
])
self
.
configure_google_provider
(
enabled
=
True
)
...
...
@@ -148,14 +152,19 @@ class LoginFormTest(ThirdPartyAuthTestMixin, UrlResetMixin, ModuleStoreTestCase)
@ddt.ddt
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
RegisterFormTest
(
ThirdPartyAuthTestMixin
,
UrlResetMixin
,
ModuleStoreTestCase
):
class
RegisterFormTest
(
ThirdPartyAuthTestMixin
,
UrlResetMixin
,
Shared
ModuleStoreTestCase
):
"""Test rendering of the registration form. """
@classmethod
def
setUpClass
(
cls
):
super
(
RegisterFormTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
@patch.dict
(
settings
.
FEATURES
,
{
"ENABLE_COMBINED_LOGIN_REGISTRATION"
:
False
})
def
setUp
(
self
):
super
(
RegisterFormTest
,
self
)
.
setUp
(
'lms.urls'
)
self
.
url
=
reverse
(
"register_user"
)
self
.
course
=
CourseFactory
.
create
()
self
.
course_id
=
unicode
(
self
.
course
.
id
)
self
.
configure_google_provider
(
enabled
=
True
)
self
.
configure_facebook_provider
(
enabled
=
True
)
...
...
common/djangoapps/student/tests/test_refunds.py
View file @
e2ed8ff7
...
...
@@ -41,10 +41,14 @@ class RefundableTest(SharedModuleStoreTestCase):
Tests for dashboard utility functions
"""
@classmethod
def
setUpClass
(
cls
):
super
(
RefundableTest
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
""" Setup components used by each refund test."""
super
(
RefundableTest
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
self
.
user
=
UserFactory
.
create
(
username
=
"jack"
,
email
=
"jack@fake.edx.org"
,
password
=
'test'
)
self
.
verified_mode
=
CourseModeFactory
.
create
(
course_id
=
self
.
course
.
id
,
...
...
common/djangoapps/student/tests/test_views.py
View file @
e2ed8ff7
...
...
@@ -12,13 +12,13 @@ from django.conf import settings
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
from
student.models
import
CourseEnrollment
from
student.helpers
import
DISABLE_UNENROLL_CERT_STATES
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.django_utils
import
Shared
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
@ddt.ddt
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardUnenrollments
(
ModuleStoreTestCase
):
class
TestStudentDashboardUnenrollments
(
Shared
ModuleStoreTestCase
):
"""
Test to ensure that the student dashboard does not show the unenroll button for users with certificates.
"""
...
...
@@ -27,10 +27,14 @@ class TestStudentDashboardUnenrollments(ModuleStoreTestCase):
PASSWORD
=
"edx"
UNENROLL_ELEMENT_ID
=
"#actions-item-unenroll-0"
@classmethod
def
setUpClass
(
cls
):
super
(
TestStudentDashboardUnenrollments
,
cls
)
.
setUpClass
()
cls
.
course
=
CourseFactory
.
create
()
def
setUp
(
self
):
""" Create a course and user, then log in. """
super
(
TestStudentDashboardUnenrollments
,
self
)
.
setUp
()
self
.
course
=
CourseFactory
.
create
()
self
.
user
=
UserFactory
.
create
(
username
=
self
.
USERNAME
,
email
=
self
.
EMAIL
,
password
=
self
.
PASSWORD
)
CourseEnrollmentFactory
(
course_id
=
self
.
course
.
id
,
user
=
self
.
user
)
self
.
cert_status
=
None
...
...
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