def test_modified_since(self): # The --since parameter is parsed into a datetime using the fairly # standard YYYY-MM-DD format. script = ModifiedBranchesScript( 'modified-branches', test_args=['--since=2009-03-02']) self.assertEqual( datetime(2009, 3, 2, tzinfo=pytz.UTC), script.get_last_modified_epoch())
def test_modified_last_hours(self): # If last_hours is specified, that number of hours is removed from the # current timestamp to work out the selection epoch. script = ModifiedBranchesScript( 'modified-branches', test_args=['--last-hours=12']) # Override the script's now_timestamp to have a definitive test. # 3pm on the first of January. script.now_timestamp = datetime(2009, 1, 1, 15, tzinfo=pytz.UTC) # The last modified should be 3am on the same day. self.assertEqual( datetime(2009, 1, 1, 3, tzinfo=pytz.UTC), script.get_last_modified_epoch())