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
7da8b084
Commit
7da8b084
authored
Dec 20, 2016
by
Ahsan Ulhaq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MicroMasters logo showing on a non-MM course discovery card
ECOM-6372
parent
cba37b58
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
2 deletions
+45
-2
course_discovery/apps/api/v1/tests/test_views/test_search.py
+40
-0
course_discovery/apps/course_metadata/models.py
+5
-2
No files found.
course_discovery/apps/api/v1/tests/test_views/test_search.py
View file @
7da8b084
...
@@ -200,6 +200,46 @@ class CourseRunSearchViewSetTests(DefaultPartnerMixin, SerializationMixin, Login
...
@@ -200,6 +200,46 @@ class CourseRunSearchViewSetTests(DefaultPartnerMixin, SerializationMixin, Login
""" Verify the unpublished programs do not show in the program_types representation. """
""" Verify the unpublished programs do not show in the program_types representation. """
self
.
_test_exclude_program_types
(
ProgramStatus
.
Unpublished
)
self
.
_test_exclude_program_types
(
ProgramStatus
.
Unpublished
)
@ddt.data
(
[{
'title'
:
'Software Testing'
,
'excluded'
:
True
}],
[{
'title'
:
'Software Testing'
,
'excluded'
:
True
},
{
'title'
:
'Software Testing 2'
,
'excluded'
:
True
}],
[{
'title'
:
'Software Testing'
,
'excluded'
:
False
},
{
'title'
:
'Software Testing 2'
,
'excluded'
:
False
}],
[{
'title'
:
'Software Testing'
,
'excluded'
:
True
},
{
'title'
:
'Software Testing 2'
,
'excluded'
:
True
},
{
'title'
:
'Software Testing 3'
,
'excluded'
:
False
}],
)
def
test_excluded_course_run
(
self
,
course_runs
):
course_list
=
[]
course_run_list
=
[]
excluded_course_run_list
=
[]
non_excluded_course_run_list
=
[]
for
run
in
course_runs
:
course_run
=
CourseRunFactory
(
course__partner
=
self
.
partner
,
course__title
=
run
[
'title'
],
status
=
CourseRunStatus
.
Published
)
course_list
.
append
(
course_run
.
course
)
course_run_list
.
append
(
course_run
)
if
run
[
'excluded'
]:
excluded_course_run_list
.
append
(
course_run
)
else
:
non_excluded_course_run_list
.
append
(
course_run
)
ProgramFactory
(
courses
=
course_list
,
status
=
ProgramStatus
.
Active
,
excluded_course_runs
=
excluded_course_run_list
)
with
self
.
assertNumQueries
(
6
):
response
=
self
.
get_search_response
(
'software'
,
faceted
=
False
)
self
.
assertEqual
(
response
.
status_code
,
200
)
response_data
=
response
.
json
()
self
.
assertEqual
(
response_data
[
'count'
],
len
(
course_run_list
))
for
result
in
response_data
[
'results'
]:
for
course_run
in
excluded_course_run_list
:
if
result
.
get
(
'title'
)
==
course_run
.
title
:
self
.
assertEqual
(
result
.
get
(
'program_types'
),
[])
for
course_run
in
non_excluded_course_run_list
:
if
result
.
get
(
'title'
)
==
course_run
.
title
:
self
.
assertEqual
(
result
.
get
(
'program_types'
),
course_run
.
program_types
)
def
_test_exclude_program_types
(
self
,
program_status
):
def
_test_exclude_program_types
(
self
,
program_status
):
""" Verify that programs with the provided type do not show in the program_types representation. """
""" Verify that programs with the provided type do not show in the program_types representation. """
course_run
=
CourseRunFactory
(
course__partner
=
self
.
partner
,
course__title
=
'Software Testing'
,
course_run
=
CourseRunFactory
(
course__partner
=
self
.
partner
,
course__title
=
'Software Testing'
,
...
...
course_discovery/apps/course_metadata/models.py
View file @
7da8b084
...
@@ -388,8 +388,11 @@ class CourseRun(TimeStampedModel):
...
@@ -388,8 +388,11 @@ class CourseRun(TimeStampedModel):
so we don't identify that program type if not available
so we don't identify that program type if not available
"""
"""
program_statuses_to_exclude
=
(
ProgramStatus
.
Unpublished
,
ProgramStatus
.
Deleted
)
program_statuses_to_exclude
=
(
ProgramStatus
.
Unpublished
,
ProgramStatus
.
Deleted
)
all_programs
=
[
program
for
program
in
self
.
programs
.
exclude
(
status__in
=
program_statuses_to_exclude
)]
associated_programs
=
[]
return
[
program
.
type
.
name
for
program
in
all_programs
]
for
program
in
self
.
programs
.
exclude
(
status__in
=
program_statuses_to_exclude
):
if
self
not
in
program
.
excluded_course_runs
.
all
():
associated_programs
.
append
(
program
)
return
[
program
.
type
.
name
for
program
in
associated_programs
]
@property
@property
def
marketing_url
(
self
):
def
marketing_url
(
self
):
...
...
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