-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2062 from jazkarta/feature-idde2
Individual Due Date Extension feature
- Loading branch information
Showing
24 changed files
with
1,244 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
Tests for extended due date utilities. | ||
""" | ||
import mock | ||
import unittest | ||
|
||
from ..util import duedate | ||
|
||
|
||
class TestGetExtendedDueDate(unittest.TestCase): | ||
""" | ||
Test `get_extended_due_date` function. | ||
""" | ||
|
||
def call_fut(self, node): | ||
""" | ||
Call function under test. | ||
""" | ||
fut = duedate.get_extended_due_date | ||
return fut(node) | ||
|
||
def test_no_due_date(self): | ||
""" | ||
Test no due date. | ||
""" | ||
node = object() | ||
self.assertEqual(self.call_fut(node), None) | ||
|
||
def test_due_date_no_extension(self): | ||
""" | ||
Test due date without extension. | ||
""" | ||
node = mock.Mock(due=1, extended_due=None) | ||
self.assertEqual(self.call_fut(node), 1) | ||
|
||
def test_due_date_with_extension(self): | ||
""" | ||
Test due date with extension. | ||
""" | ||
node = mock.Mock(due=1, extended_due=2) | ||
self.assertEqual(self.call_fut(node), 2) | ||
|
||
def test_due_date_extension_is_earlier(self): | ||
""" | ||
Test due date with extension, but due date is later than extension. | ||
""" | ||
node = mock.Mock(due=2, extended_due=1) | ||
self.assertEqual(self.call_fut(node), 2) | ||
|
||
def test_extension_without_due_date(self): | ||
""" | ||
Test non-sensical extension without due date. | ||
""" | ||
node = mock.Mock(due=None, extended_due=1) | ||
self.assertEqual(self.call_fut(node), None) | ||
|
||
def test_due_date_with_extension_dict(self): | ||
""" | ||
Test due date with extension when node is a dict. | ||
""" | ||
node = {'due': 1, 'extended_due': 2} | ||
self.assertEqual(self.call_fut(node), 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
Miscellaneous utility functions. | ||
""" | ||
from functools import partial | ||
|
||
|
||
def get_extended_due_date(node): | ||
""" | ||
Gets the actual due date for the logged in student for this node, returning | ||
the extendeded due date if one has been granted and it is later than the | ||
global due date, otherwise returning the global due date for the unit. | ||
""" | ||
if isinstance(node, dict): | ||
get = node.get | ||
else: | ||
get = partial(getattr, node) | ||
due_date = get('due', None) | ||
if not due_date: | ||
return due_date | ||
extended = get('extended_due', None) | ||
if not extended or extended < due_date: | ||
return due_date | ||
return extended |
Oops, something went wrong.