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
00dd3ad9
Commit
00dd3ad9
authored
Jan 25, 2013
by
Victor Shnayder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix some of the test bugs. Still more to fix.
parent
d453a613
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
192 deletions
+6
-192
common/djangoapps/student/tests.py
+2
-186
lms/djangoapps/django_comment_client/tests.py
+1
-5
lms/djangoapps/instructor/views.py
+3
-1
No files found.
common/djangoapps/student/tests.py
View file @
00dd3ad9
...
...
@@ -5,16 +5,11 @@ when you run "manage.py test".
Replace this with more appropriate tests for your application.
"""
import
logging
from
datetime
import
datetime
from
hashlib
import
sha1
from
django.test
import
TestCase
from
mock
import
patch
,
Mock
from
nose.plugins.skip
import
SkipTest
from
mock
import
Mock
from
.models
import
(
User
,
UserProfile
,
CourseEnrollment
,
replicate_user
,
USER_FIELDS_TO_COPY
,
unique_id_for_user
)
from
.models
import
unique_id_for_user
from
.views
import
process_survey_link
,
_cert_info
COURSE_1
=
'edX/toy/2012_Fall'
...
...
@@ -22,185 +17,6 @@ COURSE_2 = 'edx/full/6.002_Spring_2012'
log
=
logging
.
getLogger
(
__name__
)
class
ReplicationTest
(
TestCase
):
multi_db
=
True
def
test_user_replication
(
self
):
"""Test basic user replication."""
raise
SkipTest
()
portal_user
=
User
.
objects
.
create_user
(
'rusty'
,
'rusty@edx.org'
,
'fakepass'
)
portal_user
.
first_name
=
'Rusty'
portal_user
.
last_name
=
'Skids'
portal_user
.
is_staff
=
True
portal_user
.
is_active
=
True
portal_user
.
is_superuser
=
True
portal_user
.
last_login
=
datetime
(
2012
,
1
,
1
)
portal_user
.
date_joined
=
datetime
(
2011
,
1
,
1
)
# This is an Askbot field and will break if askbot is not included
if
hasattr
(
portal_user
,
'seen_response_count'
):
portal_user
.
seen_response_count
=
10
portal_user
.
save
(
using
=
'default'
)
# We replicate this user to Course 1, then pull the same user and verify
# that the fields copied over properly.
replicate_user
(
portal_user
,
COURSE_1
)
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
# Make sure the fields we care about got copied over for this user.
for
field
in
USER_FIELDS_TO_COPY
:
self
.
assertEqual
(
getattr
(
portal_user
,
field
),
getattr
(
course_user
,
field
),
"{0} not copied from {1} to {2}"
.
format
(
field
,
portal_user
,
course_user
))
# This hasattr lameness is here because we don't want this test to be
# triggered when we're being run by CMS tests (Askbot doesn't exist
# there, so the test will fail).
#
# seen_response_count isn't a field we care about, so it shouldn't have
# been copied over.
if
hasattr
(
portal_user
,
'seen_response_count'
):
portal_user
.
seen_response_count
=
20
replicate_user
(
portal_user
,
COURSE_1
)
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEqual
(
portal_user
.
seen_response_count
,
20
)
self
.
assertEqual
(
course_user
.
seen_response_count
,
0
)
# Another replication should work for an email change however, since
# it's a field we care about.
portal_user
.
email
=
"clyde@edx.org"
replicate_user
(
portal_user
,
COURSE_1
)
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEqual
(
portal_user
.
email
,
course_user
.
email
)
# During this entire time, the user data should never have made it over
# to COURSE_2
self
.
assertRaises
(
User
.
DoesNotExist
,
User
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_user
.
id
)
def
test_enrollment_for_existing_user_info
(
self
):
"""Test the effect of Enrolling in a class if you've already got user
data to be copied over."""
raise
SkipTest
()
# Create our User
portal_user
=
User
.
objects
.
create_user
(
'jack'
,
'jack@edx.org'
,
'fakepass'
)
portal_user
.
first_name
=
"Jack"
portal_user
.
save
()
# Set up our UserProfile info
portal_user_profile
=
UserProfile
.
objects
.
create
(
user
=
portal_user
,
name
=
"Jack Foo"
,
level_of_education
=
None
,
gender
=
'm'
,
mailing_address
=
None
,
goals
=
"World domination"
,
)
portal_user_profile
.
save
()
# Now let's see if creating a CourseEnrollment copies all the relevant
# data.
portal_enrollment
=
CourseEnrollment
.
objects
.
create
(
user
=
portal_user
,
course_id
=
COURSE_1
)
portal_enrollment
.
save
()
# Grab all the copies we expect
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEquals
(
portal_user
,
course_user
)
self
.
assertRaises
(
User
.
DoesNotExist
,
User
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_user
.
id
)
course_enrollment
=
CourseEnrollment
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_enrollment
.
id
)
self
.
assertEquals
(
portal_enrollment
,
course_enrollment
)
self
.
assertRaises
(
CourseEnrollment
.
DoesNotExist
,
CourseEnrollment
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_enrollment
.
id
)
course_user_profile
=
UserProfile
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user_profile
.
id
)
self
.
assertEquals
(
portal_user_profile
,
course_user_profile
)
self
.
assertRaises
(
UserProfile
.
DoesNotExist
,
UserProfile
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_user_profile
.
id
)
log
.
debug
(
"Make sure our seen_response_count is not replicated."
)
if
hasattr
(
portal_user
,
'seen_response_count'
):
portal_user
.
seen_response_count
=
200
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEqual
(
portal_user
.
seen_response_count
,
200
)
self
.
assertEqual
(
course_user
.
seen_response_count
,
0
)
portal_user
.
save
()
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEqual
(
portal_user
.
seen_response_count
,
200
)
self
.
assertEqual
(
course_user
.
seen_response_count
,
0
)
portal_user
.
email
=
'jim@edx.org'
portal_user
.
save
()
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEqual
(
portal_user
.
email
,
'jim@edx.org'
)
self
.
assertEqual
(
course_user
.
email
,
'jim@edx.org'
)
def
test_enrollment_for_user_info_after_enrollment
(
self
):
"""Test the effect of modifying User data after you've enrolled."""
raise
SkipTest
()
# Create our User
portal_user
=
User
.
objects
.
create_user
(
'patty'
,
'patty@edx.org'
,
'fakepass'
)
portal_user
.
first_name
=
"Patty"
portal_user
.
save
()
# Set up our UserProfile info
portal_user_profile
=
UserProfile
.
objects
.
create
(
user
=
portal_user
,
name
=
"Patty Foo"
,
level_of_education
=
None
,
gender
=
'f'
,
mailing_address
=
None
,
goals
=
"World peace"
,
)
portal_user_profile
.
save
()
# Now let's see if creating a CourseEnrollment copies all the relevant
# data when things are saved.
portal_enrollment
=
CourseEnrollment
.
objects
.
create
(
user
=
portal_user
,
course_id
=
COURSE_1
)
portal_enrollment
.
save
()
portal_user
.
last_name
=
"Bar"
portal_user
.
save
()
portal_user_profile
.
gender
=
'm'
portal_user_profile
.
save
()
# Grab all the copies we expect, and make sure it doesn't end up in
# places we don't expect.
course_user
=
User
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user
.
id
)
self
.
assertEquals
(
portal_user
,
course_user
)
self
.
assertRaises
(
User
.
DoesNotExist
,
User
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_user
.
id
)
course_enrollment
=
CourseEnrollment
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_enrollment
.
id
)
self
.
assertEquals
(
portal_enrollment
,
course_enrollment
)
self
.
assertRaises
(
CourseEnrollment
.
DoesNotExist
,
CourseEnrollment
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_enrollment
.
id
)
course_user_profile
=
UserProfile
.
objects
.
using
(
COURSE_1
)
.
get
(
id
=
portal_user_profile
.
id
)
self
.
assertEquals
(
portal_user_profile
,
course_user_profile
)
self
.
assertRaises
(
UserProfile
.
DoesNotExist
,
UserProfile
.
objects
.
using
(
COURSE_2
)
.
get
,
id
=
portal_user_profile
.
id
)
class
CourseEndingTest
(
TestCase
):
"""Test things related to course endings: certificates, surveys, etc"""
...
...
lms/djangoapps/django_comment_client/tests.py
View file @
00dd3ad9
...
...
@@ -10,11 +10,7 @@ from override_settings import override_settings
import
xmodule.modulestore.django
from
student.models
import
CourseEnrollment
,
\
replicate_enrollment_save
,
\
replicate_enrollment_delete
,
\
update_user_information
,
\
replicate_user_save
from
student.models
import
CourseEnrollment
from
django.db.models.signals
import
m2m_changed
,
pre_delete
,
pre_save
,
post_delete
,
post_save
from
django.dispatch.dispatcher
import
_make_id
...
...
lms/djangoapps/instructor/views.py
View file @
00dd3ad9
...
...
@@ -31,7 +31,6 @@ from django_comment_client.models import (Role,
FORUM_ROLE_COMMUNITY_TA
)
from
django_comment_client.utils
import
has_forum_access
from
psychometrics
import
psychoanalyze
from
string_util
import
split_by_comma_and_whitespace
from
student.models
import
CourseEnrollment
,
CourseEnrollmentAllowed
from
xmodule.course_module
import
CourseDescriptor
from
xmodule.modulestore
import
Location
...
...
@@ -50,6 +49,9 @@ template_imports = {'urllib': urllib}
FORUM_ROLE_ADD
=
'add'
FORUM_ROLE_REMOVE
=
'remove'
def
split_by_comma_and_whitespace
(
s
):
return
re
.
split
(
r'[\s,]'
,
s
)
@ensure_csrf_cookie
@cache_control
(
no_cache
=
True
,
no_store
=
True
,
must_revalidate
=
True
)
def
instructor_dashboard
(
request
,
course_id
):
...
...
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