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
cd4916b6
Commit
cd4916b6
authored
Aug 21, 2015
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MySQL order_by is case insensitive.
Tests run with SQLlite though, which is case sensitive.
parent
a8284058
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
21 deletions
+20
-21
lms/djangoapps/teams/tests/test_views.py
+18
-19
lms/djangoapps/teams/views.py
+2
-2
No files found.
lms/djangoapps/teams/tests/test_views.py
View file @
cd4916b6
...
...
@@ -122,7 +122,7 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
'id'
:
'topic_{}'
.
format
(
i
),
'name'
:
name
,
'description'
:
'Description for topic {}.'
.
format
(
i
)
}
for
i
,
name
in
enumerate
([
u'
s
ólar power'
,
'Wind Power'
,
'Nuclear Power'
,
'Coal Power'
])
}
for
i
,
name
in
enumerate
([
u'
S
ólar power'
,
'Wind Power'
,
'Nuclear Power'
,
'Coal Power'
])
]
}
cls
.
test_course_1
=
CourseFactory
.
create
(
...
...
@@ -201,9 +201,8 @@ class TeamAPITestCase(APITestCase, SharedModuleStoreTestCase):
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
):
# 'solar team' is intentionally lower case to test case insensitivity in name ordering
self
.
test_team_1
=
CourseTeamFactory
.
create
(
name
=
u'
s
ólar team'
,
name
=
u'
S
ólar team'
,
course_id
=
self
.
test_course_1
.
id
,
topic_id
=
'topic_0'
)
...
...
@@ -445,24 +444,24 @@ class TestListTeamsAPI(TeamAPITestCase):
)
def
test_filter_topic_id
(
self
):
self
.
verify_names
({
'course_id'
:
self
.
test_course_1
.
id
,
'topic_id'
:
'topic_0'
},
200
,
[
u'
s
ólar team'
])
self
.
verify_names
({
'course_id'
:
self
.
test_course_1
.
id
,
'topic_id'
:
'topic_0'
},
200
,
[
u'
S
ólar team'
])
def
test_filter_include_inactive
(
self
):
self
.
verify_names
({
'include_inactive'
:
True
},
200
,
[
'Coal Team'
,
'Nuclear Team'
,
u'
s
ólar team'
,
'Wind Team'
])
self
.
verify_names
({
'include_inactive'
:
True
},
200
,
[
'Coal Team'
,
'Nuclear Team'
,
u'
S
ólar team'
,
'Wind Team'
])
@ddt.data
(
(
None
,
200
,
[
'Nuclear Team'
,
u'
s
ólar team'
,
'Wind Team'
]),
(
'name'
,
200
,
[
'Nuclear Team'
,
u'
s
ólar team'
,
'Wind Team'
]),
# Note that "Nuclear Team" and "
s
olar team" have the same open_slots.
# "
s
olar team" comes first due to secondary sort by last_activity_at.
(
'open_slots'
,
200
,
[
'Wind Team'
,
u'
s
ólar team'
,
'Nuclear Team'
]),
(
None
,
200
,
[
'Nuclear Team'
,
u'
S
ólar team'
,
'Wind Team'
]),
(
'name'
,
200
,
[
'Nuclear Team'
,
u'
S
ólar team'
,
'Wind Team'
]),
# Note that "Nuclear Team" and "
S
olar team" have the same open_slots.
# "
S
olar team" comes first due to secondary sort by last_activity_at.
(
'open_slots'
,
200
,
[
'Wind Team'
,
u'
S
ólar team'
,
'Nuclear Team'
]),
# Note that "Wind Team" and "Nuclear Team" have the same last_activity_at.
# "Wind Team" comes first due to secondary sort by open_slots.
(
'last_activity_at'
,
200
,
[
u'
s
ólar team'
,
'Wind Team'
,
'Nuclear Team'
]),
(
'last_activity_at'
,
200
,
[
u'
S
ólar team'
,
'Wind Team'
,
'Nuclear Team'
]),
)
@ddt.unpack
def
test_order_by
(
self
,
field
,
status
,
names
):
# Make "
s
olar team" the most recently active team.
# Make "
S
olar team" the most recently active team.
# The CourseTeamFactory sets the last_activity_at to a fixed time (in the past), so all of the
# other teams have the same last_activity_at.
with
skip_signal
(
...
...
@@ -471,7 +470,7 @@ class TestListTeamsAPI(TeamAPITestCase):
sender
=
CourseTeam
,
dispatch_uid
=
'teams.signals.course_team_post_save_callback'
):
solar_team
=
self
.
test_team_name_id_map
[
u'
s
ólar team'
]
solar_team
=
self
.
test_team_name_id_map
[
u'
S
ólar team'
]
solar_team
.
last_activity_at
=
datetime
.
utcnow
()
.
replace
(
tzinfo
=
pytz
.
utc
)
solar_team
.
save
()
...
...
@@ -810,11 +809,11 @@ class TestListTopicsAPI(TeamAPITestCase):
self
.
get_topics_list
(
400
)
@ddt.data
(
(
None
,
200
,
[
'Coal Power'
,
'Nuclear Power'
,
u'
s
ólar power'
,
'Wind Power'
],
'name'
),
(
'name'
,
200
,
[
'Coal Power'
,
'Nuclear Power'
,
u'
s
ólar power'
,
'Wind Power'
],
'name'
),
# Note that "Nuclear Power" and "
s
olar power" both have 2 teams. "Coal Power" and "Window Power"
(
None
,
200
,
[
'Coal Power'
,
'Nuclear Power'
,
u'
S
ólar power'
,
'Wind Power'
],
'name'
),
(
'name'
,
200
,
[
'Coal Power'
,
'Nuclear Power'
,
u'
S
ólar power'
,
'Wind Power'
],
'name'
),
# Note that "Nuclear Power" and "
S
olar power" both have 2 teams. "Coal Power" and "Window Power"
# both have 0 teams. The secondary sort is alphabetical by name.
(
'team_count'
,
200
,
[
'Nuclear Power'
,
u'
s
ólar power'
,
'Coal Power'
,
'Wind Power'
],
'team_count'
),
(
'team_count'
,
200
,
[
'Nuclear Power'
,
u'
S
ólar power'
,
'Coal Power'
,
'Wind Power'
],
'team_count'
),
(
'no_such_field'
,
400
,
[],
None
),
)
@ddt.unpack
...
...
@@ -865,7 +864,7 @@ class TestListTopicsAPI(TeamAPITestCase):
'page'
:
1
,
'order_by'
:
'team_count'
})
self
.
assertEqual
([
"Wind Power"
,
u'
s
ólar power'
],
[
topic
[
'name'
]
for
topic
in
topics
[
'results'
]])
self
.
assertEqual
([
"Wind Power"
,
u'
S
ólar power'
],
[
topic
[
'name'
]
for
topic
in
topics
[
'results'
]])
topics
=
self
.
get_topics_list
(
data
=
{
'course_id'
:
self
.
test_course_1
.
id
,
...
...
@@ -981,7 +980,7 @@ class TestListMembershipAPI(TeamAPITestCase):
@ddt.data
(
(
'student_enrolled_both_courses_other_team'
,
'TestX/TS101/Test_Course'
,
200
,
'Nuclear Team'
),
(
'student_enrolled_both_courses_other_team'
,
'MIT/6.002x/Circuits'
,
200
,
'Another Team'
),
(
'student_enrolled'
,
'TestX/TS101/Test_Course'
,
200
,
u'
s
ólar team'
),
(
'student_enrolled'
,
'TestX/TS101/Test_Course'
,
200
,
u'
S
ólar team'
),
(
'student_enrolled'
,
'MIT/6.002x/Circuits'
,
400
,
''
),
)
@ddt.unpack
...
...
lms/djangoapps/teams/views.py
View file @
cd4916b6
...
...
@@ -361,8 +361,8 @@ class TeamsListView(ExpandableFieldViewMixin, GenericAPIView):
queryset
=
CourseTeam
.
objects
.
filter
(
**
result_filter
)
order_by_input
=
request
.
QUERY_PARAMS
.
get
(
'order_by'
,
'name'
)
if
order_by_input
==
'name'
:
queryset
=
queryset
.
extra
(
select
=
{
'lower_name'
:
"lower(name)"
})
queryset
=
queryset
.
order_by
(
'
lower_
name'
)
# MySQL does case-insensitive order_by.
queryset
=
queryset
.
order_by
(
'name'
)
elif
order_by_input
==
'open_slots'
:
queryset
=
queryset
.
annotate
(
team_size
=
Count
(
'users'
))
queryset
=
queryset
.
order_by
(
'team_size'
,
'-last_activity_at'
)
...
...
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