Skip to content

Commit

Permalink
Add test for container flow generator
Browse files Browse the repository at this point in the history
  • Loading branch information
1kastner committed May 24, 2024
1 parent 93027b5 commit 34498a2
Showing 1 changed file with 57 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
from conflowgen.application.repositories.container_flow_generation_properties_repository import \
ContainerFlowGenerationPropertiesRepository
from conflowgen.database_connection.create_tables import create_tables
from conflowgen.domain_models.container import Container
from conflowgen.domain_models.distribution_models.container_dwell_time_distribution import \
ContainerDwellTimeDistribution
from conflowgen.domain_models.distribution_models.mode_of_transport_distribution import ModeOfTransportDistribution
from conflowgen.domain_models.distribution_models.storage_requirement_distribution import StorageRequirementDistribution
from conflowgen.domain_models.distribution_seeders import mode_of_transport_distribution_seeder, \
seed_all_distributions, container_dwell_time_distribution_seeder
from conflowgen.domain_models.data_types.mode_of_transport import ModeOfTransport
from conflowgen.domain_models.vehicle import Feeder, DeepSeaVessel
from conflowgen.flow_generator.container_flow_generation_service import \
ContainerFlowGenerationService
from conflowgen.domain_models.large_vehicle_schedule import Schedule
Expand Down Expand Up @@ -100,17 +102,68 @@ def test_happy_path_no_mocking_with_ramp_up_and_ramp_down(self):
service_name="TestDeepSeaVessel",
vehicle_arrives_at=properties.start_date + datetime.timedelta(days=8),
vehicle_arrives_at_time=datetime.time(11),
average_vehicle_capacity=800,
average_moved_capacity=100,
average_vehicle_capacity=12000,
average_moved_capacity=1000,
next_destinations=None
)
port_call_manager.add_vehicle(
vehicle_type=ModeOfTransport.deep_sea_vessel,
service_name="TestDeepSeaVessel2",
vehicle_arrives_at=properties.end_date - datetime.timedelta(days=2),
vehicle_arrives_at_time=datetime.time(11),
average_vehicle_capacity=800,
average_moved_capacity=100,
average_vehicle_capacity=12000,
average_moved_capacity=1000,
next_destinations=None
)
self.container_flow_generator_service.generate()

reference = list(Container.select())

# Vehicle 1 - inbound during ramp-up untouched
feeder = Feeder.select().where(
Feeder.large_scheduled_vehicle.name == "TestFeeder"
)
feeder_instance = list(feeder)[0]

Check failure on line 126 in conflowgen/tests/flow_generator/test_container_flow_generator_service__generate.py

View workflow job for this annotation

GitHub Actions / Run unittests

TestContainerFlowGeneratorService__generate.test_happy_path_no_mocking_with_ramp_up_and_ramp_down IndexError: list index out of range
number_containers_during_ramp_up = Container.select().where(
Container.delivered_by_large_scheduled_vehicle == feeder
).count()
self.assertLess(
number_containers_during_ramp_up,
100
)
self.assertGreater(
number_containers_during_ramp_up,
50
)

# Vehicle 2 - no effect
deep_sea_vessel_1 = DeepSeaVessel.select().where(
DeepSeaVessel.large_scheduled_vehicle.name == "TestDeepSeaVessel"
)
number_containers_in_normal_phase = Container.select().where(
Container.picked_up_by_large_scheduled_vehicle == deep_sea_vessel_1
).count()
self.assertLess(
number_containers_in_normal_phase,
1000
)
self.assertGreater(
number_containers_in_normal_phase,
500
)

# Vehicle 3 - inbound volume during ramp-down throttled
deep_sea_vessel_2 = DeepSeaVessel.select().where(
DeepSeaVessel.large_scheduled_vehicle.name == "TestDeepSeaVessel2"
)
number_containers_during_ramp_down = Container.select().where(
Container.delivered_by_large_scheduled_vehicle == deep_sea_vessel_2
).count()
self.assertLess(
number_containers_during_ramp_down,
1000
)
self.assertGreater(
number_containers_during_ramp_down,
500
)

0 comments on commit 34498a2

Please sign in to comment.