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
b7c4ada9
Commit
b7c4ada9
authored
Sep 23, 2015
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! course_blocks unit tests
parent
a47f86e5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
29 additions
and
42 deletions
+29
-42
lms/djangoapps/course_blocks/api.py
+15
-9
lms/djangoapps/course_blocks/transformers/library_content.py
+3
-4
lms/djangoapps/course_blocks/transformers/tests/test_helpers.py
+0
-11
lms/djangoapps/course_blocks/transformers/tests/test_library_content.py
+0
-3
lms/djangoapps/course_blocks/transformers/tests/test_split_test.py
+10
-10
lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py
+0
-3
lms/djangoapps/course_blocks/transformers/user_partitions.py
+1
-2
No files found.
lms/djangoapps/course_blocks/api.py
View file @
b7c4ada9
...
@@ -23,26 +23,32 @@ LMS_COURSE_TRANSFORMERS = [
...
@@ -23,26 +23,32 @@ LMS_COURSE_TRANSFORMERS = [
]
]
_
cache
=
None
_
COURSE_BLOCKS_CACHE
=
None
def
_get_cache
():
def
_get_cache
():
global
_
cache
global
_
COURSE_BLOCKS_CACHE
if
not
_
cache
:
if
not
_
COURSE_BLOCKS_CACHE
:
_
cache
=
get_cache
(
'lms.course_blocks'
)
_
COURSE_BLOCKS_CACHE
=
get_cache
(
'lms.course_blocks'
)
return
_
cache
return
_
COURSE_BLOCKS_CACHE
def
get_course_blocks
(
def
get_course_blocks
(
user
,
user
,
root_usage_key
,
root_usage_key
=
None
,
transformers
=
LMS_COURSE_TRANSFORMERS
,
course_key
=
None
,
transformers
=
None
,
):
):
store
=
modulestore
()
if
transformers
is
None
:
if
transformers
is
None
:
transformers
=
LMS_COURSE_TRANSFORMERS
transformers
=
LMS_COURSE_TRANSFORMERS
if
root_usage_key
is
None
:
root_usage_key
=
store
.
make_course_usage_key
(
course_key
)
return
get_blocks
(
return
get_blocks
(
_get_cache
(),
modulestore
()
,
CourseUserInfo
(
root_usage_key
.
course_key
,
user
),
root_usage_key
,
transformers
,
_get_cache
(),
store
,
CourseUserInfo
(
root_usage_key
.
course_key
,
user
),
root_usage_key
,
transformers
,
)
)
...
...
lms/djangoapps/course_blocks/transformers/library_content.py
View file @
b7c4ada9
...
@@ -97,7 +97,6 @@ class ContentLibraryTransformer(BlockStructureTransformer):
...
@@ -97,7 +97,6 @@ class ContentLibraryTransformer(BlockStructureTransformer):
selected_children
.
append
(
usage_key
)
selected_children
.
append
(
usage_key
)
# Check and remove all non-selected children from course structure.
# Check and remove all non-selected children from course structure.
if
not
user_info
.
has_staff_access
:
block_structure
.
remove_block_if
(
block_structure
.
remove_block_if
(
check_child_removal
check_child_removal
)
)
lms/djangoapps/course_blocks/transformers/tests/test_helpers.py
View file @
b7c4ada9
...
@@ -160,17 +160,6 @@ class CourseStructureTestCase(ModuleStoreTestCase):
...
@@ -160,17 +160,6 @@ class CourseStructureTestCase(ModuleStoreTestCase):
xblocks
=
(
blocks
[
ref
]
for
ref
in
refs
)
xblocks
=
(
blocks
[
ref
]
for
ref
in
refs
)
return
set
([
xblock
.
location
for
xblock
in
xblocks
])
return
set
([
xblock
.
location
for
xblock
in
xblocks
])
def
assert_staff_access_to_all_blocks
(
self
,
course
,
blocks
,
transformer
):
"""
Assert staff users have access to all blocks
"""
trans_block_structure
=
get_course_blocks
(
self
.
staff
,
course
.
location
,
transformers
=
{
transformer
}
)
self
.
assertEqual
(
len
(
list
(
trans_block_structure
.
get_block_keys
())),
len
(
blocks
))
class
BlockParentsMapTestCase
(
ModuleStoreTestCase
):
class
BlockParentsMapTestCase
(
ModuleStoreTestCase
):
"""
"""
...
...
lms/djangoapps/course_blocks/transformers/tests/test_library_content.py
View file @
b7c4ada9
...
@@ -156,6 +156,3 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase):
...
@@ -156,6 +156,3 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase):
'html1'
'html1'
)
)
)
)
def
test_staff_user
(
self
):
self
.
assert_staff_access_to_all_blocks
(
self
.
course
,
self
.
blocks
,
self
.
transformer
)
lms/djangoapps/course_blocks/transformers/tests/test_split_test.py
View file @
b7c4ada9
...
@@ -214,13 +214,13 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
...
@@ -214,13 +214,13 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
self
.
course
.
location
,
self
.
course
.
location
,
transformers
=
{
self
.
transformer
},
transformers
=
{
self
.
transformer
},
)
)
# with check_mongo_calls(0): TODO - debug issue with pickling
with
check_mongo_calls
(
0
):
#
block_structure2 = get_course_blocks(
block_structure2
=
get_course_blocks
(
#
self.user,
self
.
user
,
#
self.course.location,
self
.
course
.
location
,
#
transformers={self.transformer},
transformers
=
{
self
.
transformer
},
#
)
)
#
self.assertEqual(
self
.
assertEqual
(
#
set(block_structure1.get_block_keys()),
set
(
block_structure1
.
get_block_keys
()),
#
set(block_structure2.get_block_keys()),
set
(
block_structure2
.
get_block_keys
()),
#
)
)
lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py
View file @
b7c4ada9
...
@@ -184,6 +184,3 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
...
@@ -184,6 +184,3 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
set
(
trans_block_structure
.
get_block_keys
()),
set
(
trans_block_structure
.
get_block_keys
()),
self
.
get_block_key_set
(
self
.
blocks
,
*
expected_blocks
)
self
.
get_block_key_set
(
self
.
blocks
,
*
expected_blocks
)
)
)
def
test_staff_user
(
self
):
self
.
assert_staff_access_to_all_blocks
(
self
.
course
,
self
.
blocks
,
self
.
transformer
)
lms/djangoapps/course_blocks/transformers/user_partitions.py
View file @
b7c4ada9
...
@@ -195,13 +195,12 @@ class UserPartitionTransformer(BlockStructureTransformer):
...
@@ -195,13 +195,12 @@ class UserPartitionTransformer(BlockStructureTransformer):
user_partitions
=
block_structure
.
get_transformer_data
(
self
,
'user_partitions'
)
user_partitions
=
block_structure
.
get_transformer_data
(
self
,
'user_partitions'
)
if
not
user_partitions
or
user_info
.
has_staff_access
:
if
not
user_partitions
:
return
return
user_groups
=
get_user_partition_groups
(
user_groups
=
get_user_partition_groups
(
user_info
.
course_key
,
user_partitions
,
user_info
.
user
user_info
.
course_key
,
user_partitions
,
user_info
.
user
)
)
# TODO test this when deserializing across processes
block_structure
.
remove_block_if
(
block_structure
.
remove_block_if
(
lambda
block_key
:
not
block_structure
.
get_transformer_block_data
(
lambda
block_key
:
not
block_structure
.
get_transformer_block_data
(
block_key
,
self
,
'merged_group_access'
block_key
,
self
,
'merged_group_access'
...
...
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