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
2aaade0f
Commit
2aaade0f
authored
Sep 12, 2013
by
Julian Arni
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utility functions for finding courses by id
parent
3e62c5e2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
12 deletions
+21
-12
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
+21
-9
common/lib/xmodule/xmodule/tests/test_import.py
+0
-3
No files found.
common/lib/xmodule/xmodule/modulestore/tests/test_mongo.py
View file @
2aaade0f
...
@@ -2,6 +2,7 @@ from pprint import pprint
...
@@ -2,6 +2,7 @@ from pprint import pprint
# pylint: disable=E0611
# pylint: disable=E0611
from
nose.tools
import
assert_equals
,
assert_raises
,
\
from
nose.tools
import
assert_equals
,
assert_raises
,
\
assert_not_equals
,
assert_false
assert_not_equals
,
assert_false
from
itertools
import
ifilter
# pylint: enable=E0611
# pylint: enable=E0611
import
pymongo
import
pymongo
import
logging
import
logging
...
@@ -88,6 +89,19 @@ class TestMongoModuleStore(object):
...
@@ -88,6 +89,19 @@ class TestMongoModuleStore(object):
def
tearDown
(
self
):
def
tearDown
(
self
):
pass
pass
def
get_course_by_id
(
self
,
name
):
"""
Returns the first course with `id` of `name`, or `None` if there are none.
"""
courses
=
self
.
store
.
get_courses
()
return
next
(
ifilter
(
lambda
x
:
x
.
id
==
name
,
courses
),
None
)
def
course_with_id_exists
(
self
,
name
):
"""
Returns true iff there exists some course with `id` of `name`.
"""
return
(
self
.
get_course_by_id
(
name
)
is
not
None
)
def
test_init
(
self
):
def
test_init
(
self
):
'''Make sure the db loads, and print all the locations in the db.
'''Make sure the db loads, and print all the locations in the db.
Call this directly from failing tests to see what is loaded'''
Call this directly from failing tests to see what is loaded'''
...
@@ -103,13 +117,11 @@ class TestMongoModuleStore(object):
...
@@ -103,13 +117,11 @@ class TestMongoModuleStore(object):
'''Make sure the course objects loaded properly'''
'''Make sure the course objects loaded properly'''
courses
=
self
.
store
.
get_courses
()
courses
=
self
.
store
.
get_courses
()
assert_equals
(
len
(
courses
),
5
)
assert_equals
(
len
(
courses
),
5
)
courses
.
sort
(
key
=
lambda
c
:
c
.
id
)
assert
self
.
course_with_id_exists
(
'edX/simple/2012_Fall'
)
assert_equals
(
courses
[
0
]
.
id
,
'edX/simple/2012_Fall'
)
assert
self
.
course_with_id_exists
(
'edX/simple_with_draft/2012_Fall'
)
assert_equals
(
courses
[
1
]
.
id
,
'edX/simple_with_draft/2012_Fall'
)
assert
self
.
course_with_id_exists
(
'edX/test_import_course/2012_Fall'
)
assert_equals
(
courses
[
2
]
.
id
,
'edX/test_import_course/2012_Fall'
)
assert
self
.
course_with_id_exists
(
'edX/test_unicode/2012_Fall'
)
assert_equals
(
courses
[
3
]
.
id
,
'edX/test_unicode/2012_Fall'
)
assert
self
.
course_with_id_exists
(
'edX/toy/2012_Fall'
)
assert_equals
(
courses
[
4
]
.
id
,
'edX/toy/2012_Fall'
)
log
.
debug
(
str
(
courses
))
def
test_loads
(
self
):
def
test_loads
(
self
):
assert_not_equals
(
assert_not_equals
(
...
@@ -173,7 +185,6 @@ class TestMongoModuleStore(object):
...
@@ -173,7 +185,6 @@ class TestMongoModuleStore(object):
)
)
def
test_static_tab_names
(
self
):
def
test_static_tab_names
(
self
):
courses
=
self
.
store
.
get_courses
()
def
get_tab_name
(
index
):
def
get_tab_name
(
index
):
"""
"""
...
@@ -181,7 +192,8 @@ class TestMongoModuleStore(object):
...
@@ -181,7 +192,8 @@ class TestMongoModuleStore(object):
Assumes the information is desired for courses[4] ('toy' course).
Assumes the information is desired for courses[4] ('toy' course).
"""
"""
return
courses
[
4
]
.
tabs
[
index
][
'name'
]
course
=
self
.
get_course_by_id
(
'edX/toy/2012_Fall'
)
return
course
.
tabs
[
index
][
'name'
]
# There was a bug where model.save was not getting called after the static tab name
# There was a bug where model.save was not getting called after the static tab name
# was set set for tabs that have a URL slug. 'Syllabus' and 'Resources' fall into that
# was set set for tabs that have a URL slug. 'Syllabus' and 'Resources' fall into that
...
...
common/lib/xmodule/xmodule/tests/test_import.py
View file @
2aaade0f
...
@@ -394,9 +394,6 @@ class ImportTestCase(BaseCourseTestCase):
...
@@ -394,9 +394,6 @@ class ImportTestCase(BaseCourseTestCase):
chapters
=
course
.
get_children
()
chapters
=
course
.
get_children
()
self
.
assertEqual
(
len
(
chapters
),
3
)
self
.
assertEqual
(
len
(
chapters
),
3
)
ch3
=
chapters
[
2
]
def
test_url_name_mangling
(
self
):
def
test_url_name_mangling
(
self
):
"""
"""
Make sure that url_names are only mangled once.
Make sure that url_names are only mangled once.
...
...
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