Mock fix for DeprecationWarning: callable is None

This commit is contained in:
sayali 2020-11-03 19:27:41 -08:00
parent dc7497e29d
commit 003779a112
1 changed files with 11 additions and 9 deletions

View File

@ -127,22 +127,24 @@ class TestAcme(unittest.TestCase):
mock_dns_provider = Mock()
mock_dns_provider.wait_for_dns_change = Mock(return_value=True)
mock_dns_challenge = Mock()
response = Mock()
response.simple_verify = Mock(return_value=False)
mock_dns_challenge.response = Mock(return_value=response)
mock_authz = Mock()
mock_authz.dns_challenge.response = Mock()
mock_authz.dns_challenge.response.simple_verify = Mock(return_value=False)
mock_authz.authz = []
mock_authz.dns_challenge = []
mock_authz.dns_challenge.append(mock_dns_challenge)
mock_authz.target_domain = "www.test.com"
mock_authz_record = Mock()
mock_authz_record.body.identifier.value = "test"
mock_authz.authz = []
mock_authz.authz.append(mock_authz_record)
mock_authz.change_id = []
mock_authz.change_id.append("123")
mock_authz.dns_challenge = []
dns_challenge = Mock()
mock_authz.dns_challenge.append(dns_challenge)
# with self.assertRaises(ValueError):
# self.acme.complete_dns_challenge(mock_acme, mock_authz)
self.assertRaises(ValueError, self.acme.complete_dns_challenge, mock_acme, mock_authz)
with self.assertRaises(ValueError):
self.acme.complete_dns_challenge(mock_acme, mock_authz)
@patch("acme.client.Client")
@patch("OpenSSL.crypto", return_value="mock_cert")