@mock.patch('certbot._internal.cert_manager.lineage_for_certname')
@mock.patch('certbot._internal.cert_manager.domains_for_certname')
@mock.patch('certbot._internal.renewal.renew_cert')
@mock.patch('certbot._internal.main._handle_unexpected_key_type_migration')
@mock.patch('certbot._internal.main._report_new_cert')
def test_find_lineage_for_domains_and_certname(self, mock_report_cert, mock_handle_type, mock_renew_cert, mock_domains, mock_lineage):
    domains = ['example.com', 'test.org']
    mock_domains.return_value = domains
    mock_lineage.names.return_value = domains
    self._call('certonly --webroot -d example.com -d test.org --cert-name example.com'.split())
    self.assertEqual(mock_lineage.call_count, 1)
    self.assertEqual(mock_domains.call_count, 1)
    self.assertEqual(mock_renew_cert.call_count, 1)
    self.assertEqual(mock_report_cert.call_count, 1)
    self.assertEqual(mock_handle_type.call_count, 1)
    self._call('certonly --webroot -d example.com -d test.com --cert-name example.com'.split())
    self.assertEqual(mock_lineage.call_count, 2)
    self.assertEqual(mock_domains.call_count, 2)
    self.assertEqual(mock_renew_cert.call_count, 2)
    self.assertEqual(mock_report_cert.call_count, 2)
    self.assertEqual(mock_handle_type.call_count, 2)
    self.mock_get_utility().yesno.return_value = False
    self.assertRaises(errors.ConfigurationError, self._call, 'certonly --webroot -d example.com -d test.com --cert-name example.com'.split())
@mock.patch('certbot._internal.cert_manager.lineage_for_certname')
@mock.patch('certbot._internal.cert_manager.domains_for_certname')
@mock.patch('certbot._internal.renewal.renew_cert')
@mock.patch('certbot._internal.main._handle_unexpected_key_type_migration')
@mock.patch('certbot._internal.main._report_new_cert')
def test_find_lineage_for_domains_and_certname(self, mock_report_cert, mock_handle_type, mock_renew_cert, mock_domains, mock_lineage):
    domains = ['example.com', 'test.org']
    mock_domains.return_value = domains
    mock_lineage.names.return_value = domains
    self._call('certonly --webroot -d example.com -d test.org --cert-name example.com'.split())
    self.assertEqual(mock_lineage.call_count, 1)
    self.assertEqual(mock_domains.call_count, 1)
    self.assertEqual(mock_renew_cert.call_count, 1)
    self.assertEqual(mock_report_cert.call_count, 1)
    self.assertEqual(mock_handle_type.call_count, 1)
    self._call('certonly --webroot -d example.com -d test.com --cert-name example.com'.split())
    self.assertEqual(mock_lineage.call_count, 2)
    self.assertEqual(mock_domains.call_count, 2)
    self.assertEqual(mock_renew_cert.call_count, 2)
    self.assertEqual(mock_report_cert.call_count, 2)
    self.assertEqual(mock_handle_type.call_count, 2)
    self.mock_get_utility().yesno.return_value = False
    self.assertRaises(errors.ConfigurationError, self._call, 'certonly --webroot -d example.com -d test.com --cert-name example.com'.split())