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
6c602dee
Commit
6c602dee
authored
Sep 10, 2015
by
Dino Cikatic
Committed by
Nimisha Asthagiri
Oct 05, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! SplitTest.. Remove Include_schemes and add staff user tests
parent
d96fa776
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
38 deletions
+72
-38
lms/djangoapps/course_blocks/transformers/helpers.py
+1
-4
lms/djangoapps/course_blocks/transformers/tests/test_helpers.py
+32
-0
lms/djangoapps/course_blocks/transformers/tests/test_library_content.py
+11
-9
lms/djangoapps/course_blocks/transformers/tests/test_split_test.py
+14
-13
lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py
+14
-12
No files found.
lms/djangoapps/course_blocks/transformers/helpers.py
View file @
6c602dee
...
...
@@ -3,8 +3,7 @@ Transformers helpers functions.
"""
from
openedx.core.djangoapps.user_api.partition_schemes
import
RandomUserPartitionScheme
from
openedx.core.djangoapps.course_groups.partition_scheme
import
CohortPartitionScheme
# TODO 8874: Make it so we support all schemes instead of manually declaring them here.
INCLUDE_SCHEMES
=
[
CohortPartitionScheme
,
RandomUserPartitionScheme
,
]
SCHEME_SUPPORTS_ASSIGNMENT
=
[
RandomUserPartitionScheme
,
]
...
...
@@ -25,8 +24,6 @@ def get_user_partition_groups(course_key, user_partitions, user):
"""
partition_groups
=
{}
for
partition
in
user_partitions
:
if
partition
.
scheme
not
in
INCLUDE_SCHEMES
:
continue
group
=
partition
.
scheme
.
get_group_for_user
(
course_key
,
user
,
...
...
lms/djangoapps/course_blocks/transformers/tests/test_helpers.py
View file @
6c602dee
...
...
@@ -17,6 +17,16 @@ class CourseStructureTestCase(ModuleStoreTestCase):
"""
blocks
=
[]
def
setUp
(
self
):
"""
Create users.
"""
super
(
CourseStructureTestCase
,
self
)
.
setUp
()
# Set up users.
self
.
password
=
'test'
self
.
user
=
UserFactory
.
create
(
password
=
self
.
password
)
self
.
staff
=
UserFactory
.
create
(
password
=
self
.
password
,
is_staff
=
True
)
def
build_course
(
self
,
course_hierarchy
):
"""
Build a hierarchy of XBlocks.
...
...
@@ -87,6 +97,28 @@ class CourseStructureTestCase(ModuleStoreTestCase):
xblocks
=
(
self
.
blocks
[
ref
]
for
ref
in
refs
)
return
set
([
xblock
.
location
for
xblock
in
xblocks
])
def
assert_course_structure_staff_user
(
self
,
staff
,
course
,
blocks
,
transformer
):
"""
Assert course structure integrity if block structure has transformer applied
and is viewed by staff user.
"""
raw_block_structure
=
get_course_blocks
(
staff
,
course
.
location
,
transformers
=
{}
)
self
.
assertEqual
(
len
(
list
(
raw_block_structure
.
get_block_keys
())),
len
(
blocks
))
trans_block_structure
=
get_course_blocks
(
staff
,
course
.
location
,
transformers
=
{
transformer
}
)
self
.
assertEqual
(
len
(
list
(
raw_block_structure
.
get_block_keys
())),
len
(
list
(
trans_block_structure
.
get_block_keys
()))
)
class
BlockParentsMapTestCase
(
ModuleStoreTestCase
):
# Tree formed by parent_map:
...
...
lms/djangoapps/course_blocks/transformers/tests/test_library_content.py
View file @
6c602dee
...
...
@@ -2,7 +2,6 @@
Tests for ContentLibraryTransformer.
"""
import
mock
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
CourseEnrollmentFactory
from
course_blocks.transformers.library_content
import
ContentLibraryTransformer
...
...
@@ -33,20 +32,18 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase):
super
(
ContentLibraryTransformerTestCase
,
self
)
.
setUp
()
# Build course.
self
.
course_hierarchy
=
self
.
get_
test_
course_hierarchy
()
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
course
=
self
.
blocks
[
'course'
]
clear_course_from_cache
(
self
.
course
.
id
)
# Set up user and enroll in course.
self
.
password
=
'test'
self
.
user
=
UserFactory
.
create
(
password
=
self
.
password
)
# Enroll user in course.
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
self
.
selected_modules
=
[
MockedModules
(
'{"selected": [["vertical", "vertical_vertical2"]]}'
)]
self
.
transformer
=
[]
self
.
transformer
=
ContentLibraryTransformer
()
def
get_
test_
course_hierarchy
(
self
):
def
get_course_hierarchy
(
self
):
"""
Get a course hierarchy to test with.
"""
...
...
@@ -115,8 +112,6 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase):
and after that mock response from MySQL db.
Check user can see mocked sections in content library.
"""
self
.
transformer
=
ContentLibraryTransformer
()
raw_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
...
...
@@ -159,3 +154,10 @@ class ContentLibraryTransformerTestCase(CourseStructureTestCase):
'html1'
)
)
def
test_course_structure_with_staff_user
(
self
):
"""
Test course structure integrity if block structure has transformer applied
and is viewed by staff user.
"""
self
.
assert_course_structure_staff_user
(
self
.
staff
,
self
.
course
,
self
.
blocks
,
self
.
transformer
)
lms/djangoapps/course_blocks/transformers/tests/test_split_test.py
View file @
6c602dee
...
...
@@ -3,7 +3,6 @@ Tests for SplitTestTransformer.
"""
from
openedx.core.djangoapps.user_api.partition_schemes
import
RandomUserPartitionScheme
from
opaque_keys.edx.keys
import
CourseKey
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
CourseEnrollmentFactory
from
xmodule.modulestore.django
import
modulestore
from
xmodule.partitions.partitions
import
Group
,
UserPartition
...
...
@@ -38,18 +37,17 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
self
.
split_test_user_partition
.
scheme
.
name
=
"random"
# Build course.
self
.
course_hierarchy
=
self
.
get_
test_
course_hierarchy
()
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
course
=
self
.
blocks
[
'course'
]
clear_course_from_cache
(
self
.
course
.
id
)
# Set up user and enroll in course.
self
.
password
=
'test'
self
.
user
=
UserFactory
.
create
(
password
=
self
.
password
)
# Enroll user in course.
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
self
.
transformation
=
[]
self
.
transformer
=
SplitTestTransformer
()
def
get_
test_
course_hierarchy
(
self
):
def
get_course_hierarchy
(
self
):
"""
Get a course hierarchy to test with.
...
...
@@ -141,8 +139,6 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
Test course structure integrity if course has split test section
and user is not assigned to any group in user partition.
"""
self
.
transformation
=
SplitTestTransformer
()
# Add user to split test.
self
.
add_user_to_splittest_group
(
assign
=
False
)
...
...
@@ -157,7 +153,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
trans_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
transformers
=
{
self
.
transform
ation
}
transformers
=
{
self
.
transform
er
}
)
self
.
assertEqual
(
...
...
@@ -170,8 +166,6 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
Test course structure integrity if course has split test section
and user is assigned to any group in user partition.
"""
self
.
transformation
=
SplitTestTransformer
()
# Add user to split test.
self
.
add_user_to_splittest_group
()
...
...
@@ -186,7 +180,7 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
trans_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
transformers
=
{
self
.
transform
ation
}
transformers
=
{
self
.
transform
er
}
)
user_groups
=
get_user_partition_groups
(
...
...
@@ -219,3 +213,10 @@ class SplitTestTransformerTestCase(CourseStructureTestCase):
'html2'
)
)
def
test_course_structure_with_staff_user
(
self
):
"""
Test course structure integrity if block structure has transformer applied
and is viewed by staff user.
"""
self
.
assert_course_structure_staff_user
(
self
.
staff
,
self
.
course
,
self
.
blocks
,
self
.
transformer
)
lms/djangoapps/course_blocks/transformers/tests/test_user_partitions.py
View file @
6c602dee
...
...
@@ -6,7 +6,6 @@ from openedx.core.djangoapps.course_groups.partition_scheme import CohortPartiti
from
openedx.core.djangoapps.course_groups.tests.helpers
import
CohortFactory
,
config_course_cohorts
from
openedx.core.djangoapps.course_groups.cohorts
import
add_user_to_cohort
from
openedx.core.djangoapps.course_groups.views
import
link_cohort_to_partition_group
from
student.tests.factories
import
UserFactory
from
student.tests.factories
import
CourseEnrollmentFactory
from
xmodule.partitions.partitions
import
Group
,
UserPartition
...
...
@@ -36,31 +35,30 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
scheme
=
CohortPartitionScheme
)
self
.
user_partition
.
scheme
.
name
=
"cohort"
# Build course.
self
.
course_hierarchy
=
self
.
get_
test_
course_hierarchy
()
self
.
course_hierarchy
=
self
.
get_course_hierarchy
()
self
.
blocks
=
self
.
build_course
(
self
.
course_hierarchy
)
self
.
course
=
self
.
blocks
[
'course'
]
clear_course_from_cache
(
self
.
course
.
id
)
# Set up user and enroll in course.
self
.
password
=
'test'
self
.
user
=
UserFactory
.
create
(
password
=
self
.
password
)
# Enroll user in course.
CourseEnrollmentFactory
.
create
(
user
=
self
.
user
,
course_id
=
self
.
course
.
id
,
is_active
=
True
)
# Set up cohorts.
config_course_cohorts
(
self
.
course
,
is_cohorted
=
True
)
self
.
cohorts
=
[
CohortFactory
(
course_id
=
self
.
course
.
id
)
for
__
in
enumerate
(
self
.
groups
)]
self
.
add_user_to_cohort_group
(
self
.
cohorts
[
0
],
self
.
groups
[
0
])
self
.
transformer
=
UserPartitionTransformer
()
def
get_
test_
course_hierarchy
(
self
):
def
get_course_hierarchy
(
self
):
"""
Get a course hierarchy to test with.
Assumes self.user_partition has already been initialized.
"""
return
{
'org'
:
'UserPartitionTransform
ation
'
,
'org'
:
'UserPartitionTransform
er
'
,
'course'
:
'UP101F'
,
'run'
:
'test_run'
,
'user_partitions'
:
[
self
.
user_partition
],
...
...
@@ -116,8 +114,6 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
Test course structure integrity if course has user partition section
and user is assigned to group in user partition.
"""
self
.
transformation
=
UserPartitionTransformer
()
raw_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
...
...
@@ -125,13 +121,19 @@ class UserPartitionTransformerTestCase(CourseStructureTestCase):
)
self
.
assertEqual
(
len
(
list
(
raw_block_structure
.
get_block_keys
())),
len
(
self
.
blocks
))
clear_course_from_cache
(
self
.
course
.
id
)
trans_block_structure
=
get_course_blocks
(
self
.
user
,
self
.
course
.
location
,
transformers
=
{
self
.
transform
ation
}
transformers
=
{
self
.
transform
er
}
)
self
.
assertSetEqual
(
set
(
trans_block_structure
.
get_block_keys
()),
self
.
get_block_key_set
(
'course'
,
'chapter1'
,
'lesson1'
,
'vertical1'
,
'html2'
)
)
def
test_course_structure_with_staff_user
(
self
):
"""
Test course structure integrity if block structure has transformer applied
and is viewed by staff user.
"""
self
.
assert_course_structure_staff_user
(
self
.
staff
,
self
.
course
,
self
.
blocks
,
self
.
transformer
)
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