MartijnBraam / python-isc-dhcp-leases

Small python module for reading /var/lib/dhcp/dhcpd.leases from isc-dhcp-server
MIT License
123 stars 47 forks source link

Support reference datetime for examining historical dhcpd.leases #32

Closed aaron-sierra closed 4 years ago

aaron-sierra commented 4 years ago

While debugging a DHCP issue, I found myself needing to review historical dhcpd.leases files. It took me a while to realize it, but as time passed the results from my review started to change :frowning_face:

I found that this module was checking lease validity against the current system time and that testing used @freeze_time decorators.

In order to do my work, I modified the module to also support a user-specified reference datetime object when initializing classes. I think that it could be useful to others, too.

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 100.0% when pulling 4222bb362bab1b6f42a1ea23061791c82297b9af on aaron-sierra:support-reference-datetime into e96c00e31f3a52c01ef98193577d614d08a93285 on MartijnBraam:master.

aaron-sierra commented 4 years ago

In reviewing my work, I noticed that the unit tests that I'd picked for the Lease and Lease6 classes weren't sensitive to changes in the "now" time, so I moved testing from test_init() to test_valid().

MartijnBraam commented 4 years ago

Looks good, thanks for the addition