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
583505b9
Commit
583505b9
authored
Jan 25, 2013
by
Deena Wang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_courses.py
parent
f9b0ec37
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
3 deletions
+41
-3
lms/djangoapps/courseware/tests/test_courses.py
+41
-3
No files found.
lms/djangoapps/courseware/tests/test_courses.py
View file @
583505b9
...
@@ -3,21 +3,59 @@ import datetime
...
@@ -3,21 +3,59 @@ import datetime
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
django.conf
import
settings
from
django.test.utils
import
override_settings
from
student.models
import
CourseEnrollment
from
student.models
import
CourseEnrollment
import
courseware.courses
as
courses
import
courseware.courses
as
courses
from
xmodule.modulestore.xml
import
XMLModuleStore
from
xmodule.modulestore.xml
import
XMLModuleStore
from
xmodule.modulestore.django
import
modulestore
def
xml_store_config
(
data_dir
):
return
{
'default'
:
{
'ENGINE'
:
'xmodule.modulestore.xml.XMLModuleStore'
,
'OPTIONS'
:
{
'data_dir'
:
data_dir
,
'default_class'
:
'xmodule.hidden_module.HiddenDescriptor'
,
}
}
}
TEST_DATA_DIR
=
settings
.
COMMON_TEST_DATA_ROOT
TEST_DATA_XML_MODULESTORE
=
xml_store_config
(
TEST_DATA_DIR
)
@override_settings
(
MODULESTORE
=
TEST_DATA_XML_MODULESTORE
)
class
CoursesTestCase
(
TestCase
):
class
CoursesTestCase
(
TestCase
):
def
setUp
(
self
):
def
setUp
(
self
):
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
self
.
user
=
User
.
objects
.
create
(
username
=
'dummy'
,
password
=
'123456'
,
email
=
'test@mit.edu'
)
email
=
'test@mit.edu'
)
self
.
date
=
datetime
.
datetime
(
2013
,
1
,
22
)
self
.
date
=
datetime
.
datetime
(
2013
,
1
,
22
)
self
.
course_id
=
'edx/toy/
Fall_2012
'
self
.
course_id
=
'edx/toy/
2012_Fall
'
self
.
enrollment
=
CourseEnrollment
.
objects
.
get_or_create
(
user
=
self
.
user
,
self
.
enrollment
=
CourseEnrollment
.
objects
.
get_or_create
(
user
=
self
.
user
,
course_id
=
self
.
course_id
,
course_id
=
self
.
course_id
,
created
=
self
.
date
)[
0
]
created
=
self
.
date
)[
0
]
self
.
xml_modulestore
=
XMLModuleStore
()
self
.
_MODULESTORES
=
{}
self
.
toy_course
=
modulestore
()
.
get_course
(
'edX/toy/2012_Fall'
)
def
test_get_course_by_id
(
self
):
def
test_get_course_by_id
(
self
):
courses
.
get_course_by_id
(
self
.
course_id
)
courses
.
get_course_by_id
(
"edx/toy/2012_Fall"
)
@override_settings
(
MODULESTORE
=
TEST_DATA_XML_MODULESTORE
)
class
CoursesTests
(
TestCase
):
def
setUp
(
self
):
self
.
_MODULESTORES
=
{}
self
.
course_name
=
'edX/toy/2012_Fall'
self
.
toy_course
=
modulestore
()
.
get_course
(
'edX/toy/2012_Fall'
)
self
.
fake_user
=
User
.
objects
.
create
(
is_superuser
=
True
)
'''
no test written for get_request_for_thread
'''
def
test_get_course_by_id
(
self
):
self
.
test_course_id
=
"edX/toy/2012_Fall"
# print modulestore().get_instance(test_course_id, Location('i4x', 'edx', 'toy', 'course', '2012_Fall'))
self
.
assertEqual
(
courses
.
get_course_by_id
(
self
.
test_course_id
),
modulestore
()
.
get_instance
(
self
.
test_course_id
,
Location
(
'i4x'
,
'edX'
,
'toy'
,
'course'
,
'2012_Fall'
),
None
))
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