prvi kod za live uporabu
Some checks failed
ERP CI Pipeline / test (push) Has been cancelled

This commit is contained in:
mariomitte
2026-07-09 21:21:17 +02:00
parent 857bb65d52
commit 5d39e048ba
239 changed files with 25151 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
import pytest
from django.core.exceptions import ValidationError
from modules.fleet.models import Vehicle
from django.contrib.auth import get_user_model
@pytest.mark.django_db
def test_vehicle_servicer_one_to_one_constraint(test_user):
# Prvo vozilo prolazi
Vehicle.objects.create(registration_number="ZG-111-AA", assigned_servicer=test_user)
# Drugo vozilo za istog servisera mora baciti IntegrityError
with pytest.raises(Exception): # Django IntegrityError
Vehicle.objects.create(registration_number="ZG-222-BB", assigned_servicer=test_user)
@pytest.mark.django_db
def test_vehicle_next_service_logic():
# current=12000, interval=15000 -> next_service_at = 15000
vehicle = Vehicle.objects.create(
registration_number="ZG-001",
current_mileage=12000,
service_interval_km=15000
)
assert vehicle.next_service_at() == 15000
# current=16000, interval=15000 -> next_service_at = 30000
vehicle.current_mileage = 16000
assert vehicle.next_service_at() == 30000