Skip to content

Commit

Permalink
[IMP] fleet_vehicle_capacity: add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelsavegnago committed Sep 4, 2024
1 parent 069f332 commit eff28e2
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
1 change: 1 addition & 0 deletions fleet_vehicle_capacity/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from . import test_fleet_vehicle_capacity
70 changes: 70 additions & 0 deletions fleet_vehicle_capacity/tests/test_fleet_vehicle_capacity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Copyright 2024 - TODAY, Marcel Savegnago <marcel.savegnago@escodoo.com.br>
# License AGPL-3.0 or later (https://www.gnu.org/licenses/agpl).

from odoo.tests import common


class TestFleetVehicleCapacity(common.TransactionCase):
def setUp(self):
super(TestFleetVehicleCapacity, self).setUp()

self.uom_ton = self.env.ref("uom.product_uom_ton")
self.uom_m3 = self.env.ref("uom.product_uom_cubic_meter")
self.uom_unit = self.env.ref("uom.product_uom_unit")

self.res_config_settings = self.env["res.config.settings"].create(
{
"vehicle_weight_uom_id": self.uom_ton.id,
"vehicle_volume_uom_id": self.uom_m3.id,
"vehicle_passenger_uom_id": self.uom_unit.id,
}
)

self.res_config_settings.execute()

self.vehicle_model = self.env["fleet.vehicle.model"].create(
{
"name": "Test Model",
"vehicle_weight": 5.0,
"weight_capacity": 2.0,
"volume_capacity": 10.0,
"passenger_capacity": 4.0,
}
)

def test_default_vehicle_weight_uom(self):
self.assertEqual(
self.vehicle_model.weight_uom_id,
self.uom_ton,
"Default Vehicle Weight UOM is incorrect",
)

def test_default_vehicle_volume_uom(self):
self.assertEqual(
self.vehicle_model.volume_uom_id,
self.uom_m3,
"Default Vehicle Volume UOM is incorrect",
)

def test_default_vehicle_passenger_uom(self):
self.assertEqual(
self.vehicle_model.passenger_uom_id,
self.uom_unit,
"Default Vehicle Passenger UOM is incorrect",
)

def test_vehicle_model_fields(self):
self.assertEqual(
self.vehicle_model.vehicle_weight, 5.0, "Vehicle weight is incorrect"
)
self.assertEqual(
self.vehicle_model.weight_capacity, 2.0, "Weight capacity is incorrect"
)
self.assertEqual(
self.vehicle_model.volume_capacity, 10.0, "Volume capacity is incorrect"
)
self.assertEqual(
self.vehicle_model.passenger_capacity,
4.0,
"Passenger capacity is incorrect",
)

0 comments on commit eff28e2

Please sign in to comment.