def test_apns_create_socket(tmpdir): certificate = tmpdir.join("certifiate.pem") certificate.write("content") with mock.patch("ssl.wrap_socket") as wrap_socket: wrap_socket.do_handshake = lambda: True apns.create_socket(TCP_HOST, TCP_PORT, str(certificate)) assert wrap_socket.called expected = {"certfile": str(certificate), "do_handshake_on_connect": False} assert wrap_socket.mock_calls[0][2] == expected
def test_apns_create_socket(tmpdir): certificate = tmpdir.join('certifiate.pem') certificate.write('content') with mock.patch('ssl.wrap_socket') as wrap_socket: wrap_socket.do_handshake = lambda: True apns.create_socket(TCP_HOST, TCP_PORT, str(certificate)) assert wrap_socket.called expected = { 'certfile': str(certificate), 'do_handshake_on_connect': False } assert wrap_socket.mock_calls[0][2] == expected
def test_apns_create_socket(tmpdir): certificate = tmpdir.join('certifiate.pem') certificate.write('content') with mock.patch('ssl.wrap_socket') as wrap_socket: wrap_socket.do_handshake = lambda: True sock = apns.create_socket(TCP_HOST, TCP_PORT, str(certificate)) assert wrap_socket.called expected = {'ssl_version': 3, 'certfile': str(certificate), 'do_handshake_on_connect': False} assert wrap_socket.mock_calls[0][2] == expected
def test_apns_create_socket_empty_certificate(tmpdir): certificate = tmpdir.join('certificate.pem') with pytest.raises(exceptions.APNSAuthError): apns.create_socket(TCP_HOST, TCP_PORT, str(certificate))
def test_apns_create_socket_no_certificate(): with pytest.raises(exceptions.APNSAuthError): apns.create_socket(TCP_HOST, TCP_PORT, None)
def test_apns_create_socket_missing_certificate(): with pytest.raises(exceptions.APNSAuthError): apns.create_socket(TCP_HOST, TCP_PORT, 'missing.pem')