當前位置: 首頁>>代碼示例>>Python>>正文


Python models.Task類代碼示例

本文整理匯總了Python中oneanddone.tasks.models.Task的典型用法代碼示例。如果您正苦於以下問題:Python Task類的具體用法?Python Task怎麽用?Python Task使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Task類的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_is_available_filter_after_end_date

 def test_is_available_filter_after_end_date(self):
     """
     If it is after a task's end date, the task should not be
     available.
     """
     tasks = Task.objects.filter(Task.is_available_filter(now=aware_datetime(2014, 2, 1)))
     ok_(self.task_end_jan not in tasks)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:7,代碼來源:test_models.py

示例2: test_is_available_filter_in_range

 def test_is_available_filter_in_range(self):
     """
     If the current date is within a task's date range, the task
     should be available.
     """
     tasks = Task.objects.filter(Task.is_available_filter(now=aware_datetime(2014, 1, 5)))
     ok_(self.task_range_jan_feb in tasks)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:7,代碼來源:test_models.py

示例3: test_is_available_filter_after_start_date

 def test_is_available_filter_after_start_date(self):
     """
     If it is after a task's start date, the task should be
     available.
     """
     tasks = Task.objects.filter(Task.is_available_filter(now=aware_datetime(2014, 2, 1)))
     ok_(self.task_start_jan in tasks)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:7,代碼來源:test_models.py

示例4: test_is_available_filter_invalid

 def test_is_available_filter_invalid(self):
     """
     If a task is marked as invalid, it should not be available.
     """
     tasks = Task.objects.filter(Task.is_available_filter(now=aware_datetime(2014, 1, 2)))
     ok_(self.task_no_draft in tasks)
     ok_(self.task_invalid not in tasks)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:7,代碼來源:test_models.py

示例5: test_is_available_filter_before_start_date

 def test_is_available_filter_before_start_date(self):
     """
     If it is before a task's start date, the task should not be
     available.
     """
     tasks = Task.objects.filter(Task.is_available_filter(now=aware_datetime(2013, 12, 1)))
     ok_(self.task_start_jan not in tasks)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:7,代碼來源:test_models.py

示例6: test_invalidate_tasks_not_equals_criterion

 def test_invalidate_tasks_not_equals_criterion(self):
     """
     The invalidate_tasks routine should invalidate tasks which match the
     invalidation criteria.
     This tests a not equals criterion.
     """
     bug_to_become_invalid, bug_to_stay_valid = BugzillaBugFactory.create_batch(2)
     batch = TaskImportBatchFactory.create()
     criterion = TaskInvalidationCriterionFactory.create(
         field_name='name',
         relation=TaskInvalidationCriterion.NOT_EQUAL,
         field_value='value')
     criterion.batches.add(batch)
     criterion.save()
     task1, task2 = TaskFactory.create_batch(2,
                                             batch=batch,
                                             imported_item=bug_to_become_invalid,
                                             is_invalid=False)
     task2.imported_item = bug_to_stay_valid
     task2.save()
     with patch('oneanddone.tasks.models.BugzillaUtils.request_bug') as request_bug:
         request_bug.side_effect = lambda x: {
             bug_to_become_invalid.bugzilla_id: {'name': 'value'},
             bug_to_stay_valid.bugzilla_id: {'name': 'not value'}}[x]
         eq_(Task.invalidate_tasks(), 1)
     eq_(Task.objects.get(pk=task1.pk).is_invalid, False)
     eq_(Task.objects.get(pk=task2.pk).is_invalid, True)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:27,代碼來源:test_models.py

示例7: handle

 def handle(self, *args, **options):
     invalidated = Task.invalidate_tasks()
     self.stdout.write('%s: %s tasks were invalidated via bug data\n' %
                       (datetime.now().isoformat(), invalidated))
     closed = TaskAttempt.close_stale_onetime_attempts()
     self.stdout.write('%s: %s stale one-time attempts were closed\n' %
                       (datetime.now().isoformat(), closed))
     closed = TaskAttempt.close_expired_task_attempts()
     self.stdout.write('%s: %s attempts for expired tasks were closed\n' %
                       (datetime.now().isoformat(), closed))
開發者ID:Anmol2307,項目名稱:oneanddone,代碼行數:10,代碼來源:taskcleanup.py

示例8: test_is_available_filter_default_now

 def test_is_available_filter_default_now(self):
     """
     If no timezone is given, is_available_filter should use
     timezone.now to determine the current datetime.
     """
     with patch('oneanddone.tasks.models.timezone.now') as now:
         now.return_value = aware_datetime(2014, 1, 5)
         tasks = Task.objects.filter(Task.is_available_filter())
         expected = [self.task_no_draft, self.task_start_jan, self.task_range_jan_feb]
         eq_(set(tasks), set(expected))
開發者ID:kyoshino,項目名稱:oneanddone,代碼行數:10,代碼來源:test_models.py

示例9: __init__

    def __init__(self, *args, **kwargs):
        super(AvailableTasksFilterSet, self).__init__(*args, **kwargs)

        # Limit the area filter to TaskAreas that have available tasks.
        available_areas = TaskArea.objects.filter(Task.is_available_filter(prefix='task__')).distinct()
        ancestor_querysets = [area.get_ancestors(include_self=True) for area in available_areas]
        self.filters['area'] = TreeFilter(
            name='area',
            queryset=reduce(operator.or_, ancestor_querysets).distinct(),
            empty_label=u'All Areas'
        )
開發者ID:lizzard,項目名稱:oneanddone,代碼行數:11,代碼來源:filters.py

示例10: test_is_available_filter_default_now

 def test_is_available_filter_default_now(self):
     """
     If no timezone is given, is_available_filter should use
     timezone.now to determine the current datetime.
     This also tests the repeatable aspect of the filter by
     ensuring that tasks with attempts that are started or
     finished are not included, but those with no attempts
     or abandoned attempts are included.
     """
     with patch('oneanddone.tasks.models.timezone.now') as now:
         now.return_value = aware_datetime(2014, 1, 5)
         tasks = Task.objects.filter(Task.is_available_filter())
         expected = [self.task_not_repeatable_no_attempts,
                     self.task_not_repeatable_abandoned_attempt,
                     self.task_no_draft, self.task_start_jan,
                     self.task_range_jan_feb]
         eq_(set(tasks), set(expected))
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:17,代碼來源:test_models.py

示例11: get_queryset

 def get_queryset(self):
     queryset = super(TaskMustBeAvailableMixin, self).get_queryset()
     return queryset.filter(Task.is_available_filter(allow_expired=self.allow_expired_tasks))
開發者ID:adini121,項目名稱:oneanddone,代碼行數:3,代碼來源:mixins.py

示例12: test_is_available_filter_before_end_date

 def test_is_available_filter_before_end_date(self):
     """
     If it is before a task's end date, the task should be available.
     """
     tasks = Task.objects.filter(Task.is_available_filter(now=aware_datetime(2013, 12, 1)))
     ok_(self.task_end_jan in tasks)
開發者ID:akatsoulas,項目名稱:oneanddone,代碼行數:6,代碼來源:test_models.py


注:本文中的oneanddone.tasks.models.Task類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。