Skip to content

Commit

Permalink
add (even) better reporting and handling of dates. closes #188
Browse files Browse the repository at this point in the history
  • Loading branch information
fontanka16 committed Apr 13, 2022
1 parent 33986a8 commit 2c22162
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
6 changes: 4 additions & 2 deletions migration_tools/transaction_migration/legacy_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def __init__(self, legacy_loan_dict, utc_difference=0, row=0):
try:
self.make_loan_utc()
if self.due_date <= self.out_date:
self.due_date = self.due_date.replace(hour=23, minute=59)
self.out_date = self.out_date.replace(hour=0, minute=1)
if self.due_date.hour == 0:
self.due_date = self.due_date.replace(hour=23, minute=59)
if self.out_date.hour == 0:
self.out_date = self.out_date.replace(hour=0, minute=1)
except Exception as ee:
self.errors.append(("Time alignment issues", "both dates"))
self.renewal_count = int(legacy_loan_dict["renewal_count"])
Expand Down
15 changes: 15 additions & 0 deletions tests/test_legacy_loan.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,18 @@ def test_init_tz():
assert legacy_loan.due_date.isoformat() == "2022-01-13T16:00:00"
assert legacy_loan.out_date.isoformat() == "2022-01-13T14:00:00"
assert legacy_loan.renewal_count > 0


def test_init_tz_2():
loan_dict = {
"item_barcode": "the barcode with trailing space ",
"patron_barcode": " the barcode with leading space",
"due_date": "2019-02-22",
"out_date": "2019-02-22 10:53:00",
"renewal_count": "1",
"next_item_status": "Checked out",
}
legacy_loan = LegacyLoan(loan_dict, 0)
assert legacy_loan.due_date.isoformat() == "2019-02-22T23:59:00"
assert legacy_loan.out_date.isoformat() == "2019-02-22T10:53:00"
assert legacy_loan.renewal_count > 0

0 comments on commit 2c22162

Please sign in to comment.