Commit b33f7df1 authored by Michele Del Giudice's avatar Michele Del Giudice
Browse files

Removed tests

parent b749455b
...@@ -19,14 +19,6 @@ source .venv/bin/activate ...@@ -19,14 +19,6 @@ source .venv/bin/activate
pip install -r requirements.txt pip install -r requirements.txt
``` ```
Run tests:
```bash
/your/path/to/.venv/bin/python -m pytest -q
# or simply
pytest -q
```
Run the app: Run the app:
```bash ```bash
......
...@@ -3,5 +3,3 @@ Flask-SQLAlchemy>=3.0 ...@@ -3,5 +3,3 @@ Flask-SQLAlchemy>=3.0
PyMySQL>=1.0 PyMySQL>=1.0
cryptography==46.0.3 cryptography==46.0.3
Flask-Migrate>=4.0 Flask-Migrate>=4.0
pytest>=7.0
pytest-flask>=1.2
\ No newline at end of file
import json
from datetime import datetime, timedelta
import pytest
from app import app as flask_app
from models import db, Car
@pytest.fixture
def app():
app = flask_app
app.config.update({
'TESTING': True,
# Use in-memory SQLite for tests
'SQLALCHEMY_DATABASE_URI': 'sqlite:///:memory:',
})
with app.app_context():
db.create_all()
yield app
db.session.remove()
db.drop_all()
@pytest.fixture
def client(app):
return app.test_client()
def test_create_and_get_car(client):
payload = {
'name': 'Test Car',
'seats': 4,
'ports': 3,
'type': 'small',
'brand': 'TestBrand',
'license_plate': 'TEST-123'
}
rv = client.post('/cars', json=payload)
assert rv.status_code == 201
data = rv.get_json()
assert data['name'] == 'Test Car'
# GET list
rv2 = client.get('/cars')
assert rv2.status_code == 200
arr = rv2.get_json()
assert any(c['license_plate'] == 'TEST-123' for c in arr)
def test_create_reservation(client):
# Create car first
car_payload = {
'name': 'Reserve Car',
'seats': 5,
'ports': 5,
'type': 'suv',
'brand': 'BrandX',
'license_plate': 'RES-001'
}
rv = client.post('/cars', json=car_payload)
assert rv.status_code == 201
car = rv.get_json()
pickup = datetime.utcnow()
return_dt = pickup + timedelta(days=2)
res_payload = {
'pickup_date': pickup.isoformat(),
'return_date': return_dt.isoformat(),
'car_id': car['id'],
'customer_fullname': 'John Tester',
'drive_license': 'DL-0001'
}
rv2 = client.post('/reservations', json=res_payload)
assert rv2.status_code == 201
res = rv2.get_json()
assert res['car_id'] == car['id']
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment