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
d0fea429
Commit
d0fea429
authored
Dec 30, 2013
by
Brian Wilson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for inherited metadata to test_dump_course, and move to commands/tests dir.
parent
4569ee9d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
2 deletions
+46
-2
lms/djangoapps/courseware/management/commands/tests/test_clean_history.py
+0
-0
lms/djangoapps/courseware/management/commands/tests/test_dump_course.py
+46
-2
No files found.
lms/djangoapps/courseware/management/tests/test_clean_history.py
→
lms/djangoapps/courseware/management/
commands/
tests/test_clean_history.py
View file @
d0fea429
File moved
lms/djangoapps/courseware/
tests/test_commands
.py
→
lms/djangoapps/courseware/
management/commands/tests/test_dump_course
.py
View file @
d0fea429
...
@@ -10,6 +10,7 @@ from path import path
...
@@ -10,6 +10,7 @@ from path import path
from
django.core.management
import
call_command
from
django.core.management
import
call_command
from
django.test.utils
import
override_settings
from
django.test.utils
import
override_settings
from
django.test.testcases
import
TestCase
from
courseware.tests.modulestore_config
import
TEST_DATA_XML_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_XML_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
from
courseware.tests.modulestore_config
import
TEST_DATA_MIXED_MODULESTORE
...
@@ -24,7 +25,7 @@ DATA_DIR = 'common/test/data/'
...
@@ -24,7 +25,7 @@ DATA_DIR = 'common/test/data/'
TEST_COURSE_ID
=
'edX/simple/2012_Fall'
TEST_COURSE_ID
=
'edX/simple/2012_Fall'
class
CommandsTestBase
(
object
):
class
CommandsTestBase
(
TestCase
):
"""
"""
Base class for testing different django commands.
Base class for testing different django commands.
...
@@ -66,6 +67,15 @@ class CommandsTestBase(object):
...
@@ -66,6 +67,15 @@ class CommandsTestBase(object):
dump
=
json
.
loads
(
output
)
dump
=
json
.
loads
(
output
)
# check that all elements in the course structure have metadata,
# but not inherited metadata:
for
element_name
in
dump
:
element
=
dump
[
element_name
]
self
.
assertIn
(
'metadata'
,
element
)
self
.
assertIn
(
'children'
,
element
)
self
.
assertIn
(
'category'
,
element
)
self
.
assertNotIn
(
'inherited_metadata'
,
element
)
# Check a few elements in the course dump
# Check a few elements in the course dump
parent_id
=
'i4x://edX/simple/chapter/Overview'
parent_id
=
'i4x://edX/simple/chapter/Overview'
...
@@ -81,10 +91,44 @@ class CommandsTestBase(object):
...
@@ -81,10 +91,44 @@ class CommandsTestBase(object):
self
.
assertEqual
(
len
(
dump
[
video_id
][
'metadata'
]),
4
)
self
.
assertEqual
(
len
(
dump
[
video_id
][
'metadata'
]),
4
)
self
.
assertIn
(
'youtube_id_1_0'
,
dump
[
video_id
][
'metadata'
])
self
.
assertIn
(
'youtube_id_1_0'
,
dump
[
video_id
][
'metadata'
])
# Check if there
is
the right number of elements
# Check if there
are
the right number of elements
self
.
assertEqual
(
len
(
dump
),
16
)
self
.
assertEqual
(
len
(
dump
),
16
)
def
test_dump_inherited_course_structure
(
self
):
args
=
[
TEST_COURSE_ID
]
kwargs
=
{
'modulestore'
:
'default'
,
'inherited'
:
True
}
output
=
self
.
call_command
(
'dump_course_structure'
,
*
args
,
**
kwargs
)
dump
=
json
.
loads
(
output
)
# check that all elements in the course structure have inherited metadata,
# and that it contains a particular value as well:
for
element_name
in
dump
:
element
=
dump
[
element_name
]
self
.
assertIn
(
'metadata'
,
element
)
self
.
assertIn
(
'children'
,
element
)
self
.
assertIn
(
'category'
,
element
)
self
.
assertIn
(
'inherited_metadata'
,
element
)
self
.
assertIsNone
(
element
[
'inherited_metadata'
][
'ispublic'
])
# ... but does not contain inherited metadata containing a default value:
self
.
assertNotIn
(
'due'
,
element
[
'inherited_metadata'
])
def
test_dump_inherited_course_structure_with_defaults
(
self
):
args
=
[
TEST_COURSE_ID
]
kwargs
=
{
'modulestore'
:
'default'
,
'inherited'
:
True
,
'inherited_defaults'
:
True
}
output
=
self
.
call_command
(
'dump_course_structure'
,
*
args
,
**
kwargs
)
dump
=
json
.
loads
(
output
)
# check that all elements in the course structure have inherited metadata,
# and that it contains a particular value as well:
for
element_name
in
dump
:
element
=
dump
[
element_name
]
self
.
assertIn
(
'metadata'
,
element
)
self
.
assertIn
(
'children'
,
element
)
self
.
assertIn
(
'category'
,
element
)
self
.
assertIn
(
'inherited_metadata'
,
element
)
self
.
assertIsNone
(
element
[
'inherited_metadata'
][
'ispublic'
])
# ... and contains inherited metadata containing a default value:
self
.
assertIsNone
(
element
[
'inherited_metadata'
][
'due'
])
def
test_export_course
(
self
):
def
test_export_course
(
self
):
tmp_dir
=
path
(
mkdtemp
())
tmp_dir
=
path
(
mkdtemp
())
filename
=
tmp_dir
/
'test.tar.gz'
filename
=
tmp_dir
/
'test.tar.gz'
...
...
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