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
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')
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
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')
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()
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()
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)
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)
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')
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')