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
265eb28e
Commit
265eb28e
authored
Mar 10, 2017
by
Awais Jibran
Committed by
Ayub khan
Mar 14, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Courses Without End Date Not Visible via API. ECOM-7444
parent
d72f5077
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
11 deletions
+20
-11
course_discovery/apps/course_metadata/query.py
+3
-1
course_discovery/apps/course_metadata/tests/test_query.py
+17
-10
No files found.
course_discovery/apps/course_metadata/query.py
View file @
265eb28e
...
@@ -35,8 +35,10 @@ class CourseRunQuerySet(models.QuerySet):
...
@@ -35,8 +35,10 @@ class CourseRunQuerySet(models.QuerySet):
"""
"""
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
return
self
.
filter
(
return
self
.
filter
(
Q
(
end__gt
=
now
)
&
(
(
Q
(
end__gt
=
now
)
|
Q
(
end__isnull
=
True
)
)
&
(
Q
(
enrollment_end__gt
=
now
)
|
Q
(
enrollment_end__gt
=
now
)
|
Q
(
enrollment_end__isnull
=
True
)
Q
(
enrollment_end__isnull
=
True
)
)
)
...
...
course_discovery/apps/course_metadata/tests/test_query.py
View file @
265eb28e
...
@@ -46,26 +46,33 @@ class CourseQuerySetTests(TestCase):
...
@@ -46,26 +46,33 @@ class CourseQuerySetTests(TestCase):
class
CourseRunQuerySetTests
(
TestCase
):
class
CourseRunQuerySetTests
(
TestCase
):
def
test_active
(
self
):
def
test_active
(
self
):
""" Verify the method returns only course runs currently open for enrollment or opening in the future. """
""" Verify the method returns only course runs currently open for enrollment or opening in the future. """
now
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
active_course_end
=
now
+
datetime
.
timedelta
(
days
=
60
)
inactive_course_end
=
now
-
datetime
.
timedelta
(
days
=
15
)
open_enrollment_end
=
now
+
datetime
.
timedelta
(
days
=
30
)
closed_enrollment_end
=
now
-
datetime
.
timedelta
(
days
=
30
)
# Create course with end date in future and enrollment_end in past.
# Create course with end date in future and enrollment_end in past.
end
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
2
)
CourseRunFactory
(
end
=
active_course_end
,
enrollment_end
=
closed_enrollment_end
)
enrollment_end
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
-
datetime
.
timedelta
(
days
=
1
)
CourseRunFactory
(
end
=
end
,
enrollment_end
=
enrollment_end
)
# Create course with end date in past and no enrollment_end.
# Create course with end date in past and no enrollment_end.
end
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
-
datetime
.
timedelta
(
days
=
2
)
CourseRunFactory
(
end
=
inactive_course_end
,
enrollment_end
=
None
)
CourseRunFactory
(
end
=
end
,
enrollment_end
=
None
)
self
.
assertEqual
(
CourseRun
.
objects
.
active
()
.
count
(),
0
)
self
.
assertEqual
(
CourseRun
.
objects
.
active
()
.
count
(),
0
)
# Create course with end date in future and enrollment_end in future.
# Create course with end date in future and enrollment_end in future.
end
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
2
)
active_enrollment_end
=
CourseRunFactory
(
end
=
active_course_end
,
enrollment_end
=
open_enrollment_end
)
enrollment_end
=
datetime
.
datetime
.
now
(
pytz
.
UTC
)
+
datetime
.
timedelta
(
days
=
1
)
active_enrollment_end
=
CourseRunFactory
(
end
=
end
,
enrollment_end
=
enrollment_end
)
# Create course with end date in future and no enrollment_end.
# Create course with end date in future and no enrollment_end.
active_no_enrollment_end
=
CourseRunFactory
(
end
=
end
,
enrollment_end
=
None
)
active_no_enrollment_end
=
CourseRunFactory
(
end
=
active_course_end
,
enrollment_end
=
None
)
# Create course with no end date and enrollment date in future.
active_no_end_date
=
CourseRunFactory
(
end
=
None
,
enrollment_end
=
open_enrollment_end
)
self
.
assertEqual
(
set
(
CourseRun
.
objects
.
active
()),
{
active_enrollment_end
,
active_no_enrollment_end
})
self
.
assertEqual
(
set
(
CourseRun
.
objects
.
active
()),
{
active_enrollment_end
,
active_no_enrollment_end
,
active_no_end_date
}
)
def
test_enrollable
(
self
):
def
test_enrollable
(
self
):
""" Verify the method returns only course runs currently open for enrollment. """
""" Verify the method returns only course runs currently open for enrollment. """
...
...
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