Ejemplo n.º 1
0
    def test_no_assignees_fails(self):
        """Test that the validation fails if the order doesn't have any assignees."""
        order = OrderFactory(assignees=[])

        validator = AssigneesFilledInSubValidator()

        with pytest.raises(ValidationError) as exc:
            validator(order=order)

        assert exc.value.detail == {
            'assignees': ['You need to add at least one assignee.'],
        }
Ejemplo n.º 2
0
    def test_no_lead_assignee_fails(self):
        """Test that the validation fails if there's no lead assignee."""
        order = OrderFactory()
        order.assignees.update(is_lead=False)

        validator = AssigneesFilledInSubValidator()

        with pytest.raises(ValidationError) as exc:
            validator(order=order)

        assert exc.value.detail == {
            'assignee_lead': ['You need to set a lead assignee.'],
        }
Ejemplo n.º 3
0
    def test_non_zero_estimated_time_succeeds(self):
        """
        Test that the validation succeeds if the combined estimated time of the assignees
        is greater than zero.
        """
        order = OrderFactory()
        assert order.assignees.aggregate(sum=Sum('estimated_time'))['sum'] > 0

        validator = AssigneesFilledInSubValidator()

        try:
            validator(order=order)
        except Exception:
            pytest.fail('Should not raise a validator error.')
Ejemplo n.º 4
0
    def test_no_estimated_time_fails(self):
        """
        Test that the validation fails if the combined estimated time of the assignees
        is zero.
        """
        order = OrderFactory()
        order.assignees.update(estimated_time=0)

        validator = AssigneesFilledInSubValidator()

        with pytest.raises(ValidationError) as exc:
            validator(order=order)

        assert exc.value.detail == {
            'assignee_time': ['The total estimated time cannot be zero.'],
        }