Code review comment for ~dashmage/charm-logrotated:bug-2019990/random-time-cronjob

Revision history for this message
Eric Chen (eric-chen) wrote :

> In the logic that I've written, the random number is generated between 0 and the
> total number of minutes within the provided time range and added to the start
> time. We can trust that random.randint will only return a number between 0 and
> the total minutes within the range. This will 100% return a random time between
> the start and end time.

When imeplemnting unit test, we should not have assumption how will the function been implemented. Because the implementation may be changed one day but the unit test should still work.

For example, I can pass current unit test very easily by this implementation

+ def get_random_time(self, time_range):
+ # Convert start and end times to integers
+ start_hour, start_minute, end_hour, end_minute = [int(t) for t in time_range]
+ return str(start_hour), str(start_minute)+1

Therefore, I don't agree the unit test of "get_random_time" proof the function work here.

review: Needs Fixing

« Back to merge proposal