Skip to content
This repository has been archived by the owner on May 10, 2023. It is now read-only.

Commit

Permalink
* Included tests for "Fleet". #41
Browse files Browse the repository at this point in the history
* Included test for "Vehicle.as_dict()".
  • Loading branch information
garciparedes committed Sep 1, 2019
1 parent 5de538f commit 99875c2
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/test_models/test_fleets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import unittest

import jinete as jit

from tests.utils import (
generate_vehicles,
)


class TestFleet(unittest.TestCase):

def test_construction(self):
vehicles = generate_vehicles(3)
fleet = jit.Fleet(vehicles)

self.assertIsInstance(fleet, jit.Fleet)
self.assertEqual(fleet.vehicles, vehicles)

def test_as_dict(self):
vehicles = generate_vehicles(3)
fleet = jit.Fleet(vehicles)

vehicles_str = ', '.join(str(vehicle) for vehicle in vehicles)
expected = {
'vehicles': f'{{{vehicles_str}}}'
}
self.assertEqual(expected, fleet.as_dict())


if __name__ == '__main__':
unittest.main()
18 changes: 18 additions & 0 deletions tests/test_models/test_vehicles.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,24 @@ def test_vehicle_with_timeout(self):
self.assertEqual(vehicle.timeout, timeout)
self.assertIsInstance(vehicle.uuid, UUID)

def test_as_dict(self):
initial = generate_one_position()
identifier = str(0)
vehicle = jit.Vehicle(identifier, initial)

expected = {
'initial': vehicle.initial,
'final': vehicle.final,
'capacity': vehicle.capacity,
'earliest': vehicle.earliest,
'timeout': vehicle.timeout,
'route_timeout': vehicle.route_timeout,
'trip_timeout': vehicle.trip_timeout,
'latest': vehicle.latest,
'uuid': vehicle.uuid,
}

self.assertEqual(expected, vehicle.as_dict())

if __name__ == '__main__':
unittest.main()

0 comments on commit 99875c2

Please sign in to comment.