예제 #1
0
파일: test_apns.py 프로젝트: nomed/pushjack
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
예제 #2
0
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
예제 #3
0
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
예제 #4
0
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))
예제 #5
0
def test_apns_create_socket_no_certificate():
    with pytest.raises(exceptions.APNSAuthError):
        apns.create_socket(TCP_HOST, TCP_PORT, None)
예제 #6
0
def test_apns_create_socket_missing_certificate():
    with pytest.raises(exceptions.APNSAuthError):
        apns.create_socket(TCP_HOST, TCP_PORT, 'missing.pem')