summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcello Stanisci <stanisci.m@gmail.com>2017-11-03 17:05:41 +0100
committerMarcello Stanisci <stanisci.m@gmail.com>2017-11-03 17:05:41 +0100
commit5c876a276c7cc14d18751e22e90d8274e526da20 (patch)
tree84610412dadbf6f45d941422f1c880b0c32fdc46
parent505cbc42020eff1442d1a7f427299a49eea136db (diff)
downloadbank-5c876a276c7cc14d18751e22e90d8274e526da20.tar.gz
bank-5c876a276c7cc14d18751e22e90d8274e526da20.tar.bz2
bank-5c876a276c7cc14d18751e22e90d8274e526da20.zip
pylint
-rw-r--r--talerbank/app/checks.py11
-rw-r--r--talerbank/app/models.py9
-rw-r--r--talerbank/app/schemas.py22
3 files changed, 19 insertions, 23 deletions
diff --git a/talerbank/app/checks.py b/talerbank/app/checks.py
index 6734d3a..7d50adb 100644
--- a/talerbank/app/checks.py
+++ b/talerbank/app/checks.py
@@ -1,4 +1,4 @@
-from django.core.checks import register, Warning
+from django.core.checks import register
from django.db.utils import OperationalError
@@ -16,9 +16,8 @@ def example_check(app_configs, **kwargs):
id='talerbank.E001'
))
except OperationalError:
- errors.append(Warning(
- 'Presumably non existent database',
- hint="create a database for the application",
- id='talerbank.E002'
- ))
+ errors.append(Warning(
+ 'Presumably non existent database',
+ hint="create a database for the application",
+ id='talerbank.E002'))
return errors
diff --git a/talerbank/app/models.py b/talerbank/app/models.py
index ebbb9f0..064dbed 100644
--- a/talerbank/app/models.py
+++ b/talerbank/app/models.py
@@ -19,12 +19,13 @@ from __future__ import unicode_literals
from django.contrib.auth.models import User
from django.db import models
from django.conf import settings
+from django.core.exceptions import ValidationError
from . import amount
class AmountField(models.Field):
-
+
description = 'Amount object in Taler style'
-
+
def __init__(self, *args, **kwargs):
super(AmountField, self).__init__(*args, **kwargs)
@@ -53,8 +54,8 @@ class AmountField(models.Field):
if None is value:
return amount.Amount.parse(settings.TALER_CURRENCY)
return amount.Amount.parse(value)
- except amount.BadAmount:
- raise models.ValidationError()
+ except amount.BadFormatAmount:
+ raise ValidationError("Invalid input for an amount string: %s" % value)
def get_zero_amount():
return amount.Amount(settings.TALER_CURRENCY)
diff --git a/talerbank/app/schemas.py b/talerbank/app/schemas.py
index 91771d1..e43947d 100644
--- a/talerbank/app/schemas.py
+++ b/talerbank/app/schemas.py
@@ -20,9 +20,8 @@ definitions of JSON schemas for validating data
"""
import validictory
-from django.core.exceptions import ValidationError
-wiredetails_schema = {
+WIREDETAILS_SCHEMA = {
"type": "object",
"properties": {
"test": {
@@ -37,7 +36,7 @@ wiredetails_schema = {
}
}
-auth_schema = {
+AUTH_SCHEMA = {
"type": "object",
"properties": {
"type": {"type": "string"},
@@ -45,7 +44,7 @@ auth_schema = {
}
}
-amount_schema = {
+AMOUNT_SCHEMA = {
"type": "object",
"properties": {
"value": {"type": "integer"},
@@ -54,25 +53,22 @@ amount_schema = {
}
}
-incoming_request_schema = {
+INCOMING_REQUEST_SCHEMA = {
"type": "object",
"properties": {
- "amount": {"type": amount_schema},
+ "amount": {"type": AMOUNT_SCHEMA},
"wtid": {"type": "string"},
"exchange_url": {"type": "string"},
"credit_account": {"type": "integer"},
- "auth": auth_schema
+ "auth": AUTH_SCHEMA
}
}
def validate_amount(amount):
- validictory.validate(amount, amount_schema)
+ validictory.validate(amount, AMOUNT_SCHEMA)
def validate_wiredetails(wiredetails):
- validictory.validate(wiredetails, wiredetails_schema)
+ validictory.validate(wiredetails, WIREDETAILS_SCHEMA)
def validate_incoming_request(incoming_request):
- validictory.validate(incoming_request, incoming_request_schema)
-
-def validate_auth_basic(auth_basic):
- validictory.validate(auth_basic, auth_basic_schema)
+ validictory.validate(incoming_request, INCOMING_REQUEST_SCHEMA)