@mock.patch('certbot._internal.eff.handle_subscription')
@mock.patch('certbot.crypto_util.notAfter')
@test_util.patch_get_utility()
def test_certonly_new_request_success(self, mock_get_utility, mock_notAfter, mock_subscription):
    cert_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/foo.bar'))
    key_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/baz.qux'))
    date = '1970-01-01'
    mock_notAfter().date.return_value = date
    mock_lineage = mock.MagicMock(cert=cert_path, fullchain=cert_path, fullchain_path=cert_path, key_path=key_path)
    mock_client = mock.MagicMock()
    mock_client.obtain_and_enroll_certificate.return_value = mock_lineage
    self._certonly_new_request_common(mock_client)
    self.assertEqual(mock_client.obtain_and_enroll_certificate.call_count, 1)
    cert_msg = mock_get_utility().add_message.call_args_list[0][0][0]
    self.assertTrue((cert_path in cert_msg))
    self.assertTrue((date in cert_msg))
    self.assertTrue((key_path in cert_msg))
    self.assertTrue(('donate' in mock_get_utility().add_message.call_args[0][0]))
    self.assertTrue(mock_subscription.called)
@mock.patch('certbot._internal.eff.handle_subscription')
@mock.patch('certbot.crypto_util.notAfter')
@test_util.patch_get_utility()
def test_certonly_new_request_success(self, mock_get_utility, mock_notAfter, mock_subscription):
    cert_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/foo.bar'))
    key_path = os.path.normpath(os.path.join(self.config.config_dir, 'live/baz.qux'))
    date = '1970-01-01'
    mock_notAfter().date.return_value = date
    mock_lineage = mock.MagicMock(cert=cert_path, fullchain=cert_path, fullchain_path=cert_path, key_path=key_path)
    mock_client = mock.MagicMock()
    mock_client.obtain_and_enroll_certificate.return_value = mock_lineage
    self._certonly_new_request_common(mock_client)
    self.assertEqual(mock_client.obtain_and_enroll_certificate.call_count, 1)
    cert_msg = mock_get_utility().add_message.call_args_list[0][0][0]
    self.assertTrue((cert_path in cert_msg))
    self.assertTrue((date in cert_msg))
    self.assertTrue((key_path in cert_msg))
    self.assertTrue(('donate' in mock_get_utility().add_message.call_args[0][0]))
    self.assertTrue(mock_subscription.called)