本文整理汇总了Python中models.Task.priority_human方法的典型用法代码示例。如果您正苦于以下问题:Python Task.priority_human方法的具体用法?Python Task.priority_human怎么用?Python Task.priority_human使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Task
的用法示例。
在下文中一共展示了Task.priority_human方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ProjectsModelsTest
# 需要导入模块: from models import Task [as 别名]
# 或者: from models.Task import priority_human [as 别名]
class ProjectsModelsTest(TestCase):
""" Documents models tests"""
def setUp(self):
self.project = Project(name='test')
self.project.save()
self.taskstatus = TaskStatus(name='test')
self.taskstatus.save()
self.task = Task(name='test', project=self.project, status=self.taskstatus)
self.task.save()
def test_task_priority_human(self):
"""Default priority should be 3, text representation should be 'Normal'
"""
self.assertEqual(self.task.priority, 3)
self.assertEqual(self.task.priority_human(), 'Normal')
def test_get_estimated_time_default(self):
"""Default estimated time is None, string representation is empty string """
self.assertIsNone(self.task.estimated_time)
self.assertEqual(self.task.get_estimated_time(), '')
def test_get_estimated_time_one_min(self):
self.task.estimated_time = 1
self.assertEqual(self.task.get_estimated_time(), ' 1 minutes')
def test_get_estimated_time_zero_min(self):
self.task.estimated_time = 0
self.assertEqual(self.task.get_estimated_time(), 'Less than 1 minute')
def test_get_estimated_time_60_min(self):
self.task.estimated_time = 60
self.assertEqual(self.task.get_estimated_time(), ' 1 hours ')
def test_get_estimated_time_61_min(self):
self.task.estimated_time = 61
self.assertEqual(self.task.get_estimated_time(), ' 1 hours 1 minutes')
def test_model_task_get_absolute_url(self):
self.task.get_absolute_url()
# def test_save TODO: save is overridden and has some extra logic
def test_get_absolute_url(self):
"""Test if get_absolute_url works without raising any exception"""
self.project.get_absolute_url()
def add_time_slot(self, total_time):
duser, created = DjangoUser.objects.get_or_create(username='testuser')
time_from = datetime(year=2015, month=8, day=3)
time_to = time_from + total_time
timeslot = TaskTimeSlot(task=self.task, user=duser.profile, time_from=time_from, time_to=time_to)
timeslot.save()
def test_get_total_time_default(self):
self.assertEqual(self.task.get_total_time(), timedelta())
def test_get_total_time_with_timeslots1(self):
total_time = timedelta(hours=3)
self.add_time_slot(total_time)
self.assertEqual(self.task.get_total_time(), total_time)
def test_get_total_time_tuple_default(self):
self.assertIsNone(self.task.get_total_time_tuple())
def test_get_total_time_tuple(self):
total_time = timedelta(hours=3)
self.add_time_slot(total_time)
h, m, s = self.task.get_total_time_tuple()
self.assertEqual((h, m, s), (3, 0, 0))
def test_get_total_time_string_default(self):
self.assertEqual(self.task.get_total_time_string(), '0 minutes')
def test_get_total_time_string_one_min(self):
total_time = timedelta(minutes=1)
self.add_time_slot(total_time)
self.assertEqual(self.task.get_total_time_string(), ' 1 minutes')
def test_get_total_time_string_zero_min(self):
total_time = timedelta(minutes=0)
self.add_time_slot(total_time)
self.assertEqual(self.task.get_total_time_string(), '0 minutes')
def test_get_total_time_string_30_secs(self):
total_time = timedelta(seconds=30)
self.add_time_slot(total_time)
self.assertEqual(self.task.get_total_time_string(), 'Less than 1 minute')
def test_get_total_time_string_60_min(self):
total_time = timedelta(minutes=60)
self.add_time_slot(total_time)
self.assertEqual(self.task.get_total_time_string(), ' 1 hours ')
def test_get_total_time_string_61_min(self):
total_time = timedelta(minutes=61)
self.add_time_slot(total_time)
self.assertEqual(self.task.get_total_time_string(), ' 1 hours 1 minutes')
#.........这里部分代码省略.........