Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
course-discovery
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
course-discovery
Commits
83a32240
Commit
83a32240
authored
Sep 19, 2016
by
Renzo Lucioni
Committed by
GitHub
Sep 19, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix expected query counts in tests (#344)
parent
0a3b0dfd
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
course_discovery/apps/api/v1/tests/test_views/test_catalogs.py
+1
-1
course_discovery/apps/api/v1/tests/test_views/test_courses.py
+3
-3
course_discovery/apps/api/v1/tests/test_views/test_programs.py
+2
-2
No files found.
course_discovery/apps/api/v1/tests/test_views/test_catalogs.py
View file @
83a32240
...
@@ -141,7 +141,7 @@ class CatalogViewSetTests(ElasticsearchTestMixin, SerializationMixin, OAuth2Mixi
...
@@ -141,7 +141,7 @@ class CatalogViewSetTests(ElasticsearchTestMixin, SerializationMixin, OAuth2Mixi
CourseRunFactory
(
enrollment_end
=
enrollment_end
,
course__title
=
'ABC Test Course 2'
)
CourseRunFactory
(
enrollment_end
=
enrollment_end
,
course__title
=
'ABC Test Course 2'
)
CourseRunFactory
(
enrollment_end
=
enrollment_end
,
course
=
self
.
course
)
CourseRunFactory
(
enrollment_end
=
enrollment_end
,
course
=
self
.
course
)
with
self
.
assertNumQueries
(
4
1
):
with
self
.
assertNumQueries
(
4
0
):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertListEqual
(
response
.
data
[
'results'
],
self
.
serialize_catalog_course
(
courses
,
many
=
True
))
self
.
assertListEqual
(
response
.
data
[
'results'
],
self
.
serialize_catalog_course
(
courses
,
many
=
True
))
...
...
course_discovery/apps/api/v1/tests/test_views/test_courses.py
View file @
83a32240
...
@@ -19,7 +19,7 @@ class CourseViewSetTests(SerializationMixin, APITestCase):
...
@@ -19,7 +19,7 @@ class CourseViewSetTests(SerializationMixin, APITestCase):
""" Verify the endpoint returns the details for a single course. """
""" Verify the endpoint returns the details for a single course. """
url
=
reverse
(
'api:v1:course-detail'
,
kwargs
=
{
'key'
:
self
.
course
.
key
})
url
=
reverse
(
'api:v1:course-detail'
,
kwargs
=
{
'key'
:
self
.
course
.
key
})
with
self
.
assertNumQueries
(
1
9
):
with
self
.
assertNumQueries
(
1
8
):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
data
,
self
.
serialize_course
(
self
.
course
))
self
.
assertEqual
(
response
.
data
,
self
.
serialize_course
(
self
.
course
))
...
@@ -28,7 +28,7 @@ class CourseViewSetTests(SerializationMixin, APITestCase):
...
@@ -28,7 +28,7 @@ class CourseViewSetTests(SerializationMixin, APITestCase):
""" Verify the endpoint returns a list of all courses. """
""" Verify the endpoint returns a list of all courses. """
url
=
reverse
(
'api:v1:course-list'
)
url
=
reverse
(
'api:v1:course-list'
)
with
self
.
assertNumQueries
(
2
5
):
with
self
.
assertNumQueries
(
2
4
):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertEqual
(
response
.
status_code
,
200
)
self
.
assertListEqual
(
self
.
assertListEqual
(
...
@@ -55,6 +55,6 @@ class CourseViewSetTests(SerializationMixin, APITestCase):
...
@@ -55,6 +55,6 @@ class CourseViewSetTests(SerializationMixin, APITestCase):
keys
=
','
.
join
([
course
.
key
for
course
in
courses
])
keys
=
','
.
join
([
course
.
key
for
course
in
courses
])
url
=
'{root}?keys={keys}'
.
format
(
root
=
reverse
(
'api:v1:course-list'
),
keys
=
keys
)
url
=
'{root}?keys={keys}'
.
format
(
root
=
reverse
(
'api:v1:course-list'
),
keys
=
keys
)
with
self
.
assertNumQueries
(
3
8
):
with
self
.
assertNumQueries
(
3
5
):
response
=
self
.
client
.
get
(
url
)
response
=
self
.
client
.
get
(
url
)
self
.
assertListEqual
(
response
.
data
[
'results'
],
self
.
serialize_course
(
courses
,
many
=
True
))
self
.
assertListEqual
(
response
.
data
[
'results'
],
self
.
serialize_course
(
courses
,
many
=
True
))
course_discovery/apps/api/v1/tests/test_views/test_programs.py
View file @
83a32240
...
@@ -40,14 +40,14 @@ class ProgramViewSetTests(APITestCase):
...
@@ -40,14 +40,14 @@ class ProgramViewSetTests(APITestCase):
def
test_retrieve
(
self
):
def
test_retrieve
(
self
):
""" Verify the endpoint returns the details for a single program. """
""" Verify the endpoint returns the details for a single program. """
program
=
ProgramFactory
()
program
=
ProgramFactory
()
with
self
.
assertNumQueries
(
15
):
with
self
.
assertNumQueries
(
34
):
self
.
assert_retrieve_success
(
program
)
self
.
assert_retrieve_success
(
program
)
def
test_retrieve_without_course_runs
(
self
):
def
test_retrieve_without_course_runs
(
self
):
""" Verify the endpoint returns data for a program even if the program's courses have no course runs. """
""" Verify the endpoint returns data for a program even if the program's courses have no course runs. """
course
=
CourseFactory
()
course
=
CourseFactory
()
program
=
ProgramFactory
(
courses
=
[
course
])
program
=
ProgramFactory
(
courses
=
[
course
])
with
self
.
assertNumQueries
(
15
):
with
self
.
assertNumQueries
(
49
):
self
.
assert_retrieve_success
(
program
)
self
.
assert_retrieve_success
(
program
)
def
assert_list_results
(
self
,
url
,
expected
,
expected_query_count
):
def
assert_list_results
(
self
,
url
,
expected
,
expected_query_count
):
...
...
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