Skip to content

Commit

Permalink
fix executiondate in technicallogbookorders
Browse files Browse the repository at this point in the history
also add a small test

see #6
  • Loading branch information
diegoquintanav committed Oct 21, 2020
1 parent 42be14b commit 6166c24
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 12 additions & 7 deletions project/providers/airport.py
Original file line number Diff line number Diff line change
Expand Up @@ -1404,20 +1404,25 @@ def technical_logbook_order(
# repairing of the problem in the aircraft, respectively.

mel = self.mel_category_kind(quality=quality)
planned = self.flight_timestamp(quality=quality)
deadline = planned + self.reporting_deadline_duration(mel_type=mel)
due = self.flight_timestamp(quality=quality)
reportingdate = due + self.reporting_deadline_duration(mel_type=mel)
executiondate = self.generator.date_time_ad(
end_datetime=due, start_datetime=reportingdate
)

workpackageid = getattr(work_package, "workpackageid", None)

order = amos.TechnicalLogbookOrder(
workorderid=work_package.workpackageid or self.random_int(max=max_id),
workorderid=workpackageid or self.random_int(max=max_id),
aircraftregistration=self.aircraft_registration_code(quality=quality),
executiondate=self.flight_timestamp(quality=quality),
executiondate=executiondate,
executionplace=self.airport_code(quality=quality),
workpackage=self.work_package(quality=quality).workpackageid,
kind="TechnicalLogBook",
reporteurclass=self.report_kind(quality=quality),
reporteurid=self.reporter(quality=quality).reporteurid,
reportingdate=planned,
due=deadline,
reportingdate=reportingdate,
due=due,
deferred=self.generator.pybool(),
mel=mel,
)
Expand Down Expand Up @@ -1584,7 +1589,7 @@ def flight_slot(self, *args, **kwargs) -> aims.FlightSlot:
actual_arrival = None
actual_departure = None
else:
delay = self.duration(max_minutes = max_delay)
delay = self.duration(max_minutes=max_delay)
delay_code = self.delay_code(quality=quality)
actual_departure = scheduled_departure + delay
actual_arrival = scheduled_arrival + delay
Expand Down
6 changes: 6 additions & 0 deletions tests/test_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,9 @@ def test_forecasted_orders_have_valid_executiondate(fake):
assert fo.executiondate <= fo.deadline
assert fo.executiondate >= fo.planned


def test_tlb_orders_have_valid_executiondate(fake):

tlb = fake.technical_logbook_order()
assert tlb.executiondate <= tlb.due
assert tlb.executiondate >= tlb.reportingdate

0 comments on commit 6166c24

Please sign in to comment.