コード例 #1
0
def test_dispatch_unknown_app():
    server = APNSProxyServer(dummy_setting)
    server.create_workers(
        {
            "myApp2": {
                "application_id": "myApp2",
                "name": "My App2",
                "sandbox": False,
                "cert_file": "sample.cert",
                "key_file": "sample.key"
            },
        }, 1)

    token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    eq_(
        server.dispatch_queue(
            json.dumps({
                "token": token,
                "appid": "unknownApp",
                "test": True,
                "aps": {
                    "alert": "This is test",
                    "badge": 1,
                    "sound": "default"
                },
                "expiry": None
            })), False, "Dispatch should be failed of unknown appid")
コード例 #2
0
def test_thread_count():
    """
    スレッド生成数のテスト
    """
    before_num = threading.active_count()

    server = APNSProxyServer(dummy_setting)
    server.create_workers(
        {
            "myApp1": {
                "application_id": "myApp1",
                "name": "My App1",
                "sandbox": False,
                "cert_file": "sample.cert",
                "key_file": "sample.key"
            },
            "myApp2": {
                "application_id": "myApp2",
                "name": "My App2",
                "sandbox": False,
                "cert_file": "sample.cert",
                "key_file": "sample.key"
            },
        }, 3)

    after_num = threading.active_count()

    eq_(before_num + 6, after_num)
コード例 #3
0
ファイル: test_server.py プロジェクト: co3k/apns-proxy-server
def test_thread_count():
    """
    スレッド生成数のテスト
    """
    before_num = threading.active_count()

    server = APNSProxyServer(dummy_setting)
    server.create_workers({
        "myApp1": {
            "application_id": "myApp1",
            "name": "My App1",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
        "myApp2": {
            "application_id": "myApp2",
            "name": "My App2",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
    }, 3)

    after_num = threading.active_count()

    eq_(before_num + 6, after_num)
コード例 #4
0
ファイル: test_server.py プロジェクト: co3k/apns-proxy-server
def test_dispatch_messages():
    server = APNSProxyServer(dummy_setting)
    server.create_workers({
        "myApp2": {
            "application_id": "myApp2",
            "name": "My App2",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
    }, 1)

    token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    eq_(server.dispatch_queue(json.dumps({
        "token": token,
        "appid": "myApp2",
        "aps": {
            "content_available": True
        },
        "test": True
        })), True)
    eq_(server.dispatch_queue(json.dumps({
        "token": token,
        "appid": "myApp2",
        "aps": {
            "sound": None,
            "badge": 99
        },
        "priority": 5,
        "test": True
        })), True)
コード例 #5
0
ファイル: test_server.py プロジェクト: co3k/apns-proxy-server
def test_dispatch_known_app():
    server = APNSProxyServer(dummy_setting)
    server.create_workers({
        "myApp1": {
            "application_id": "myApp1",
            "name": "My App1",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
        "myApp2": {
            "application_id": "myApp2",
            "name": "My App2",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
    }, 1)

    token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    eq_(server.dispatch_queue(json.dumps({
        "token": token,
        "appid": "myApp1",
        "test": True,
        "aps": {
            "alert": "This is test",
            "badge": 1,
            "sound": "default"
        },
        "expiry": None
        })), True, "Dispatch should be success")

    eq_(server.dispatch_queue(json.dumps({
        "token": token,
        "appid": "myApp2",
        "test": True,
        "aps": {
            "alert": "This is test",
            "badge": 1,
            "sound": "default",
        },
        "expiry": None
        })), True, "Dispatch should be success")
コード例 #6
0
ファイル: test_server.py プロジェクト: co3k/apns-proxy-server
def test_create_worker():
    server = APNSProxyServer(dummy_setting)
    server.create_workers({
        "myApp1": {
            "application_id": "myApp1",
            "name": "My App1",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
        "myApp2": {
            "application_id": "myApp2",
            "name": "My App2",
            "sandbox": False,
            "cert_file": "sample.cert",
            "key_file": "sample.key"
        },
    }, 1)
    eq_(len(server.task_queues), 2)
    for k in server.task_queues.keys():
        ok_(isinstance(server.task_queues[k], Queue))
コード例 #7
0
def test_create_worker():
    server = APNSProxyServer(dummy_setting)
    server.create_workers(
        {
            "myApp1": {
                "application_id": "myApp1",
                "name": "My App1",
                "sandbox": False,
                "cert_file": "sample.cert",
                "key_file": "sample.key"
            },
            "myApp2": {
                "application_id": "myApp2",
                "name": "My App2",
                "sandbox": False,
                "cert_file": "sample.cert",
                "key_file": "sample.key"
            },
        }, 1)
    eq_(len(server.task_queues), 2)
    for k in server.task_queues.keys():
        ok_(isinstance(server.task_queues[k], Queue))
コード例 #8
0
def test_dispatch_messages():
    server = APNSProxyServer(dummy_setting)
    server.create_workers(
        {
            "myApp2": {
                "application_id": "myApp2",
                "name": "My App2",
                "sandbox": False,
                "cert_file": "sample.cert",
                "key_file": "sample.key"
            },
        }, 1)

    token = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
    eq_(
        server.dispatch_queue(
            json.dumps({
                "token": token,
                "appid": "myApp2",
                "aps": {
                    "content_available": True
                },
                "test": True
            })), True)
    eq_(
        server.dispatch_queue(
            json.dumps({
                "token": token,
                "appid": "myApp2",
                "aps": {
                    "sound": None,
                    "badge": 99
                },
                "priority": 5,
                "test": True
            })), True)