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
5fb30f33
Commit
5fb30f33
authored
Jan 26, 2015
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up test to work with split modulestore.
Get updated xblocks from modulestore before checking properties.
parent
29e23521
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
26 deletions
+41
-26
lms/djangoapps/courseware/tests/test_group_access.py
+41
-26
No files found.
lms/djangoapps/courseware/tests/test_group_access.py
View file @
5fb30f33
...
@@ -64,13 +64,22 @@ class GroupAccessTestCase(ModuleStoreTestCase):
...
@@ -64,13 +64,22 @@ class GroupAccessTestCase(ModuleStoreTestCase):
"""
"""
partition
.
scheme
.
set_group_for_user
(
user
,
partition
,
group
)
partition
.
scheme
.
set_group_for_user
(
user
,
partition
,
group
)
def
set_group_access
(
self
,
block
,
access_dict
):
def
set_group_access
(
self
,
block
_location
,
access_dict
):
"""
"""
DRY helper
.
Set group_access on block specified by location
.
"""
"""
block
=
modulestore
()
.
get_item
(
block_location
)
block
.
group_access
=
access_dict
block
.
group_access
=
access_dict
modulestore
()
.
update_item
(
block
,
1
)
modulestore
()
.
update_item
(
block
,
1
)
def
set_user_partitions
(
self
,
block_location
,
partitions
):
"""
Sets the user_partitions on block specified by location.
"""
block
=
modulestore
()
.
get_item
(
block_location
)
block
.
user_partitions
=
partitions
modulestore
()
.
update_item
(
block
,
1
)
def
setUp
(
self
):
def
setUp
(
self
):
super
(
GroupAccessTestCase
,
self
)
.
setUp
()
super
(
GroupAccessTestCase
,
self
)
.
setUp
()
...
@@ -117,10 +126,15 @@ class GroupAccessTestCase(ModuleStoreTestCase):
...
@@ -117,10 +126,15 @@ class GroupAccessTestCase(ModuleStoreTestCase):
self
.
course
=
CourseFactory
.
create
(
self
.
course
=
CourseFactory
.
create
(
user_partitions
=
[
self
.
animal_partition
,
self
.
color_partition
],
user_partitions
=
[
self
.
animal_partition
,
self
.
color_partition
],
)
)
self
.
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent
=
self
.
course
)
chapter
=
ItemFactory
.
create
(
category
=
'chapter'
,
parent
=
self
.
course
)
self
.
section
=
ItemFactory
.
create
(
category
=
'sequential'
,
parent
=
self
.
chapter
)
section
=
ItemFactory
.
create
(
category
=
'sequential'
,
parent
=
chapter
)
self
.
vertical
=
ItemFactory
.
create
(
category
=
'vertical'
,
parent
=
self
.
section
)
vertical
=
ItemFactory
.
create
(
category
=
'vertical'
,
parent
=
section
)
self
.
component
=
ItemFactory
.
create
(
category
=
'problem'
,
parent
=
self
.
vertical
)
component
=
ItemFactory
.
create
(
category
=
'problem'
,
parent
=
vertical
)
self
.
chapter_location
=
chapter
.
location
self
.
section_location
=
section
.
location
self
.
vertical_location
=
vertical
.
location
self
.
component_location
=
component
.
location
self
.
red_cat
=
UserFactory
()
# student in red and cat groups
self
.
red_cat
=
UserFactory
()
# student in red and cat groups
self
.
set_user_group
(
self
.
red_cat
,
self
.
animal_partition
,
self
.
cat_group
)
self
.
set_user_group
(
self
.
red_cat
,
self
.
animal_partition
,
self
.
cat_group
)
...
@@ -145,15 +159,15 @@ class GroupAccessTestCase(ModuleStoreTestCase):
...
@@ -145,15 +159,15 @@ class GroupAccessTestCase(ModuleStoreTestCase):
# avoid repeatedly declaring the same sequence for ddt in all the test cases.
# avoid repeatedly declaring the same sequence for ddt in all the test cases.
PARENT_CHILD_PAIRS
=
(
PARENT_CHILD_PAIRS
=
(
(
'chapter
'
,
'chapter
'
),
(
'chapter
_location'
,
'chapter_location
'
),
(
'chapter
'
,
'sec
tion'
),
(
'chapter
_location'
,
'section_loca
tion'
),
(
'chapter
'
,
'vertical
'
),
(
'chapter
_location'
,
'vertical_location
'
),
(
'chapter
'
,
'component
'
),
(
'chapter
_location'
,
'component_location
'
),
(
'section
'
,
'sec
tion'
),
(
'section
_location'
,
'section_loca
tion'
),
(
'section
'
,
'vertical
'
),
(
'section
_location'
,
'vertical_location
'
),
(
'section
'
,
'component
'
),
(
'section
_location'
,
'component_location
'
),
(
'vertical
'
,
'vertical
'
),
(
'vertical
_location'
,
'vertical_location
'
),
(
'vertical
'
,
'component
'
),
(
'vertical
_location'
,
'component_location
'
),
)
)
def
tearDown
(
self
):
def
tearDown
(
self
):
...
@@ -163,19 +177,20 @@ class GroupAccessTestCase(ModuleStoreTestCase):
...
@@ -163,19 +177,20 @@ class GroupAccessTestCase(ModuleStoreTestCase):
"""
"""
UserPartition
.
scheme_extensions
=
None
UserPartition
.
scheme_extensions
=
None
def
check_access
(
self
,
user
,
block
,
is_accessible
):
def
check_access
(
self
,
user
,
block
_location
,
is_accessible
):
"""
"""
DRY helper.
DRY helper.
"""
"""
self
.
assertIs
(
self
.
assertIs
(
access
.
has_access
(
user
,
'load'
,
block
,
self
.
course
.
id
),
access
.
has_access
(
user
,
'load'
,
modulestore
()
.
get_item
(
block_location
)
,
self
.
course
.
id
),
is_accessible
is_accessible
)
)
def
ensure_staff_access
(
self
,
block
):
def
ensure_staff_access
(
self
,
block
_location
):
"""
"""
Another DRY helper.
Another DRY helper.
"""
"""
block
=
modulestore
()
.
get_item
(
block_location
)
self
.
assertTrue
(
access
.
has_access
(
self
.
staff
,
'load'
,
block
,
self
.
course
.
id
))
self
.
assertTrue
(
access
.
has_access
(
self
.
staff
,
'load'
,
block
,
self
.
course
.
id
))
# NOTE: in all the tests that follow, `block_specified` and
# NOTE: in all the tests that follow, `block_specified` and
...
@@ -396,12 +411,12 @@ class GroupAccessTestCase(ModuleStoreTestCase):
...
@@ -396,12 +411,12 @@ class GroupAccessTestCase(ModuleStoreTestCase):
except user_partitions in use by the split_test module.
except user_partitions in use by the split_test module.
"""
"""
# Initially, "red_cat" user can't view the vertical.
# Initially, "red_cat" user can't view the vertical.
self
.
set_group_access
(
self
.
chapter
,
{
self
.
animal_partition
.
id
:
[
self
.
dog_group
.
id
]})
self
.
set_group_access
(
self
.
chapter
_location
,
{
self
.
animal_partition
.
id
:
[
self
.
dog_group
.
id
]})
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
,
False
)
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
_location
,
False
)
# Change the vertical's user_partitions value to the empty list. Now red_cat can view the vertical.
# Change the vertical's user_partitions value to the empty list. Now red_cat can view the vertical.
self
.
vertical
.
user_partitions
=
[]
self
.
set_user_partitions
(
self
.
vertical_location
,
[])
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
,
True
)
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
_location
,
True
)
# Change the vertical's user_partitions value to include only "split_test" partitions.
# Change the vertical's user_partitions value to include only "split_test" partitions.
split_test_partition
=
UserPartition
(
split_test_partition
=
UserPartition
(
...
@@ -411,9 +426,9 @@ class GroupAccessTestCase(ModuleStoreTestCase):
...
@@ -411,9 +426,9 @@ class GroupAccessTestCase(ModuleStoreTestCase):
[
Group
(
2
,
'random group'
)],
[
Group
(
2
,
'random group'
)],
scheme
=
UserPartition
.
get_scheme
(
"random"
),
scheme
=
UserPartition
.
get_scheme
(
"random"
),
)
)
self
.
vertical
.
user_partitions
=
[
split_test_partition
]
self
.
set_user_partitions
(
self
.
vertical_location
,
[
split_test_partition
])
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
,
True
)
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
_location
,
True
)
# Finally, add back in a cohort user_partition
# Finally, add back in a cohort user_partition
self
.
vertical
.
user_partitions
=
[
split_test_partition
,
self
.
animal_partition
]
self
.
set_user_partitions
(
self
.
vertical_location
,
[
split_test_partition
,
self
.
animal_partition
])
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
,
False
)
self
.
check_access
(
self
.
red_cat
,
self
.
vertical
_location
,
False
)
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