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
660bc8f4
Commit
660bc8f4
authored
Sep 09, 2016
by
Nimisha Asthagiri
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable Persistent Grades in unit tests
parent
2251097c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
43 deletions
+47
-43
lms/djangoapps/grades/config/models.py
+3
-0
lms/djangoapps/grades/config/tests/test_models.py
+9
-10
lms/djangoapps/grades/tests/test_new.py
+30
-33
lms/djangoapps/grades/tests/test_signals.py
+2
-0
lms/envs/test.py
+3
-0
No files found.
lms/djangoapps/grades/config/models.py
View file @
660bc8f4
...
@@ -3,6 +3,7 @@ Models for configuration of the feature flags
...
@@ -3,6 +3,7 @@ Models for configuration of the feature flags
controlling persistent grades.
controlling persistent grades.
"""
"""
from
config_models.models
import
ConfigurationModel
from
config_models.models
import
ConfigurationModel
from
django.conf
import
settings
from
django.db.models
import
BooleanField
from
django.db.models
import
BooleanField
from
xmodule_django.models
import
CourseKeyField
from
xmodule_django.models
import
CourseKeyField
...
@@ -29,6 +30,8 @@ class PersistentGradesEnabledFlag(ConfigurationModel):
...
@@ -29,6 +30,8 @@ class PersistentGradesEnabledFlag(ConfigurationModel):
If the flag is enabled and no course ID is given,
If the flag is enabled and no course ID is given,
we return True since the global setting is enabled.
we return True since the global setting is enabled.
"""
"""
if
settings
.
FEATURES
.
get
(
'PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'
):
return
True
if
not
PersistentGradesEnabledFlag
.
is_enabled
():
if
not
PersistentGradesEnabledFlag
.
is_enabled
():
return
False
return
False
elif
not
PersistentGradesEnabledFlag
.
current
()
.
enabled_for_all_courses
and
course_id
:
elif
not
PersistentGradesEnabledFlag
.
current
()
.
enabled_for_all_courses
and
course_id
:
...
...
lms/djangoapps/grades/config/tests/test_models.py
View file @
660bc8f4
...
@@ -3,6 +3,9 @@ Tests for the models that control the
...
@@ -3,6 +3,9 @@ Tests for the models that control the
persistent grading feature.
persistent grading feature.
"""
"""
import
ddt
import
ddt
from
django.conf
import
settings
import
itertools
from
mock
import
patch
from
django.test
import
TestCase
from
django.test
import
TestCase
from
opaque_keys.edx.locator
import
CourseLocator
from
opaque_keys.edx.locator
import
CourseLocator
...
@@ -10,6 +13,7 @@ from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag
...
@@ -10,6 +13,7 @@ from lms.djangoapps.grades.config.models import PersistentGradesEnabledFlag
from
lms.djangoapps.grades.config.tests.utils
import
persistent_grades_feature_flags
from
lms.djangoapps.grades.config.tests.utils
import
persistent_grades_feature_flags
@patch.dict
(
settings
.
FEATURES
,
{
'PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'
:
False
})
@ddt.ddt
@ddt.ddt
class
PersistentGradesFeatureFlagTests
(
TestCase
):
class
PersistentGradesFeatureFlagTests
(
TestCase
):
"""
"""
...
@@ -21,16 +25,11 @@ class PersistentGradesFeatureFlagTests(TestCase):
...
@@ -21,16 +25,11 @@ class PersistentGradesFeatureFlagTests(TestCase):
self
.
course_id_1
=
CourseLocator
(
org
=
"edx"
,
course
=
"course"
,
run
=
"run"
)
self
.
course_id_1
=
CourseLocator
(
org
=
"edx"
,
course
=
"course"
,
run
=
"run"
)
self
.
course_id_2
=
CourseLocator
(
org
=
"edx"
,
course
=
"course2"
,
run
=
"run"
)
self
.
course_id_2
=
CourseLocator
(
org
=
"edx"
,
course
=
"course2"
,
run
=
"run"
)
@ddt.data
(
@ddt.data
(
*
itertools
.
product
(
(
True
,
True
,
True
),
(
True
,
False
),
(
True
,
True
,
False
),
(
True
,
False
),
(
True
,
False
,
True
),
(
True
,
False
),
(
True
,
False
,
False
),
))
(
False
,
True
,
True
),
(
False
,
False
,
True
),
(
False
,
True
,
False
),
(
False
,
False
,
False
),
)
@ddt.unpack
@ddt.unpack
def
test_persistent_grades_feature_flags
(
self
,
global_flag
,
enabled_for_all_courses
,
enabled_for_course_1
):
def
test_persistent_grades_feature_flags
(
self
,
global_flag
,
enabled_for_all_courses
,
enabled_for_course_1
):
with
persistent_grades_feature_flags
(
with
persistent_grades_feature_flags
(
...
...
lms/djangoapps/grades/tests/test_new.py
View file @
660bc8f4
...
@@ -3,6 +3,7 @@ Test saved subsection grade functionality.
...
@@ -3,6 +3,7 @@ Test saved subsection grade functionality.
"""
"""
import
ddt
import
ddt
from
django.conf
import
settings
from
mock
import
patch
from
mock
import
patch
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
from
capa.tests.response_xml_factory
import
MultipleChoiceResponseXMLFactory
...
@@ -71,6 +72,7 @@ class TestCourseGradeFactory(GradeTestBase):
...
@@ -71,6 +72,7 @@ class TestCourseGradeFactory(GradeTestBase):
Test that CourseGrades are calculated properly
Test that CourseGrades are calculated properly
"""
"""
@patch.dict
(
settings
.
FEATURES
,
{
'PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'
:
False
})
@ddt.data
(
@ddt.data
(
(
True
,
True
),
(
True
,
True
),
(
True
,
False
),
(
True
,
False
),
...
@@ -107,44 +109,39 @@ class SubsectionGradeFactoryTest(GradeTestBase):
...
@@ -107,44 +109,39 @@ class SubsectionGradeFactoryTest(GradeTestBase):
"""
"""
Tests to ensure that a persistent subsection grade is created, saved, then fetched on re-request.
Tests to ensure that a persistent subsection grade is created, saved, then fetched on re-request.
"""
"""
with
persistent_grades_feature_flags
(
with
patch
(
global_flag
=
True
,
'lms.djangoapps.grades.new.subsection_grade.SubsectionGradeFactory._save_grade'
,
enabled_for_all_courses
=
False
,
wraps
=
self
.
subsection_grade_factory
.
_save_grade
# pylint: disable=protected-access
course_id
=
self
.
course
.
id
,
)
as
mock_save_grades
:
enabled_for_course
=
True
):
with
patch
(
with
patch
(
'lms.djangoapps.grades.new.subsection_grade.SubsectionGradeFactory._save_grade'
,
'lms.djangoapps.grades.new.subsection_grade.SubsectionGradeFactory._get_saved_grade'
,
wraps
=
self
.
subsection_grade_factory
.
_save_grade
# pylint: disable=protected-access
wraps
=
self
.
subsection_grade_factory
.
_get_saved_grade
# pylint: disable=protected-access
)
as
mock_save_grades
:
)
as
mock_get_saved_grade
:
with
patch
(
with
self
.
assertNumQueries
(
19
):
'lms.djangoapps.grades.new.subsection_grade.SubsectionGradeFactory._get_saved_grade'
,
grade_a
=
self
.
subsection_grade_factory
.
create
(
wraps
=
self
.
subsection_grade_factory
.
_get_saved_grade
# pylint: disable=protected-access
self
.
sequence
,
)
as
mock_get_saved_grade
:
self
.
course_structure
,
with
self
.
assertNumQueries
(
22
):
self
.
course
grade_a
=
self
.
subsection_grade_factory
.
create
(
)
self
.
sequence
,
self
.
assertTrue
(
mock_get_saved_grade
.
called
)
self
.
course_structure
,
self
.
assertTrue
(
mock_save_grades
.
called
)
self
.
course
)
mock_get_saved_grade
.
reset_mock
()
self
.
assertTrue
(
mock_get_saved_grade
.
called
)
mock_save_grades
.
reset_mock
()
self
.
assertTrue
(
mock_save_grades
.
called
)
with
self
.
assertNumQueries
(
3
):
mock_get_saved_grade
.
reset_mock
()
grade_b
=
self
.
subsection_grade_factory
.
create
(
mock_save_grades
.
reset_mock
()
self
.
sequence
,
self
.
course_structure
,
with
self
.
assertNumQueries
(
4
):
self
.
course
grade_b
=
self
.
subsection_grade_factory
.
create
(
)
self
.
sequence
,
self
.
assertTrue
(
mock_get_saved_grade
.
called
)
self
.
course_structure
,
self
.
assertFalse
(
mock_save_grades
.
called
)
self
.
course
)
self
.
assertTrue
(
mock_get_saved_grade
.
called
)
self
.
assertFalse
(
mock_save_grades
.
called
)
self
.
assertEqual
(
grade_a
.
url_name
,
grade_b
.
url_name
)
self
.
assertEqual
(
grade_a
.
url_name
,
grade_b
.
url_name
)
self
.
assertEqual
(
grade_a
.
all_total
,
grade_b
.
all_total
)
self
.
assertEqual
(
grade_a
.
all_total
,
grade_b
.
all_total
)
@patch.dict
(
settings
.
FEATURES
,
{
'PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'
:
False
})
@ddt.data
(
@ddt.data
(
(
True
,
True
),
(
True
,
True
),
(
True
,
False
),
(
True
,
False
),
...
...
lms/djangoapps/grades/tests/test_signals.py
View file @
660bc8f4
...
@@ -3,6 +3,7 @@ Tests for the score change signals defined in the courseware models module.
...
@@ -3,6 +3,7 @@ Tests for the score change signals defined in the courseware models module.
"""
"""
import
ddt
import
ddt
from
django.conf
import
settings
from
django.test
import
TestCase
from
django.test
import
TestCase
from
mock
import
patch
,
MagicMock
from
mock
import
patch
,
MagicMock
from
unittest
import
skip
from
unittest
import
skip
...
@@ -169,6 +170,7 @@ class SubmissionSignalRelayTest(TestCase):
...
@@ -169,6 +170,7 @@ class SubmissionSignalRelayTest(TestCase):
self
.
signal_mock
.
assert_not_called
()
self
.
signal_mock
.
assert_not_called
()
@patch.dict
(
settings
.
FEATURES
,
{
'PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'
:
False
})
@ddt.ddt
@ddt.ddt
class
ScoreChangedUpdatesSubsectionGradeTest
(
ModuleStoreTestCase
):
class
ScoreChangedUpdatesSubsectionGradeTest
(
ModuleStoreTestCase
):
"""
"""
...
...
lms/envs/test.py
View file @
660bc8f4
...
@@ -298,6 +298,9 @@ OIDC_COURSE_HANDLER_CACHE_TIMEOUT = 0
...
@@ -298,6 +298,9 @@ OIDC_COURSE_HANDLER_CACHE_TIMEOUT = 0
FEATURES
[
'ENABLE_MOBILE_REST_API'
]
=
True
FEATURES
[
'ENABLE_MOBILE_REST_API'
]
=
True
FEATURES
[
'ENABLE_VIDEO_ABSTRACTION_LAYER_API'
]
=
True
FEATURES
[
'ENABLE_VIDEO_ABSTRACTION_LAYER_API'
]
=
True
########################### Grades #################################
FEATURES
[
'PERSISTENT_GRADES_ENABLED_FOR_ALL_TESTS'
]
=
True
###################### Payment ##############################3
###################### Payment ##############################3
# Enable fake payment processing page
# Enable fake payment processing page
FEATURES
[
'ENABLE_PAYMENT_FAKE'
]
=
True
FEATURES
[
'ENABLE_PAYMENT_FAKE'
]
=
True
...
...
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