本文整理汇总了Python中bluebottle.test.factory_models.tasks.TaskMemberFactory类的典型用法代码示例。如果您正苦于以下问题:Python TaskMemberFactory类的具体用法?Python TaskMemberFactory怎么用?Python TaskMemberFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskMemberFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: 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()
示例2: test_calculate_task_count
def test_calculate_task_count(self):
"""
Test that the task_count property on a user is calculated correctly.
We count a) tasks where a user is a task author and
b) TaskMembers where a user is applied, accepted or realized
"""
self.assertEqual(self.user.task_count, 0)
task = TaskFactory.create(author=self.user)
self.assertEqual(self.user.task_count, 1)
taskmember = TaskMemberFactory.create(
member=self.user,
status=TASKS_MEMBER_MODEL.TaskMemberStatuses.applied,
task=task
)
self.assertEqual(self.user.task_count, 2)
uncounted_taskmember = TaskMemberFactory.create(
member=self.user,
status=TASKS_MEMBER_MODEL.TaskMemberStatuses.stopped,
task=task
)
self.assertEqual(self.user.task_count, 2)
示例3: test_people_registered_expired_task
def test_people_registered_expired_task(self):
self.task.deadline = timezone.now() - timezone.timedelta(days=1)
self.task.save()
TaskMemberFactory.create(member=self.user,
task=self.task)
self.assertEqual(self.project.people_registered, 0)
示例4: test_people_registered_for_two_tasks
def test_people_registered_for_two_tasks(self):
TaskMemberFactory.create(member=self.user,
task=self.task)
TaskMemberFactory.create(member=self.user,
task=self.other_task)
self.assertEqual(self.project.people_registered, 2)
示例5: test_people_registered_closed_task
def test_people_registered_closed_task(self):
self.task.status = 'closed'
self.task.save()
TaskMemberFactory.create(member=self.user,
task=self.task)
self.assertEqual(self.project.people_registered, 0)
示例6: setUp
def setUp(self):
super(HomepageEndpointTestCase, self).setUp()
self.init_projects()
self.stats = Statistics()
"""
Create 10 Project instances for one user with half in the campaign phase
and the other half in the done-complete phase
This will create:
- 10 running or realised projects
- 10 campaigners (eg 10 new people involved)
"""
self.user1 = BlueBottleUserFactory.create()
self.campaign_phase = ProjectPhase.objects.get(slug='campaign')
self.plan_phase = ProjectPhase.objects.get(slug='done-complete')
projects = []
for char in 'abcdefghij':
# Put half of the projects in the campaign phase.
if ord(char) % 2 == 1:
project = ProjectFactory.create(title=char * 3, slug=char * 3, status=self.campaign_phase)
else:
project = ProjectFactory.create(title=char * 3, slug=char * 3, status=self.plan_phase)
projects.append(project)
"""
Create 10 TaskMember instances for one project.
This will create:
- 1 realised task
- 1 task owner (eg 1 new person involved)
- 10 task members (eg 10 new people involved)
"""
self.task = TaskFactory.create(project=projects[0], status=Task.TaskStatuses.realized)
for char in 'abcdefghij':
# Put half of the projects in the campaign phase.
if ord(char) % 2 == 1:
task = TaskMemberFactory.create(task=self.task)
else:
task = TaskMemberFactory.create(task=self.task)
"""
Create 10 Donations with half to fundraisers
This will create:
- 10 donations of 1000 (total amount of 10000)
- 10 donators (eg 10 new people involved)
- 5 fundraisers (eg 5 new people involved)
"""
for char in 'abcdefghij':
if ord(char) % 2 == 1:
self.order = OrderFactory.create(status=StatusDefinition.SUCCESS)
self.donation = DonationFactory.create(amount=1000, order=self.order, fundraiser=None)
else:
self.order = OrderFactory.create(status=StatusDefinition.SUCCESS)
self.donation = DonationFactory.create(amount=1000, order=self.order)
示例7: test_check_number_of_members_needed_no_externals_count
def test_check_number_of_members_needed_no_externals_count(self):
""" Test that 'check_number_of_members_needed' returns the right count without externals"""
task = TaskFactory.create(status='open', people_needed=4)
task_member1 = TaskMemberFactory.create(task=task, status='accepted')
self.assertEqual(task_member1.check_number_of_members_needed(task), 1)
task_member2 = TaskMemberFactory.create(task=task, status='accepted')
self.assertEqual(task_member2.check_number_of_members_needed(task), 2)
self.assertEqual(task_member1.check_number_of_members_needed(task), 2)
示例8: test_task_count
def test_task_count(self):
""" Test various task_count values """
# No task members assigned to a task of a project, so there is a task open
response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['results'][0]['task_count'], 1)
task_member = TaskMemberFactory.create(member=self.another_user, task=self.task1, status='accepted')
# The task has one task member and two people needed, still one task open
response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['results'][0]['task_count'], 1)
task_member2 = TaskMemberFactory.create(member=self.yet_another_user, task=self.task1, status='accepted')
# The task has two accepted task members for two people_needed, no more task open
response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['results'][0]['task_count'], 0)
task_member2.status = 'applied'
task_member2.save()
# FIXME: Make sure task is marked as available in the code.
# The task has one accepted task member and one applied member, still one open task
# response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
# self.assertEqual(response.data['results'][0]['task_count'], 1)
self.task1.status = BB_TASK_MODEL.TaskStatuses.closed
self.task1.save()
# The task is closed, so don't give a task_count
response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['results'][0]['task_count'], 0)
self.task1.status = BB_TASK_MODEL.TaskStatuses.realized
self.task1.save()
# The task is realized, so don't give a task_count
response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['results'][0]['task_count'], 0)
self.task1.status = BB_TASK_MODEL.TaskStatuses.open
self.task1.save()
task2 = TaskFactory.create(
status=BB_TASK_MODEL.TaskStatuses.open,
author=self.some_project.owner,
project=self.some_project,
people_needed=2
)
# There are now two tasks for the same project, so task_count gives 2
response = self.client.get(self.previews_url, HTTP_AUTHORIZATION=self.some_token)
self.assertEqual(response.data['results'][0]['task_count'], 2)
示例9: test_check_number_of_members_needed_with_externals_count
def test_check_number_of_members_needed_with_externals_count(self):
""" Test that 'check_number_of_members_needed' returns the right count with externals"""
task = TaskFactory.create(status='open', people_needed=4)
task_member1 = TaskMemberFactory.create(task=task, status='accepted',
externals=1)
self.assertEqual(task_member1.task.people_accepted, 2)
task_member2 = TaskMemberFactory.create(task=task, status='accepted',
externals=2)
self.assertEqual(task_member2.task.people_accepted, 5)
self.assertEqual(task_member1.task.people_accepted, 5)
示例10: test_bulk_status_change
def test_bulk_status_change(self, queue_mock):
for i in range(10):
TaskMemberFactory.create()
previous_call_count = queue_mock.call_count
TaskMember.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(TestProjectPopularity, self).setUp()
self.init_projects()
self.project = ProjectFactory.create()
VoteFactory.create(project=self.project)
task = TaskFactory.create(project=self.project)
TaskMemberFactory.create(task=task)
order = OrderFactory.create(status=StatusDefinition.SUCCESS)
DonationFactory(order=order, project=self.project)
示例12: test_save_check_status_update_insufficent_accepted_members
def test_save_check_status_update_insufficent_accepted_members(self):
""" Check that the save method correctly sets the status of the task if not enough task members are
accepted for the task and the save method is called """
task = TaskFactory.create(status='open', people_needed=4)
task_member1 = TaskMemberFactory.create(task=task, status='accepted', externals=1)
task.save()
self.assertEqual(task.status, 'open')
task_member2 = TaskMemberFactory.create(task=task, status='accepted')
task.save()
# Total of 3 out of 4 people. Task status should be open.
self.assertEqual(task.status, 'open')
示例13: test_task_realized_when_members_realized
def test_task_realized_when_members_realized(self):
"""
If all the task members are realized after the deadline for a task which
is not yet realized (eg. closed) then the task should also be realized.
"""
deadline = timezone.now() - timezone.timedelta(days=1)
task = TaskFactory.create(deadline=deadline, status='closed', people_needed=2)
task_member1 = TaskMemberFactory.create(task=task, status='accepted')
task_member2 = TaskMemberFactory.create(task=task, status='accepted')
task_member1.status = TaskMember.TaskMemberStatuses.realized
task_member1.save()
task_member2.status = TaskMember.TaskMemberStatuses.realized
task_member2.save()
self.assertEqual(task.status, Task.TaskStatuses.realized)
示例14: test_check_number_of_members_needed_set_in_progress
def test_check_number_of_members_needed_set_in_progress(self):
""" Test that the task status changes when enough people are accepted for a task. It shouldn't update
when insufficient people are accepted."""
task = TaskFactory.create(status='open', people_needed=4)
task_member1 = TaskMemberFactory.create(task=task, status='accepted', externals=1)
self.assertEqual(task_member1.check_number_of_members_needed(task), 2)
# Not enough people yet
self.assertEqual(task.status, 'open')
task_member2 = TaskMemberFactory.create(task=task, status='accepted', externals=2)
self.assertEqual(task_member2.check_number_of_members_needed(task), 5)
# More than people_needed have applied
self.assertEqual(task.status, 'in progress')
示例15: 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)