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
bd2f3c75
Commit
bd2f3c75
authored
Jun 23, 2014
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Explicitly skip tests in common unless we know we're running the LMS unittest suite
parent
4eb234e7
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
81 deletions
+50
-81
common/djangoapps/student/tests/test_bulk_email_settings.py
+6
-12
common/djangoapps/student/tests/test_change_name.py
+8
-14
common/djangoapps/student/tests/test_userstanding.py
+26
-36
common/djangoapps/student/tests/tests.py
+4
-9
common/djangoapps/track/tests/test_logs.py
+6
-10
No files found.
common/djangoapps/student/tests/test_bulk_email_settings.py
View file @
bd2f3c75
...
...
@@ -7,8 +7,8 @@ Course Auth is turned on.
from
django.test.utils
import
override_settings
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
unittest.case
import
SkipT
est
from
django.core.urlresolvers
import
reverse
import
unitt
est
from
courseware.tests.tests
import
TEST_DATA_MONGO_MODULESTORE
from
student.tests.factories
import
UserFactory
,
CourseEnrollmentFactory
...
...
@@ -23,6 +23,7 @@ from mock import patch
@override_settings
(
MODULESTORE
=
TEST_DATA_MONGO_MODULESTORE
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardEmailView
(
ModuleStoreTestCase
):
"""
Check for email view displayed with flag
...
...
@@ -35,11 +36,7 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase):
CourseEnrollmentFactory
.
create
(
user
=
student
,
course_id
=
self
.
course
.
id
)
self
.
client
.
login
(
username
=
student
.
username
,
password
=
"test"
)
try
:
# URL for dashboard
self
.
url
=
reverse
(
'dashboard'
)
except
NoReverseMatch
:
raise
SkipTest
(
"Skip this test if url cannot be found (ie running from CMS tests)"
)
self
.
url
=
reverse
(
'dashboard'
)
# URL for email settings modal
self
.
email_modal_link
=
(
(
'<a href="#email-settings-modal" class="email-settings" rel="leanModal" '
...
...
@@ -92,6 +89,7 @@ class TestStudentDashboardEmailView(ModuleStoreTestCase):
@override_settings
(
MODULESTORE
=
TEST_DATA_MIXED_MODULESTORE
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestStudentDashboardEmailViewXMLBacked
(
ModuleStoreTestCase
):
"""
Check for email view on student dashboard, with XML backed course.
...
...
@@ -107,11 +105,7 @@ class TestStudentDashboardEmailViewXMLBacked(ModuleStoreTestCase):
)
self
.
client
.
login
(
username
=
student
.
username
,
password
=
"test"
)
try
:
# URL for dashboard
self
.
url
=
reverse
(
'dashboard'
)
except
NoReverseMatch
:
raise
SkipTest
(
"Skip this test if url cannot be found (ie running from CMS tests)"
)
self
.
url
=
reverse
(
'dashboard'
)
# URL for email settings modal
self
.
email_modal_link
=
(
...
...
common/djangoapps/student/tests/test_change_name.py
View file @
bd2f3c75
...
...
@@ -3,15 +3,17 @@ Unit tests for change_name view of student.
"""
import
json
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
django.conf
import
settings
from
django.core.urlresolvers
import
reverse
from
django.test.client
import
Client
from
django.test
import
TestCase
from
student.tests.factories
import
UserFactory
from
student.models
import
UserProfile
from
unittest.case
import
SkipT
est
import
unitt
est
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TestChangeName
(
TestCase
):
"""
Check the change_name view of student.
...
...
@@ -22,14 +24,14 @@ class TestChangeName(TestCase):
def
test_change_name_get_request
(
self
):
"""Get requests are not allowed in this view."""
change_name_url
=
self
.
get_url
(
)
change_name_url
=
reverse
(
'change_name'
)
resp
=
self
.
client
.
get
(
change_name_url
)
self
.
assertEquals
(
resp
.
status_code
,
405
)
def
test_change_name_post_request
(
self
):
"""Name will be changed when provided with proper data."""
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
'test'
)
change_name_url
=
self
.
get_url
(
)
change_name_url
=
reverse
(
'change_name'
)
resp
=
self
.
client
.
post
(
change_name_url
,
{
'new_name'
:
'waqas'
,
'rationale'
:
'change identity'
...
...
@@ -44,7 +46,7 @@ class TestChangeName(TestCase):
def
test_change_name_without_name
(
self
):
"""Empty string for name is not allowed in this view."""
self
.
client
.
login
(
username
=
self
.
student
.
username
,
password
=
'test'
)
change_name_url
=
self
.
get_url
(
)
change_name_url
=
reverse
(
'change_name'
)
resp
=
self
.
client
.
post
(
change_name_url
,
{
'new_name'
:
''
,
'rationale'
:
'change identity'
...
...
@@ -54,17 +56,9 @@ class TestChangeName(TestCase):
def
test_unauthenticated
(
self
):
"""Unauthenticated user is not allowed to call this view."""
change_name_url
=
self
.
get_url
(
)
change_name_url
=
reverse
(
'change_name'
)
resp
=
self
.
client
.
post
(
change_name_url
,
{
'new_name'
:
'waqas'
,
'rationale'
:
'change identity'
})
self
.
assertEquals
(
resp
.
status_code
,
404
)
def
get_url
(
self
):
"""Get the url of change_name view."""
try
:
change_name_url
=
reverse
(
'change_name'
)
return
change_name_url
except
NoReverseMatch
:
raise
SkipTest
(
"Skip this test if url cannot be found (ie running from CMS tests)"
)
common/djangoapps/student/tests/test_userstanding.py
View file @
bd2f3c75
...
...
@@ -2,11 +2,13 @@
These are tests for disabling and enabling student accounts, and for making sure
that students with disabled accounts are unable to access the courseware.
"""
import
unittest
from
student.tests.factories
import
UserFactory
,
UserStandingFactory
from
student.models
import
UserStanding
from
django.conf
import
settings
from
django.test
import
TestCase
,
Client
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
nose.plugins.skip
import
SkipTest
from
django.core.urlresolvers
import
reverse
class
UserStandingTest
(
TestCase
):
...
...
@@ -48,27 +50,21 @@ class UserStandingTest(TestCase):
changed_by
=
self
.
admin
)
# set different stock urls for lms and cms
# to test disabled accounts' access to site
try
:
self
.
some_url
=
reverse
(
'dashboard'
)
except
NoReverseMatch
:
self
.
some_url
=
'/course/'
# set stock url to test disabled accounts' access to site
self
.
some_url
=
'/'
# since it's only possible to disable accounts from lms, we're going
# to skip tests for cms
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_disable_account
(
self
):
self
.
assertEqual
(
UserStanding
.
objects
.
filter
(
user
=
self
.
good_user
)
.
count
(),
0
)
try
:
response
=
self
.
admin_client
.
post
(
reverse
(
'disable_account_ajax'
),
{
'username'
:
self
.
good_user
.
username
,
'account_action'
:
'disable'
,
})
except
NoReverseMatch
:
raise
SkipTest
()
response
=
self
.
admin_client
.
post
(
reverse
(
'disable_account_ajax'
),
{
'username'
:
self
.
good_user
.
username
,
'account_action'
:
'disable'
,
})
self
.
assertEqual
(
UserStanding
.
objects
.
get
(
user
=
self
.
good_user
)
.
account_status
,
UserStanding
.
ACCOUNT_DISABLED
...
...
@@ -78,37 +74,31 @@ class UserStandingTest(TestCase):
response
=
self
.
bad_user_client
.
get
(
self
.
some_url
)
self
.
assertEqual
(
response
.
status_code
,
403
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_reenable_account
(
self
):
try
:
response
=
self
.
admin_client
.
post
(
reverse
(
'disable_account_ajax'
),
{
'username'
:
self
.
bad_user
.
username
,
'account_action'
:
'reenable'
})
except
NoReverseMatch
:
raise
SkipTest
()
response
=
self
.
admin_client
.
post
(
reverse
(
'disable_account_ajax'
),
{
'username'
:
self
.
bad_user
.
username
,
'account_action'
:
'reenable'
})
self
.
assertEqual
(
UserStanding
.
objects
.
get
(
user
=
self
.
bad_user
)
.
account_status
,
UserStanding
.
ACCOUNT_ENABLED
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_non_staff_cant_access_disable_view
(
self
):
try
:
response
=
self
.
non_staff_client
.
get
(
reverse
(
'manage_user_standing'
),
{
'user'
:
self
.
non_staff
,
})
except
NoReverseMatch
:
raise
SkipTest
()
response
=
self
.
non_staff_client
.
get
(
reverse
(
'manage_user_standing'
),
{
'user'
:
self
.
non_staff
,
})
self
.
assertEqual
(
response
.
status_code
,
404
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
test_non_staff_cant_disable_account
(
self
):
try
:
response
=
self
.
non_staff_client
.
post
(
reverse
(
'disable_account_ajax'
),
{
'username'
:
self
.
good_user
.
username
,
'user'
:
self
.
non_staff
,
'account_action'
:
'disable'
})
except
NoReverseMatch
:
raise
SkipTest
()
response
=
self
.
non_staff_client
.
post
(
reverse
(
'disable_account_ajax'
),
{
'username'
:
self
.
good_user
.
username
,
'user'
:
self
.
non_staff
,
'account_action'
:
'disable'
})
self
.
assertEqual
(
response
.
status_code
,
404
)
self
.
assertEqual
(
UserStanding
.
objects
.
filter
(
user
=
self
.
good_user
)
.
count
(),
0
...
...
common/djangoapps/student/tests/tests.py
View file @
bd2f3c75
...
...
@@ -153,15 +153,13 @@ class DashboardTest(TestCase):
)
self
.
client
=
Client
()
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
check_verification_status_on
(
self
,
mode
,
value
):
"""
Check that the css class and the status message are in the dashboard html.
"""
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
location
.
course_key
,
mode
=
mode
)
try
:
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
except
NoReverseMatch
:
raise
SkipTest
(
"Skip this test if url cannot be found (ie running from CMS tests)"
)
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertContains
(
response
,
"class=
\"
course {0}
\"
"
.
format
(
mode
))
self
.
assertContains
(
response
,
value
)
...
...
@@ -175,15 +173,13 @@ class DashboardTest(TestCase):
self
.
check_verification_status_on
(
'honor'
,
'You
\'
re enrolled as an honor code student'
)
self
.
check_verification_status_on
(
'audit'
,
'You
\'
re auditing this course'
)
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
def
check_verification_status_off
(
self
,
mode
,
value
):
"""
Check that the css class and the status message are not in the dashboard html.
"""
CourseEnrollment
.
enroll
(
self
.
user
,
self
.
course
.
location
.
course_key
,
mode
=
mode
)
try
:
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
except
NoReverseMatch
:
raise
SkipTest
(
"Skip this test if url cannot be found (ie running from CMS tests)"
)
response
=
self
.
client
.
get
(
reverse
(
'dashboard'
))
self
.
assertNotContains
(
response
,
"class=
\"
course {0}
\"
"
.
format
(
mode
))
self
.
assertNotContains
(
response
,
value
)
...
...
@@ -232,7 +228,6 @@ class DashboardTest(TestCase):
self
.
assertFalse
(
enrollment
.
refundable
())
class
EnrollInCourseTest
(
TestCase
):
"""Tests enrolling and unenrolling in courses."""
...
...
common/djangoapps/track/tests.py
→
common/djangoapps/track/tests
/test_logs
.py
View file @
bd2f3c75
"""Tests
for student tracking
"""
"""Tests
that tracking data are successfully logged
"""
import
mock
import
unittest
from
django.test
import
TestCase
from
django.core.urlresolvers
import
reverse
,
NoReverseMatch
from
django.conf
import
settings
from
track.models
import
TrackingLog
from
track.views
import
user_track
from
nose.plugins.skip
import
SkipTest
@unittest.skipUnless
(
settings
.
ROOT_URLCONF
==
'lms.urls'
,
'Test only valid in lms'
)
class
TrackingTest
(
TestCase
):
"""
Tests that tracking logs correctly handle events
...
...
@@ -24,10 +26,7 @@ class TrackingTest(TestCase):
]
with
mock
.
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_SQL_TRACKING_LOGS'
:
True
}):
for
request_params
in
requests
:
try
:
# because /event maps to two different views in lms and cms, we're only going to test lms here
response
=
self
.
client
.
post
(
reverse
(
user_track
),
request_params
)
except
NoReverseMatch
:
raise
SkipTest
()
response
=
self
.
client
.
post
(
reverse
(
user_track
),
request_params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
'success'
)
tracking_logs
=
TrackingLog
.
objects
.
order_by
(
'-dtcreated'
)
...
...
@@ -47,10 +46,7 @@ class TrackingTest(TestCase):
]
with
mock
.
patch
.
dict
(
'django.conf.settings.FEATURES'
,
{
'ENABLE_SQL_TRACKING_LOGS'
:
True
}):
for
request_params
in
requests
:
try
:
# because /event maps to two different views in lms and cms, we're only going to test lms here
response
=
self
.
client
.
get
(
reverse
(
user_track
),
request_params
)
except
NoReverseMatch
:
raise
SkipTest
()
response
=
self
.
client
.
get
(
reverse
(
user_track
),
request_params
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
content
,
'success'
)
tracking_logs
=
TrackingLog
.
objects
.
order_by
(
'-dtcreated'
)
...
...
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