'Test should_autodeploy() and should_autorenew() on the basis
of expiry time windows.'

@mock.patch('certbot.storage.datetime')
def test_time_interval_judgments(self, mock_datetime):

    test_cert = test_util.load_vector('cert.pem')
    self._write_out_ex_kinds()
    self.test_rc.update_all_links_to(12)
    with open(self.test_rc.cert, 'wb') as f:
        f.write(test_cert)
    self.test_rc.update_all_links_to(11)
    with open(self.test_rc.cert, 'wb') as f:
        f.write(test_cert)
    mock_datetime.timedelta = datetime.timedelta
    for (current_time, interval, result) in [(1418472000, '2    months', True), (1418472000, '1    week', True), (1418472000, '4    days', False), (1418472000, '2    days', False), (1241179200, '7    years', True), (1241179200, '11    years    2    months', True), (1241179200, '8    hours', False), (1241179200, '2    days', False), (1241179200, '40    days', False), (1241179200, '9    months', False), (1420070400, '0    seconds', True), (1420070400, '10    seconds', True), (1420070400, '10    minutes', True), (1420070400, '10    weeks', True), (1420070400, '10    months', True), (1420070400, '10    years', True), (1420070400, '99    months', True)]:
        sometime = datetime.datetime.utcfromtimestamp(current_time)
        mock_datetime.datetime.utcnow.return_value = sometime
        self.test_rc.configuration['deploy_before_expiry'] = interval
        self.test_rc.configuration['renew_before_expiry'] = interval
        self.assertEqual(self.test_rc.should_autodeploy(), result)
        self.assertEqual(self.test_rc.should_autorenew(), result)
