Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
edx-platform-release
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hsin-Yu Chien
edx-platform-release
Commits
e649d2d7
Commit
e649d2d7
authored
7 years ago
by
Troy Sankey
Browse files
Options
Downloads
Patches
Plain Diff
Shim query count assertions due to added SAVEPOINTs
parent
1deb26e1
Loading
Loading
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lms/djangoapps/course_api/blocks/tests/test_api.py
+14
-2
14 additions, 2 deletions
lms/djangoapps/course_api/blocks/tests/test_api.py
lms/djangoapps/grades/tests/test_course_grade_factory.py
+37
-4
37 additions, 4 deletions
lms/djangoapps/grades/tests/test_course_grade_factory.py
with
51 additions
and
6 deletions
lms/djangoapps/course_api/blocks/tests/test_api.py
+
14
−
2
View file @
e649d2d7
...
...
@@ -5,8 +5,8 @@ Tests for Blocks api.py
from
itertools
import
product
import
ddt
import
django
from
django.test.client
import
RequestFactory
from
openedx.core.djangoapps.content.block_structure.api
import
clear_course_from_cache
from
openedx.core.djangoapps.content.block_structure.config
import
STORAGE_BACKING_FOR_CACHE
,
waffle
from
student.tests.factories
import
UserFactory
...
...
@@ -161,8 +161,20 @@ class TestGetBlocksQueryCounts(SharedModuleStoreTestCase):
with
waffle
().
override
(
STORAGE_BACKING_FOR_CACHE
,
active
=
with_storage_backing
):
course
=
self
.
_create_course
(
store_type
)
clear_course_from_cache
(
course
.
id
)
if
with_storage_backing
:
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Django 1.11 results in a few more SAVEPOINTs due to:
# https://github.com/django/django/commit/d44afd88#diff-5b0dda5eb9a242c15879dc9cd2121379L485
if
django
.
VERSION
>=
(
1
,
11
):
num_sql_queries
=
16
else
:
num_sql_queries
=
14
else
:
num_sql_queries
=
6
self
.
_get_blocks
(
course
,
expected_mongo_queries
,
expected_sql_queries
=
14
if
with_storage_backing
else
6
,
expected_sql_queries
=
num_sql_queries
,
)
This diff is collapsed.
Click to expand it.
lms/djangoapps/grades/tests/test_course_grade_factory.py
+
37
−
4
View file @
e649d2d7
...
...
@@ -2,6 +2,7 @@ import itertools
from
nose.plugins.attrib
import
attr
import
ddt
import
django
from
courseware.access
import
has_access
from
django.conf
import
settings
from
lms.djangoapps.grades.config.tests.utils
import
persistent_grades_feature_flags
...
...
@@ -94,25 +95,57 @@ class TestCourseGradeFactory(GradeTestBase):
with
self
.
assertNumQueries
(
2
),
mock_get_score
(
1
,
2
):
_assert_read
(
expected_pass
=
False
,
expected_percent
=
0
)
# start off with grade of 0
with
self
.
assertNumQueries
(
29
),
mock_get_score
(
1
,
2
):
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Django 1.11 results in a few more SAVEPOINTs due to:
# https://github.com/django/django/commit/d44afd88#diff-5b0dda5eb9a242c15879dc9cd2121379L485
if
django
.
VERSION
>=
(
1
,
11
):
num_queries
=
37
else
:
num_queries
=
29
with
self
.
assertNumQueries
(
num_queries
),
mock_get_score
(
1
,
2
):
grade_factory
.
update
(
self
.
request
.
user
,
self
.
course
,
force_update_subsections
=
True
)
with
self
.
assertNumQueries
(
2
):
_assert_read
(
expected_pass
=
True
,
expected_percent
=
0.5
)
# updated to grade of .5
with
self
.
assertNumQueries
(
4
),
mock_get_score
(
1
,
4
):
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Django 1.11 results in a few more SAVEPOINTs due to:
# https://github.com/django/django/commit/d44afd88#diff-5b0dda5eb9a242c15879dc9cd2121379L485
if
django
.
VERSION
>=
(
1
,
11
):
num_queries
=
6
else
:
num_queries
=
4
with
self
.
assertNumQueries
(
num_queries
),
mock_get_score
(
1
,
4
):
grade_factory
.
update
(
self
.
request
.
user
,
self
.
course
,
force_update_subsections
=
False
)
with
self
.
assertNumQueries
(
2
):
_assert_read
(
expected_pass
=
True
,
expected_percent
=
0.5
)
# NOT updated to grade of .25
with
self
.
assertNumQueries
(
12
),
mock_get_score
(
2
,
2
):
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Django 1.11 results in a few more SAVEPOINTs due to:
# https://github.com/django/django/commit/d44afd88#diff-5b0dda5eb9a242c15879dc9cd2121379L485
if
django
.
VERSION
>=
(
1
,
11
):
num_queries
=
20
else
:
num_queries
=
12
with
self
.
assertNumQueries
(
num_queries
),
mock_get_score
(
2
,
2
):
grade_factory
.
update
(
self
.
request
.
user
,
self
.
course
,
force_update_subsections
=
True
)
with
self
.
assertNumQueries
(
2
):
_assert_read
(
expected_pass
=
True
,
expected_percent
=
1.0
)
# updated to grade of 1.0
with
self
.
assertNumQueries
(
12
),
mock_get_score
(
0
,
0
):
# the subsection now is worth zero
# TODO: Remove Django 1.11 upgrade shim
# SHIM: Django 1.11 results in a few more SAVEPOINTs due to:
# https://github.com/django/django/commit/d44afd88#diff-5b0dda5eb9a242c15879dc9cd2121379L485
if
django
.
VERSION
>=
(
1
,
11
):
num_queries
=
20
else
:
num_queries
=
12
with
self
.
assertNumQueries
(
num_queries
),
mock_get_score
(
0
,
0
):
# the subsection now is worth zero
grade_factory
.
update
(
self
.
request
.
user
,
self
.
course
,
force_update_subsections
=
True
)
with
self
.
assertNumQueries
(
2
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment