You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
1.3 KiB

from django.test import TestCase
from model_mommy import mommy
from examples.assignment.usecase import StrategyName, bulk_assign
from projects.models import Member, ProjectType
from projects.tests.utils import prepare_project
class TestBulkAssignment(TestCase):
def setUp(self):
self.project = prepare_project(ProjectType.SEQUENCE_LABELING)
self.member_ids = list(Member.objects.values_list("id", flat=True))
self.example = mommy.make("Example", project=self.project.item)
def test_raise_error_if_weights_is_invalid(self):
with self.assertRaises(ValueError):
bulk_assign(
self.project.item.id, StrategyName.weighted_sequential, self.member_ids, [0] * len(self.member_ids)
)
def test_raise_error_if_passing_wrong_member_ids(self):
with self.assertRaises(ValueError):
bulk_assign(
self.project.item.id,
StrategyName.weighted_sequential,
self.member_ids + [100],
[0] * len(self.member_ids),
)
def test_assign_examples(self):
bulk_assign(self.project.item.id, StrategyName.weighted_sequential, self.member_ids, [100, 0, 0])
self.assertEqual(self.example.assignments.count(), 1)
self.assertEqual(self.example.assignments.first().assignee, self.project.admin)