def test_fails_if_theres_already_an_active_quote(self, validators):
        """Test raises APIConflictException if there's already an active quote."""
        validators.NoOtherActiveQuoteExistsValidator.side_effect = APIConflictException(
            'error')

        order = OrderFactory()
        with pytest.raises(APIConflictException):
            order.generate_quote(by=None)
예제 #2
0
    def __call__(self, data=None, order=None):
        """Validate that the order is in one of the statuses."""
        if not order and not self.order_required:
            return  # all fine

        if order.status not in self.allowed_statuses:
            raise APIConflictException(
                self.message.format(order.get_status_display()), )
예제 #3
0
 def _change_status(self, status, by, details):
     """Change status of a proposition."""
     if self.status != PropositionStatus.ONGOING:
         raise APIConflictException(
             f'The action cannot be performed in the current status {self.status}.',
         )
     self.status = status
     self.modified_by = by
     self.details = details
     self.save()
예제 #4
0
 def __call__(self, data=None, order=None):
     """Validate that no other active quote exists."""
     if order.quote and not order.quote.is_cancelled():
         raise APIConflictException(self.message)