Compare commits
No commits in common. "0082ee2bad9bf66cac204667d91b2d27e6604ddd" and "25a0f902ab174320d384b9423f183572d2123dea" have entirely different histories.
0082ee2bad
...
25a0f902ab
5 changed files with 43 additions and 51 deletions
|
@ -66,7 +66,7 @@ def validate(entity):
|
||||||
'email': {
|
'email': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True,
|
'required': True,
|
||||||
'check_with': valid_email},
|
'regex': '^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+.[a-zA-Z0-9-.]+$'},
|
||||||
'fullname': {
|
'fullname': {
|
||||||
'type': 'string',
|
'type': 'string',
|
||||||
'required': True},
|
'required': True},
|
||||||
|
|
|
@ -2,5 +2,4 @@ tornado==6.0.4
|
||||||
isodate==0.6.0
|
isodate==0.6.0
|
||||||
pytest==5.4.1
|
pytest==5.4.1
|
||||||
schwifty==2020.11.0
|
schwifty==2020.11.0
|
||||||
Cerberus==1.3.2
|
Cerberus==1.3.2
|
||||||
validator-collection==1.5.0
|
|
42
test.py
42
test.py
|
@ -58,11 +58,49 @@ class TestValidation(tornado.testing.AsyncHTTPTestCase):
|
||||||
self.assertFalse(validation_result['valid'], "Validation result is expected to be valid==false")
|
self.assertFalse(validation_result['valid'], "Validation result is expected to be valid==false")
|
||||||
|
|
||||||
def test_valid_entity(self):
|
def test_valid_entity(self):
|
||||||
entity_file = json.load(open('test_cases/valid/valid.json','r'))
|
entity = {
|
||||||
|
'finanzdaten':
|
||||||
|
{
|
||||||
|
'bic': 'PBNKDEFFXXX',
|
||||||
|
'holder': '',
|
||||||
|
'iban': 'DE89370400440532013000',
|
||||||
|
'issuance': '2012-01-01',
|
||||||
|
'reference': '0042',
|
||||||
|
'scan-sepa-mandate': ''
|
||||||
|
},
|
||||||
|
'mitgliederdaten':
|
||||||
|
{
|
||||||
|
'bis': '',
|
||||||
|
'mitgliedsbeitrag': '30',
|
||||||
|
'scan-antrag': '',
|
||||||
|
'schliessberechtigung': 'Ja',
|
||||||
|
'spendenbeitrag': '0',
|
||||||
|
'status': 'V',
|
||||||
|
'von': '2012-01-01'
|
||||||
|
},
|
||||||
|
'stammdaten':
|
||||||
|
{
|
||||||
|
'address_code': '39104',
|
||||||
|
'address_country': 'DE',
|
||||||
|
'address_label': 'Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg',
|
||||||
|
'address_locality': 'Magdeburg',
|
||||||
|
'address_region': '',
|
||||||
|
'address_street': 'Leibnizstr. 32',
|
||||||
|
'birth_date': '1970-01-01',
|
||||||
|
'birth_location': 'Hackstadt',
|
||||||
|
'email': 'max.hackerberg@netz39.de',
|
||||||
|
'fullname': 'Max Hackerberg',
|
||||||
|
'nickname': 'maxH',
|
||||||
|
'pgp-key': '',
|
||||||
|
'ssh-key': ''
|
||||||
|
},
|
||||||
|
'timestamp': '2020-03-25T23:58:11',
|
||||||
|
'id': '6af68'
|
||||||
|
}
|
||||||
|
|
||||||
response = self.fetch('/v0/validate',
|
response = self.fetch('/v0/validate',
|
||||||
method='POST',
|
method='POST',
|
||||||
body=json.dumps(entity_file))
|
body=json.dumps(entity))
|
||||||
|
|
||||||
self.assertEqual(200, response.code, "Validation must always return 200")
|
self.assertEqual(200, response.code, "Validation must always return 200")
|
||||||
|
|
||||||
|
|
|
@ -1,36 +0,0 @@
|
||||||
{
|
|
||||||
"finanzdaten": {
|
|
||||||
"bic": "PBNKDEFFXXX",
|
|
||||||
"holder": "",
|
|
||||||
"iban": "DE89370400440532013000",
|
|
||||||
"issuance": "2012-01-01",
|
|
||||||
"reference": "0042",
|
|
||||||
"scan-sepa-mandate": ""
|
|
||||||
},
|
|
||||||
"mitgliederdaten": {
|
|
||||||
"bis": "",
|
|
||||||
"mitgliedsbeitrag": "30",
|
|
||||||
"scan-antrag": "",
|
|
||||||
"schliessberechtigung": "Ja",
|
|
||||||
"spendenbeitrag": "0",
|
|
||||||
"status": "V",
|
|
||||||
"von": "2012-01-01"
|
|
||||||
},
|
|
||||||
"stammdaten": {
|
|
||||||
"address_code": "39104",
|
|
||||||
"address_country": "DE",
|
|
||||||
"address_label": "Max Hackerberg\nLeibnizstr. 32\n39104 Magdeburg",
|
|
||||||
"address_locality": "Magdeburg",
|
|
||||||
"address_region": "",
|
|
||||||
"address_street": "Leibnizstr. 32",
|
|
||||||
"birth_date": "1970-01-01",
|
|
||||||
"birth_location": "Hackstadt",
|
|
||||||
"email": "max.hackerberg@netz39.de",
|
|
||||||
"fullname": "Max Hackerberg",
|
|
||||||
"nickname": "maxH",
|
|
||||||
"pgp-key": "",
|
|
||||||
"ssh-key": ""
|
|
||||||
},
|
|
||||||
"timestamp": "2020-03-25T23:58:11",
|
|
||||||
"id": "6af68"
|
|
||||||
}
|
|
|
@ -1,6 +1,5 @@
|
||||||
from schwifty import IBAN, BIC
|
from schwifty import IBAN, BIC
|
||||||
import datetime
|
import datetime
|
||||||
from validator_collection import validators, errors
|
|
||||||
|
|
||||||
def valid_iban(field, value, error):
|
def valid_iban(field, value, error):
|
||||||
try:
|
try:
|
||||||
|
@ -25,15 +24,7 @@ def iso_date(field, value, error):
|
||||||
|
|
||||||
def valid_money_amount(field, value, error):
|
def valid_money_amount(field, value, error):
|
||||||
try:
|
try:
|
||||||
# value is string, check formatting by parsing as float
|
|
||||||
float(value)
|
float(value)
|
||||||
return True
|
return True
|
||||||
except (ValueError, TypeError):
|
except (ValueError, TypeError):
|
||||||
error(field, 'not a valid money value')
|
error(field, 'not a valid money value')
|
||||||
|
|
||||||
def valid_email(field, value, error):
|
|
||||||
try:
|
|
||||||
validators.email(value)
|
|
||||||
return True
|
|
||||||
except errors.InvalidEmailError:
|
|
||||||
error(field, 'not a valid email')
|
|
Loading…
Reference in a new issue