本文整理汇总了Python中bluebottle.test.factory_models.tasks.TaskFactory类的典型用法代码示例。如果您正苦于以下问题:Python TaskFactory类的具体用法?Python TaskFactory怎么用?Python TaskFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
super(TestTaskSurveyAggregation, self).setUp()
self.init_projects()
self.project = ProjectFactory.create()
self.task1 = TaskFactory.create(project=self.project)
self.task2 = TaskFactory.create(project=self.project)
self.task3 = TaskFactory.create(project=self.project)
self.survey = SurveyFactory(title='test survey')
self.project_response = ResponseFactory.create(
project=self.project,
survey=self.survey
)
self.task_response1 = ResponseFactory.create(
project=self.project,
task=self.task1,
survey=self.survey
)
self.task_response2 = ResponseFactory.create(
project=self.project,
task=self.task2,
survey=self.survey
)
self.task_response3 = ResponseFactory.create(
project=self.project,
task=self.task3,
survey=self.survey
)
示例2: test_search_for_date_range
def test_search_for_date_range(self):
"""
Search tasks for a date range. Return ongoing and event tasks
with deadline in range
"""
ongoing_task_4 = TaskFactory.create(status='open',
type='ongoing',
deadline=self.now +
timezone.timedelta(days=365),
people_needed=1)
TaskFactory.create(status='open',
type='event',
deadline=self.now + timezone.timedelta(days=365),
people_needed=1)
search_date = {
'start': str((self.tomorrow + timezone.timedelta(days=3)).date()),
'end': str((self.month + timezone.timedelta(days=15)).date())
}
response = self.client.get(self.task_url, search_date,
token=self.some_token)
# Search should return event_task_2, ongoing_task_1, and ongoing_task_3
ids = [self.event_task_2.id, self.ongoing_task_1.id,
self.ongoing_task_3.id, ongoing_task_4.id]
self.assertEqual(response.data['count'], 4)
self.assertTrue(response.data['results'][0]['id'] in ids)
self.assertTrue(response.data['results'][1]['id'] in ids)
self.assertTrue(response.data['results'][2]['id'] in ids)
self.assertTrue(response.data['results'][3]['id'] in ids)
示例3: test_some_tasks_realised
def test_some_tasks_realised(self):
TaskFactory.create(project=self.project, status=Task.TaskStatuses.in_progress)
self.task.status = Task.TaskStatuses.realized
self.task.save()
self.assertEqual(self.task.status, Task.TaskStatuses.realized)
self.assertEqual(self.project.status.slug, 'campaign')
示例4: test_sourcing_tasks_incomplete_in_progress
def test_sourcing_tasks_incomplete_in_progress(self):
self.project.amount_asked = 0 # makes it sourcing
TaskFactory.create(project=self.project,
status=TASK_MODEL.TaskStatuses.in_progress)
self.project.deadline_reached()
self.assertEquals(self.project.status, self.incomplete)
示例5: test_task_search_by_status
def test_task_search_by_status(self):
"""
Ensure we can filter task list by status
"""
self.task1 = TaskFactory.create(
status=BB_TASK_MODEL.TaskStatuses.in_progress,
author=self.some_project.owner,
project=self.some_project,
)
self.task2 = TaskFactory.create(
status=BB_TASK_MODEL.TaskStatuses.open,
author=self.another_project.owner,
project=self.another_project,
)
self.assertEqual(2, BB_TASK_MODEL.objects.count())
# Test as a different user
response = self.client.get(self.task_url, {'status': 'open'}, token=self.some_token)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
self.assertEqual(response.data['count'], 1)
response = self.client.get(self.task_url, {'status': 'in progress'}, token=self.some_token)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.data)
self.assertEqual(response.data['count'], 1)
示例6: test_sourcing_tasks_complete
def test_sourcing_tasks_complete(self):
""" one remaining open task """
self.project.amount_asked = 0 # makes it sourcing
TaskFactory.create(project=self.project,
status=TASK_MODEL.TaskStatuses.realized)
self.project.deadline_reached()
self.assertEquals(self.project.status, self.complete)
示例7: test_sourcing_tasks_incomplete_open
def test_sourcing_tasks_incomplete_open(self):
""" on remaining in progress task """
self.project.amount_asked = 0 # makes it sourcing
TaskFactory.create(project=self.project,
status=TASK_MODEL.TaskStatuses.open)
self.project.deadline_reached()
self.assertEquals(self.project.status, self.incomplete)
示例8: status_response
def status_response(self, url):
self.task1.delete()
task1 = TaskFactory.create(
status=Task.TaskStatuses.open,
author=self.some_project.owner,
project=self.some_project,
people_needed=2
)
task2 = TaskFactory.create(
status=Task.TaskStatuses.closed,
author=self.some_project.owner,
project=self.some_project,
people_needed=2
)
task3 = TaskFactory.create(
status=Task.TaskStatuses.realized,
author=self.some_project.owner,
project=self.some_project,
people_needed=2
)
task4 = TaskFactory.create(
status=Task.TaskStatuses.in_progress,
author=self.some_project.owner,
project=self.some_project,
people_needed=2
)
response = self.client.get(url,
{'status': 'open'},
HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['count'], 1)
self.assertEqual(response.data['results'][0]['id'], task1.id)
response = self.client.get(url,
{'status': 'closed'},
HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['count'], 1)
self.assertEqual(response.data['results'][0]['id'], task2.id)
response = self.client.get(url,
{'status': 'realized'},
HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['count'], 1)
self.assertEqual(response.data['results'][0]['id'], task3.id)
response = self.client.get(url,
{'status': 'in progress'},
HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['count'], 1)
self.assertEqual(response.data['results'][0]['id'], task4.id)
示例9: test_funding_tasks_incomplete
def test_funding_tasks_incomplete(self):
""" a funding project with incomplete tasks is still complete """
self.project.amount_asked = 100
self.pay(self.project, 100)
self.project.save()
TaskFactory.create(project=self.project, status=TASK_MODEL.TaskStatuses.open)
self.project.deadline_reached()
self.assertEquals(self.project.status, self.complete)
示例10: test_bulk_status_change
def test_bulk_status_change(self, queue_mock):
for i in range(10):
TaskFactory.create()
previous_call_count = queue_mock.call_count
Task.objects.update(status='realized')
self.assertEqual(queue_mock.call_count, previous_call_count + len(Task.objects.all()),
'Analytics should be sent when update is called')
args, kwargs = queue_mock.call_args
self.assertEqual(kwargs['tags']['status'], 'realized')
示例11: setUp
def setUp(self):
super(TestProjectPeopleCount, self).setUp()
self.init_projects()
self.project = ProjectFactory.create(title='test', amount_asked=100)
self.project.status = ProjectPhase.objects.get(slug='campaign')
self.project.save()
self.user = BlueBottleUserFactory.create()
self.another_user = BlueBottleUserFactory.create()
self.task = TaskFactory.create(
project=self.project, people_needed=10, status='open')
self.other_task = TaskFactory.create(
project=self.project, people_needed=10, status='open')
示例12: setUp
def setUp(self):
super(TestTaskMails, self).setUp()
self.init_projects()
self.status_running = ProjectPhase.objects.get(slug='campaign')
self.project = ProjectFactory.create(status=self.status_running)
self.task = TaskFactory.create(project=self.project)
示例13: test_tags_generation
def test_tags_generation(self, queue_mock):
user = BlueBottleUserFactory.create()
task = TaskFactory.create(author=user, people_needed=2)
task_member = TaskMemberFactory.create(time_spent=10.5, member=user, task=task, status='applied')
project = task.project
expected_tags = {
'type': 'task_member',
'tenant': u'test',
'status': 'applied',
'location': '',
'location_group': '',
'country': task.project.country.name,
'theme': project.theme.name,
'theme_slug': project.theme.slug,
}
expected_fields = {
'id': task_member.id,
'task_id': task.id,
'user_id': user.id,
'hours': int(task_member.time_spent)
}
args, kwargs = queue_mock.call_args
self.assertEqual(kwargs['tags'], expected_tags)
self.assertEqual(kwargs['fields'], expected_fields)
示例14: setUp
def setUp(self):
super(TaskEmailTests, self).setUp()
self.some_user = BlueBottleUserFactory.create(first_name='King')
self.another_user = BlueBottleUserFactory.create(first_name='Kong')
self.some_project = ProjectFactory.create()
self.task = TaskFactory.create(
status=TASK_MODEL.TaskStatuses.in_progress,
author=self.some_project.owner,
)
self.taskmember1 = TaskMemberFactory.create(
member=self.some_user,
status=TASKS_MEMBER_MODEL.TaskMemberStatuses.applied,
task=self.task
)
self.taskmember2 = TaskMemberFactory.create(
member=self.another_user,
status=TASKS_MEMBER_MODEL.TaskMemberStatuses.applied,
task=self.task
)
self.task.save()
示例15: setUp
def setUp(self):
super(TaskApiTestcase, self).setUp()
self.init_projects()
self.some_user = BlueBottleUserFactory.create()
self.some_token = "JWT {0}".format(self.some_user.get_jwt_token())
campaign_status = ProjectPhase.objects.get(slug='campaign')
self.some_project = ProjectFactory.create(owner=self.some_user,
status=campaign_status)
self.task1 = TaskFactory.create(
status=Task.TaskStatuses.open,
author=self.some_project.owner,
project=self.some_project,
people_needed=2
)
self.another_user = BlueBottleUserFactory.create()
self.another_token = "JWT {0}".format(self.another_user.get_jwt_token())
self.yet_another_user = BlueBottleUserFactory.create()
self.yet_another_token = "JWT {0}".format(
self.yet_another_user.get_jwt_token())
self.previews_url = reverse('project_preview_list')
self.task_preview_url = reverse('task_preview_list')
self.tasks_url = reverse('task_list')
self.task_member_url = reverse('task_member_list')