first commit
This commit is contained in:
32
tests/test_errors.py
Normal file
32
tests/test_errors.py
Normal file
@@ -0,0 +1,32 @@
|
||||
from io import BytesIO
|
||||
|
||||
from app.extensions import db
|
||||
from app.models import AppSetting
|
||||
|
||||
|
||||
def test_not_found(client):
|
||||
response = client.get('/missing-page')
|
||||
assert response.status_code == 404
|
||||
|
||||
|
||||
def test_json_404(client):
|
||||
response = client.get('/missing-page', headers={'Accept': 'application/json'})
|
||||
assert response.status_code == 404
|
||||
assert response.is_json
|
||||
assert response.get_json()['status_code'] == 404
|
||||
|
||||
|
||||
def test_large_upload_returns_413(logged_user, app):
|
||||
with app.app_context():
|
||||
AppSetting.set('max_upload_mb', '1')
|
||||
db.session.commit()
|
||||
data = {
|
||||
'title': 'Huge file',
|
||||
'amount': '10.00',
|
||||
'currency': 'PLN',
|
||||
'purchase_date': '2026-03-10',
|
||||
'payment_method': 'card',
|
||||
'document': (BytesIO(b'x' * (2 * 1024 * 1024)), 'big.jpg'),
|
||||
}
|
||||
response = logged_user.post('/expenses/create', data=data, content_type='multipart/form-data')
|
||||
assert response.status_code == 413
|
||||
Reference in New Issue
Block a user