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
6048bc28
Commit
6048bc28
authored
Mar 20, 2013
by
Jay Zoldak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pep8 fixes for factory refactor
parent
e45ccbf3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
53 additions
and
54 deletions
+53
-54
common/djangoapps/student/tests/factories.py
+6
-6
common/djangoapps/terrain/factories.py
+11
-11
lms/djangoapps/courseware/features/common.py
+8
-8
lms/djangoapps/courseware/features/courses.py
+4
-5
lms/djangoapps/courseware/features/problems.py
+21
-21
lms/djangoapps/courseware/features/smart-accordion.py
+3
-3
No files found.
common/djangoapps/student/tests/factories.py
View file @
6048bc28
from
student.models
import
(
User
,
UserProfile
,
Registration
,
from
student.models
import
(
User
,
UserProfile
,
Registration
,
CourseEnrollmentAllowed
,
CourseEnrollment
)
CourseEnrollmentAllowed
,
CourseEnrollment
)
from
django.contrib.auth.models
import
Group
from
django.contrib.auth.models
import
Group
from
datetime
import
datetime
from
datetime
import
datetime
...
@@ -101,10 +101,10 @@ class XModuleCourseFactory(Factory):
...
@@ -101,10 +101,10 @@ class XModuleCourseFactory(Factory):
new_course
.
lms
.
start
=
gmtime
()
new_course
.
lms
.
start
=
gmtime
()
new_course
.
tabs
=
[{
"type"
:
"courseware"
},
new_course
.
tabs
=
[{
"type"
:
"courseware"
},
{
"type"
:
"course_info"
,
"name"
:
"Course Info"
},
{
"type"
:
"course_info"
,
"name"
:
"Course Info"
},
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"discussion"
,
"name"
:
"Discussion"
},
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
},
{
"type"
:
"wiki"
,
"name"
:
"Wiki"
},
{
"type"
:
"progress"
,
"name"
:
"Progress"
}]
{
"type"
:
"progress"
,
"name"
:
"Progress"
}]
# Update the data in the mongo datastore
# Update the data in the mongo datastore
store
.
update_metadata
(
new_course
.
location
.
url
(),
own_metadata
(
new_course
))
store
.
update_metadata
(
new_course
.
location
.
url
(),
own_metadata
(
new_course
))
...
@@ -170,7 +170,7 @@ class XModuleItemFactory(Factory):
...
@@ -170,7 +170,7 @@ class XModuleItemFactory(Factory):
# If a display name is set, use that
# If a display name is set, use that
dest_name
=
display_name
.
replace
(
" "
,
"_"
)
if
display_name
is
not
None
else
uuid4
()
.
hex
dest_name
=
display_name
.
replace
(
" "
,
"_"
)
if
display_name
is
not
None
else
uuid4
()
.
hex
dest_location
=
parent_location
.
_replace
(
category
=
template
.
category
,
dest_location
=
parent_location
.
_replace
(
category
=
template
.
category
,
name
=
dest_name
)
name
=
dest_name
)
new_item
=
store
.
clone_item
(
template
,
dest_location
)
new_item
=
store
.
clone_item
(
template
,
dest_location
)
...
...
common/djangoapps/terrain/factories.py
View file @
6048bc28
from
student.tests.factories
import
(
UserFactory
,
UserProfileFactory
,
from
student.tests.factories
import
(
UserFactory
,
UserProfileFactory
,
RegistrationFactory
,
GroupFactory
,
RegistrationFactory
,
GroupFactory
,
CourseEnrollmentAllowed
,
CourseEnrollmentAllowed
,
CourseFactory
,
ItemFactory
)
CourseFactory
,
ItemFactory
)
from
lettuce
import
world
from
lettuce
import
world
...
@@ -9,7 +9,7 @@ from lettuce import world
...
@@ -9,7 +9,7 @@ from lettuce import world
class
UserFactory
(
UserFactory
):
class
UserFactory
(
UserFactory
):
"""
"""
User account for lms / cms
User account for lms / cms
"""
"""
pass
pass
...
@@ -17,7 +17,7 @@ class UserFactory(UserFactory):
...
@@ -17,7 +17,7 @@ class UserFactory(UserFactory):
class
UserProfileFactory
(
UserProfileFactory
):
class
UserProfileFactory
(
UserProfileFactory
):
"""
"""
Demographics etc for the User
Demographics etc for the User
"""
"""
pass
pass
...
@@ -25,7 +25,7 @@ class UserProfileFactory(UserProfileFactory):
...
@@ -25,7 +25,7 @@ class UserProfileFactory(UserProfileFactory):
class
RegistrationFactory
(
RegistrationFactory
):
class
RegistrationFactory
(
RegistrationFactory
):
"""
"""
Activation key for registering the user account
Activation key for registering the user account
"""
"""
pass
pass
...
@@ -33,7 +33,7 @@ class RegistrationFactory(RegistrationFactory):
...
@@ -33,7 +33,7 @@ class RegistrationFactory(RegistrationFactory):
class
GroupFactory
(
GroupFactory
):
class
GroupFactory
(
GroupFactory
):
"""
"""
Groups for user permissions for courses
Groups for user permissions for courses
"""
"""
pass
pass
...
@@ -41,7 +41,7 @@ class GroupFactory(GroupFactory):
...
@@ -41,7 +41,7 @@ class GroupFactory(GroupFactory):
class
CourseEnrollmentAllowedFactory
(
CourseEnrollmentAllowed
):
class
CourseEnrollmentAllowedFactory
(
CourseEnrollmentAllowed
):
"""
"""
Users allowed to enroll in the course outside of the usual window
Users allowed to enroll in the course outside of the usual window
"""
"""
pass
pass
...
@@ -49,13 +49,13 @@ class CourseEnrollmentAllowedFactory(CourseEnrollmentAllowed):
...
@@ -49,13 +49,13 @@ class CourseEnrollmentAllowedFactory(CourseEnrollmentAllowed):
class
CourseFactory
(
CourseFactory
):
class
CourseFactory
(
CourseFactory
):
"""
"""
Courseware courses
Courseware courses
"""
"""
pass
pass
@world.absorb
@world.absorb
class
ItemFactory
(
ItemFactory
):
class
ItemFactory
(
ItemFactory
):
"""
"""
Everything included inside a course
Everything included inside a course
"""
"""
pass
pass
lms/djangoapps/courseware/features/common.py
View file @
6048bc28
...
@@ -99,16 +99,16 @@ def create_course(step, course):
...
@@ -99,16 +99,16 @@ def create_course(step, course):
# We always use the same org and display name,
# We always use the same org and display name,
# but vary the course identifier (e.g. 600x or 191x)
# but vary the course identifier (e.g. 600x or 191x)
course
=
world
.
CourseFactory
.
create
(
org
=
TEST_COURSE_ORG
,
course
=
world
.
CourseFactory
.
create
(
org
=
TEST_COURSE_ORG
,
number
=
course
,
number
=
course
,
display_name
=
TEST_COURSE_NAME
)
display_name
=
TEST_COURSE_NAME
)
# Add a section to the course to contain problems
# Add a section to the course to contain problems
section
=
world
.
ItemFactory
.
create
(
parent_location
=
course
.
location
,
section
=
world
.
ItemFactory
.
create
(
parent_location
=
course
.
location
,
display_name
=
TEST_SECTION_NAME
)
display_name
=
TEST_SECTION_NAME
)
problem_section
=
world
.
ItemFactory
.
create
(
parent_location
=
section
.
location
,
problem_section
=
world
.
ItemFactory
.
create
(
parent_location
=
section
.
location
,
template
=
'i4x://edx/templates/sequential/Empty'
,
template
=
'i4x://edx/templates/sequential/Empty'
,
display_name
=
TEST_SECTION_NAME
)
display_name
=
TEST_SECTION_NAME
)
@step
(
u'I am registered for the course "([^"]*)"$'
)
@step
(
u'I am registered for the course "([^"]*)"$'
)
...
@@ -130,8 +130,8 @@ def i_am_registered_for_the_course(step, course):
...
@@ -130,8 +130,8 @@ def i_am_registered_for_the_course(step, course):
@step
(
u'The course "([^"]*)" has extra tab "([^"]*)"$'
)
@step
(
u'The course "([^"]*)" has extra tab "([^"]*)"$'
)
def
add_tab_to_course
(
step
,
course
,
extra_tab_name
):
def
add_tab_to_course
(
step
,
course
,
extra_tab_name
):
section_item
=
world
.
ItemFactory
.
create
(
parent_location
=
course_location
(
course
),
section_item
=
world
.
ItemFactory
.
create
(
parent_location
=
course_location
(
course
),
template
=
"i4x://edx/templates/static_tab/Empty"
,
template
=
"i4x://edx/templates/static_tab/Empty"
,
display_name
=
str
(
extra_tab_name
))
display_name
=
str
(
extra_tab_name
))
@step
(
u'I am an edX user$'
)
@step
(
u'I am an edX user$'
)
...
@@ -159,7 +159,7 @@ def flush_xmodule_store():
...
@@ -159,7 +159,7 @@ def flush_xmodule_store():
def
course_id
(
course_num
):
def
course_id
(
course_num
):
return
"
%
s/
%
s/
%
s"
%
(
TEST_COURSE_ORG
,
course_num
,
return
"
%
s/
%
s/
%
s"
%
(
TEST_COURSE_ORG
,
course_num
,
TEST_COURSE_NAME
.
replace
(
" "
,
"_"
))
TEST_COURSE_NAME
.
replace
(
" "
,
"_"
))
def
course_location
(
course_num
):
def
course_location
(
course_num
):
...
...
lms/djangoapps/courseware/features/courses.py
View file @
6048bc28
...
@@ -83,13 +83,13 @@ def get_courseware_with_tabs(course_id):
...
@@ -83,13 +83,13 @@ def get_courseware_with_tabs(course_id):
course
=
get_course_by_id
(
course_id
)
course
=
get_course_by_id
(
course_id
)
chapters
=
[
chapter
for
chapter
in
course
.
get_children
()
if
not
chapter
.
lms
.
hide_from_toc
]
chapters
=
[
chapter
for
chapter
in
course
.
get_children
()
if
not
chapter
.
lms
.
hide_from_toc
]
courseware
=
[{
'chapter_name'
:
c
.
display_name_with_default
,
courseware
=
[{
'chapter_name'
:
c
.
display_name_with_default
,
'sections'
:
[{
'section_name'
:
s
.
display_name_with_default
,
'sections'
:
[{
'section_name'
:
s
.
display_name_with_default
,
'clickable_tab_count'
:
len
(
s
.
get_children
())
if
(
type
(
s
)
==
seq_module
.
SequenceDescriptor
)
else
0
,
'clickable_tab_count'
:
len
(
s
.
get_children
())
if
(
type
(
s
)
==
seq_module
.
SequenceDescriptor
)
else
0
,
'tabs'
:
[{
'children_count'
:
len
(
t
.
get_children
())
if
(
type
(
t
)
==
vertical_module
.
VerticalDescriptor
)
else
0
,
'tabs'
:
[{
'children_count'
:
len
(
t
.
get_children
())
if
(
type
(
t
)
==
vertical_module
.
VerticalDescriptor
)
else
0
,
'class'
:
t
.
__class__
.
__name__
}
'class'
:
t
.
__class__
.
__name__
}
for
t
in
s
.
get_children
()]}
for
t
in
s
.
get_children
()]}
for
s
in
c
.
get_children
()
if
not
s
.
lms
.
hide_from_toc
]}
for
s
in
c
.
get_children
()
if
not
s
.
lms
.
hide_from_toc
]}
for
c
in
chapters
]
for
c
in
chapters
]
return
courseware
return
courseware
...
@@ -168,7 +168,6 @@ def process_section(element, num_tabs=0):
...
@@ -168,7 +168,6 @@ def process_section(element, num_tabs=0):
assert
False
,
"Class for element not recognized!!"
assert
False
,
"Class for element not recognized!!"
def
process_problem
(
element
,
problem_id
):
def
process_problem
(
element
,
problem_id
):
'''
'''
Process problem attempts to
Process problem attempts to
...
...
lms/djangoapps/courseware/features/problems.py
View file @
6048bc28
...
@@ -5,9 +5,9 @@ import random
...
@@ -5,9 +5,9 @@ import random
import
textwrap
import
textwrap
from
common
import
i_am_registered_for_the_course
,
TEST_SECTION_NAME
,
section_location
from
common
import
i_am_registered_for_the_course
,
TEST_SECTION_NAME
,
section_location
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactory
,
\
from
capa.tests.response_xml_factory
import
OptionResponseXMLFactory
,
\
ChoiceResponseXMLFactory
,
MultipleChoiceResponseXMLFactory
,
\
ChoiceResponseXMLFactory
,
MultipleChoiceResponseXMLFactory
,
\
StringResponseXMLFactory
,
NumericalResponseXMLFactory
,
\
StringResponseXMLFactory
,
NumericalResponseXMLFactory
,
\
FormulaResponseXMLFactory
,
CustomResponseXMLFactory
FormulaResponseXMLFactory
,
CustomResponseXMLFactory
# Factories from capa.tests.response_xml_factory that we will use
# Factories from capa.tests.response_xml_factory that we will use
# to generate the problem XML, with the keyword args used to configure
# to generate the problem XML, with the keyword args used to configure
...
@@ -77,7 +77,7 @@ PROBLEM_FACTORY_DICT = {
...
@@ -77,7 +77,7 @@ PROBLEM_FACTORY_DICT = {
a2=0
a2=0
return (a1+a2)==int(expect)
return (a1+a2)==int(expect)
"""
)}},
"""
)}},
}
}
def
add_problem_to_course
(
course
,
problem_type
):
def
add_problem_to_course
(
course
,
problem_type
):
...
@@ -92,10 +92,10 @@ def add_problem_to_course(course, problem_type):
...
@@ -92,10 +92,10 @@ def add_problem_to_course(course, problem_type):
# We set rerandomize=always in the metadata so that the "Reset" button
# We set rerandomize=always in the metadata so that the "Reset" button
# will appear.
# will appear.
problem_item
=
world
.
ItemFactory
.
create
(
parent_location
=
section_location
(
course
),
problem_item
=
world
.
ItemFactory
.
create
(
parent_location
=
section_location
(
course
),
template
=
"i4x://edx/templates/problem/Blank_Common_Problem"
,
template
=
"i4x://edx/templates/problem/Blank_Common_Problem"
,
display_name
=
str
(
problem_type
),
display_name
=
str
(
problem_type
),
data
=
problem_xml
,
data
=
problem_xml
,
metadata
=
{
'rerandomize'
:
'always'
})
metadata
=
{
'rerandomize'
:
'always'
})
@step
(
u'I am viewing a "([^"]*)" problem'
)
@step
(
u'I am viewing a "([^"]*)" problem'
)
...
@@ -201,21 +201,21 @@ def assert_answer_mark(step, problem_type, correctness):
...
@@ -201,21 +201,21 @@ def assert_answer_mark(step, problem_type, correctness):
# depending on whether the user selects an incorrect
# depending on whether the user selects an incorrect
# item or submits without selecting any item)
# item or submits without selecting any item)
correct_selectors
=
{
'drop down'
:
[
'span.correct'
],
correct_selectors
=
{
'drop down'
:
[
'span.correct'
],
'multiple choice'
:
[
'label.choicegroup_correct'
],
'multiple choice'
:
[
'label.choicegroup_correct'
],
'checkbox'
:
[
'span.correct'
],
'checkbox'
:
[
'span.correct'
],
'string'
:
[
'div.correct'
],
'string'
:
[
'div.correct'
],
'numerical'
:
[
'div.correct'
],
'numerical'
:
[
'div.correct'
],
'formula'
:
[
'div.correct'
],
'formula'
:
[
'div.correct'
],
'script'
:
[
'div.correct'
],
}
'script'
:
[
'div.correct'
],
}
incorrect_selectors
=
{
'drop down'
:
[
'span.incorrect'
],
incorrect_selectors
=
{
'drop down'
:
[
'span.incorrect'
],
'multiple choice'
:
[
'label.choicegroup_incorrect'
,
'multiple choice'
:
[
'label.choicegroup_incorrect'
,
'span.incorrect'
],
'span.incorrect'
],
'checkbox'
:
[
'span.incorrect'
],
'checkbox'
:
[
'span.incorrect'
],
'string'
:
[
'div.incorrect'
],
'string'
:
[
'div.incorrect'
],
'numerical'
:
[
'div.incorrect'
],
'numerical'
:
[
'div.incorrect'
],
'formula'
:
[
'div.incorrect'
],
'formula'
:
[
'div.incorrect'
],
'script'
:
[
'div.incorrect'
]}
'script'
:
[
'div.incorrect'
]}
assert
(
correctness
in
[
'correct'
,
'incorrect'
,
'unanswered'
])
assert
(
correctness
in
[
'correct'
,
'incorrect'
,
'unanswered'
])
assert
(
problem_type
in
correct_selectors
and
problem_type
in
incorrect_selectors
)
assert
(
problem_type
in
correct_selectors
and
problem_type
in
incorrect_selectors
)
...
@@ -257,7 +257,7 @@ def inputfield(problem_type, choice=None, input_num=1):
...
@@ -257,7 +257,7 @@ def inputfield(problem_type, choice=None, input_num=1):
of checkboxes. """
of checkboxes. """
sel
=
(
"input#input_i4x-edx-model_course-problem-
%
s_2_
%
s"
%
sel
=
(
"input#input_i4x-edx-model_course-problem-
%
s_2_
%
s"
%
(
problem_type
.
replace
(
" "
,
"_"
),
str
(
input_num
)))
(
problem_type
.
replace
(
" "
,
"_"
),
str
(
input_num
)))
if
choice
is
not
None
:
if
choice
is
not
None
:
base
=
"_choice_"
if
problem_type
==
"multiple choice"
else
"_"
base
=
"_choice_"
if
problem_type
==
"multiple choice"
else
"_"
...
...
lms/djangoapps/courseware/features/smart-accordion.py
View file @
6048bc28
...
@@ -81,7 +81,7 @@ def browse_course(course_id):
...
@@ -81,7 +81,7 @@ def browse_course(course_id):
num_rendered_sections
=
len
(
rendered_sections
)
num_rendered_sections
=
len
(
rendered_sections
)
msg
=
(
'
%
d sections expected,
%
d sections found on page,
%
s -
%
d -
%
s'
%
msg
=
(
'
%
d sections expected,
%
d sections found on page,
%
s -
%
d -
%
s'
%
(
num_sections
,
num_rendered_sections
,
course_id
,
chapter_it
,
chapters
[
chapter_it
][
'chapter_name'
]))
(
num_sections
,
num_rendered_sections
,
course_id
,
chapter_it
,
chapters
[
chapter_it
][
'chapter_name'
]))
#logger.debug(msg)
#logger.debug(msg)
assert
num_sections
==
num_rendered_sections
,
msg
assert
num_sections
==
num_rendered_sections
,
msg
...
@@ -112,7 +112,7 @@ def browse_course(course_id):
...
@@ -112,7 +112,7 @@ def browse_course(course_id):
num_rendered_tabs
=
0
num_rendered_tabs
=
0
msg
=
(
'
%
d tabs expected,
%
d tabs found,
%
s -
%
d -
%
s'
%
msg
=
(
'
%
d tabs expected,
%
d tabs found,
%
s -
%
d -
%
s'
%
(
num_tabs
,
num_rendered_tabs
,
course_id
,
section_it
,
sections
[
section_it
][
'section_name'
]))
(
num_tabs
,
num_rendered_tabs
,
course_id
,
section_it
,
sections
[
section_it
][
'section_name'
]))
#logger.debug(msg)
#logger.debug(msg)
# Save the HTML to a file for later comparison
# Save the HTML to a file for later comparison
...
@@ -137,7 +137,7 @@ def browse_course(course_id):
...
@@ -137,7 +137,7 @@ def browse_course(course_id):
rendered_items
=
world
.
browser
.
find_by_css
(
'div#seq_content > section > ol > li > section'
)
rendered_items
=
world
.
browser
.
find_by_css
(
'div#seq_content > section > ol > li > section'
)
num_rendered_items
=
len
(
rendered_items
)
num_rendered_items
=
len
(
rendered_items
)
msg
=
(
'
%
d items expected,
%
d items found,
%
s -
%
d -
%
s - tab
%
d'
%
msg
=
(
'
%
d items expected,
%
d items found,
%
s -
%
d -
%
s - tab
%
d'
%
(
tab_children
,
num_rendered_items
,
course_id
,
section_it
,
sections
[
section_it
][
'section_name'
],
tab_it
))
(
tab_children
,
num_rendered_items
,
course_id
,
section_it
,
sections
[
section_it
][
'section_name'
],
tab_it
))
#logger.debug(msg)
#logger.debug(msg)
assert
tab_children
==
num_rendered_items
,
msg
assert
tab_children
==
num_rendered_items
,
msg
...
...
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