示例#1
0
 def test_cef_not(self, _log_cef):
     form = UpdateForm({'status': constants.STATUS_PENDING},
         original_data={'created': datetime.now(),
                        'status': constants.STATUS_PENDING},
         request=self.req)
     assert form.is_valid()
     assert not _log_cef.called
示例#2
0
 def test_cef_failed(self, _log_cef):
     form = UpdateForm({'status': constants.STATUS_PENDING},
         original_data={'created': datetime.now(),
                        'status': constants.STATUS_CANCELLED},
         request=self.req)
     assert not form.is_valid()
     _log_cef.assert_called_with('Transaction change failure', 7, ANY,
         msg='Transaction change failure', config=ANY, signature=ANY,
         cs7Label='new', cs6Label='old', cs6='cancelled', cs7='pending')
示例#3
0
 def test_cef_not(self, _log_cef):
     form = UpdateForm({'status': constants.STATUS_PENDING},
                       original_data={
                           'created': datetime.now(),
                           'status': constants.STATUS_PENDING
                       },
                       request=self.req)
     assert form.is_valid()
     assert not _log_cef.called
示例#4
0
 def test_cef_ok(self, _log_cef):
     form = UpdateForm({'status': constants.STATUS_CHECKED},
         original_data={'created': datetime.now(),
                        'status': constants.STATUS_COMPLETED},
         request=self.req)
     assert form.is_valid()
     _log_cef.assert_called_with('Transaction change success', 5, ANY,
         msg='Transaction change success', config=ANY, signature=ANY,
         cs7Label='new', cs6Label='old', cs6='completed', cs7='checked')
示例#5
0
 def test_provide_set_twice(self):
     form = UpdateForm(
         {'status': constants.STATUS_CHECKED,
          'provider': constants.PROVIDER_REFERENCE},
         original_data={
             'created': datetime.now(),
             'status': constants.STATUS_COMPLETED,
             'provider': constants.PROVIDER_BANGO,
             'seller_product': 1,
         },
         request=self.req)
     assert not form.is_valid()
示例#6
0
 def test_provide_set_twice(self):
     form = UpdateForm(
         {
             'status': constants.STATUS_CHECKED,
             'provider': constants.PROVIDER_REFERENCE
         },
         original_data={
             'created': datetime.now(),
             'status': constants.STATUS_COMPLETED,
             'provider': constants.PROVIDER_BANGO,
             'seller_product': 1,
         },
         request=self.req)
     assert not form.is_valid()
示例#7
0
    def update(self, request, *args, **kwargs):
        # Disallow PUT, but allow PATCH.
        if not kwargs.get('partial', False):
            return Response(status=405)

        # We only allow very limited transaction changes.
        self.object = self.get_object_or_none()
        form = UpdateForm(request.DATA,
                          original_data=self.object.to_dict(),
                          request=request)
        if form.is_valid():
            return (super(TransactionViewSet,
                          self).update(request, *args, **kwargs))

        return self.form_errors(form)
示例#8
0
    def update(self, request, *args, **kwargs):
        # Disallow PUT, but allow PATCH.
        if not kwargs.get('partial', False):
            return Response(status=405)

        # We only allow very limited transaction changes.
        self.object = self.get_object_or_none()
        form = UpdateForm(
            request.DATA, original_data=self.object.to_dict(), request=request)
        if form.is_valid():
            return (
                super(TransactionViewSet, self)
                .update(request, *args, **kwargs)
            )

        return self.form_errors(form)
示例#9
0
 def test_cef_failed(self, _log_cef):
     form = UpdateForm({'status': constants.STATUS_PENDING},
                       original_data={
                           'created': datetime.now(),
                           'status': constants.STATUS_CANCELLED
                       },
                       request=self.req)
     assert not form.is_valid()
     _log_cef.assert_called_with('Transaction change failure',
                                 7,
                                 ANY,
                                 msg='Transaction change failure',
                                 config=ANY,
                                 signature=ANY,
                                 cs7Label='new',
                                 cs6Label='old',
                                 cs6='cancelled',
                                 cs7='pending')
示例#10
0
 def test_cef_ok(self, _log_cef):
     form = UpdateForm({'status': constants.STATUS_CHECKED},
                       original_data={
                           'created': datetime.now(),
                           'status': constants.STATUS_COMPLETED
                       },
                       request=self.req)
     assert form.is_valid()
     _log_cef.assert_called_with('Transaction change success',
                                 5,
                                 ANY,
                                 msg='Transaction change success',
                                 config=ANY,
                                 signature=ANY,
                                 cs7Label='new',
                                 cs6Label='old',
                                 cs6='completed',
                                 cs7='checked')