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
9d34767e
Commit
9d34767e
authored
Feb 01, 2013
by
Ned Batchelder
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix the remaining module storage tests.
parent
08acf435
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
lms/djangoapps/courseware/model_data.py
+3
-3
lms/djangoapps/courseware/tests/test_model_data.py
+3
-2
No files found.
lms/djangoapps/courseware/model_data.py
View file @
9d34767e
...
...
@@ -25,7 +25,7 @@ def chunks(items, chunk_size):
class
ModelDataCache
(
object
):
"""
A cache of django model objects needed to supply the data
for a module and its decend
e
nts
for a module and its decend
a
nts
"""
def
__init__
(
self
,
descriptors
,
course_id
,
user
,
select_for_update
=
False
):
'''
...
...
@@ -35,10 +35,10 @@ class ModelDataCache(object):
state will have a StudentModule.
Arguments
descriptors: A
n array
of XModuleDescriptors.
descriptors: A
list
of XModuleDescriptors.
course_id: The id of the current course
user: The user for which to cache data
select_for_update:
Flag indicating whether the
rows should be locked until end of transaction
select_for_update:
True if
rows should be locked until end of transaction
'''
self
.
cache
=
{}
self
.
descriptors
=
descriptors
...
...
lms/djangoapps/courseware/tests/test_model_data.py
View file @
9d34767e
...
...
@@ -131,7 +131,8 @@ class TestStudentModuleStorage(TestCase):
def
setUp
(
self
):
self
.
desc_md
=
{}
self
.
user
=
UserFactory
.
create
()
student_module
=
StudentModuleFactory
(
state
=
json
.
dumps
({
'a_field'
:
'a_value'
}))
self
.
user
=
student_module
.
student
self
.
mdc
=
ModelDataCache
([
mock_descriptor
([
mock_field
(
Scope
.
student_state
,
'a_field'
)])],
course_id
,
self
.
user
)
self
.
kvs
=
LmsKeyValueStore
(
self
.
desc_md
,
self
.
mdc
)
...
...
@@ -159,7 +160,7 @@ class TestStudentModuleStorage(TestCase):
"Test that deleting an existing field removes it from the StudentModule"
self
.
kvs
.
delete
(
student_state_key
(
'a_field'
))
self
.
assertEquals
(
1
,
StudentModule
.
objects
.
all
()
.
count
())
self
.
assert
Equals
({},
self
.
mdc
.
find
.
return_value
.
state
)
self
.
assert
Raises
(
KeyError
,
self
.
kvs
.
get
,
student_state_key
(
'not_a_field'
)
)
def
test_delete_missing_field
(
self
):
"Test that deleting a missing field from an existing StudentModule raises a KeyError"
...
...
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