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
8dd95a88
Commit
8dd95a88
authored
Sep 15, 2015
by
Adam Palay
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test for fix_not_found
(PLAT-835) (TNL-844)
parent
cf71f485
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
cms/djangoapps/contentstore/management/commands/tests/test_fix_not_found.py
+47
-0
No files found.
cms/djangoapps/contentstore/management/commands/tests/test_fix_not_found.py
0 → 100644
View file @
8dd95a88
"""
Tests for the fix_not_found management command
"""
from
django.core.management
import
call_command
from
xmodule.modulestore
import
ModuleStoreEnum
from
xmodule.modulestore.tests.django_utils
import
ModuleStoreTestCase
from
xmodule.modulestore.tests.factories
import
CourseFactory
,
ItemFactory
class
TestFixNotFound
(
ModuleStoreTestCase
):
"""
Tests for the fix_not_found management command
"""
def
test_fix_not_found_non_split
(
self
):
"""
The management command doesn't work on non split courses
"""
course
=
CourseFactory
(
default_store
=
ModuleStoreEnum
.
Type
.
mongo
)
with
self
.
assertRaises
(
SystemExit
):
call_command
(
"fix_not_found"
,
unicode
(
course
.
id
))
def
test_fix_not_found
(
self
):
course
=
CourseFactory
.
create
(
default_store
=
ModuleStoreEnum
.
Type
.
split
)
ItemFactory
.
create
(
category
=
'chapter'
,
parent_location
=
course
.
location
)
# get course again in order to update its children list
course
=
self
.
store
.
get_course
(
course
.
id
)
# create a dangling usage key that we'll add to the course's children list
dangling_pointer
=
course
.
id
.
make_usage_key
(
'chapter'
,
'DanglingPointer'
)
course
.
children
.
append
(
dangling_pointer
)
self
.
store
.
update_item
(
course
,
self
.
user
.
id
)
# the course block should now point to two children, one of which
# doesn't actually exist
self
.
assertEqual
(
len
(
course
.
children
),
2
)
self
.
assertIn
(
dangling_pointer
,
course
.
children
)
call_command
(
"fix_not_found"
,
unicode
(
course
.
id
))
# make sure the dangling pointer was removed from
# the course block's children
course
=
self
.
store
.
get_course
(
course
.
id
)
self
.
assertEqual
(
len
(
course
.
children
),
1
)
self
.
assertNotIn
(
dangling_pointer
,
course
.
children
)
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