Files
mymach_fleet_intelligence/test_phase3.py

43 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

print("\n--- FAZ 3 TEST BAŞLIYOR ---")
partner = env['res.partner'].create({'name': 'Sürpriz Sürücü'})
vehicle = env['fleet.vehicle'].search([], limit=1)
vehicle.driver_id = partner.id
# 1. Sözleşme Yasaklı İken
contract = env['mymach.fleet.contract'].create({
'name': 'TEST-FAZ3',
'driver_id': partner.id,
'personal_use_policy': 'forbidden',
})
log = env['mymach.fleet.security.log'].create({
'name': 'Test GPS Log',
'vehicle_id': vehicle.id,
'status': 'exception'
})
wizard = env['mymach.fleet.route.exception.wizard'].create({
'log_id': log.id,
'vehicle_id': vehicle.id,
'exception_type': 'personal',
'description': 'Haftasonu Piknik',
'estimated_cost': 500.0
})
print("TEST_RESULT_START")
try:
wizard.action_confirm()
print("HATA: Yasaklı sözleşmeye rağmen onaylandı!")
except Exception as e:
print("BAŞARILI: Sözleşme yasağı devreye girdi ve engelledi. Hata Mesajı:", str(e))
# 2. Sözleşme İzinli İken
contract.personal_use_policy = 'allowed'
wizard.action_confirm()
print("BAŞARILI: İzinli sözleşme onaylandı.")
print("Log Kesinti Tutarı (Beklenen 500.0):", log.deduction_amount)
print("Log Çözüldü Mü (Beklenen True):", log.is_resolved)
print("TEST_RESULT_END")
print("--- FAZ 3 TEST BİTTİ ---\n")
env.cr.rollback()