Beispiel #1
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)
Beispiel #2
0
def test_get_feedback_with_unknown_app():
    server = APNSProxyServer(dummy_setting)

    proxy = server.get_feedback_proxy(json.dumps({
        "appid": "myApp1",
    }))
    ok_(not proxy)
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")
Beispiel #4
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)
def test_get_feedback_with_unknown_app():
    server = APNSProxyServer(dummy_setting)

    proxy = server.get_feedback_proxy(json.dumps({
        "appid": "myApp1",
    }))
    ok_(not proxy)
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)
 def server():
     server = APNSProxyServer({
         'BIND_PORT_FOR_ENTRY': 15555,
         'BIND_PORT_FOR_PULL': 15556,
         'THREAD_NUMS_PER_APPLICATION': 5,
         'APPLICATIONS': []
     })
     server.start()
 def server(error_queue):
     try:
         import tests.data.valid_settings
         s = validator.validate_settings(tests.data.valid_settings)
         server = APNSProxyServer(s)
         server.start()
     except Exception, e:
         error_queue.put(e)
Beispiel #9
0
 def server():
     server = APNSProxyServer({
         'BIND_PORT_FOR_ENTRY': 15555,
         'BIND_PORT_FOR_PULL': 15556,
         'THREAD_NUMS_PER_APPLICATION': 5,
         'APPLICATIONS': []
     })
     server.start()
Beispiel #10
0
 def server(error_queue):
     try:
         import tests.data.valid_settings
         s = validator.validate_settings(tests.data.valid_settings)
         server = APNSProxyServer(s)
         server.start()
     except Exception, e:
         error_queue.put(e)
def test_get_feedback():
    server = APNSProxyServer(dummy_setting)
    server.app_config["myApp1"] = {
        "application_id": "myApp1",
        "name": "My App1",
        "sandbox": True,
        "cert_file": "sample.cert",
        "key_file": "sample.key",
    }

    proxy = server.get_feedback_proxy(json.dumps({
        "appid": "myApp1",
    }))
    ok_(proxy)
    ok_(proxy.use_sandbox)
    eq_(proxy.cert_file, "sample.cert")
    eq_(proxy.key_file, "sample.key")
Beispiel #12
0
def test_get_feedback():
    server = APNSProxyServer(dummy_setting)
    server.app_config["myApp1"] = {
        "application_id": "myApp1",
        "name": "My App1",
        "sandbox": True,
        "cert_file": "sample.cert",
        "key_file": "sample.key",
    }

    proxy = server.get_feedback_proxy(json.dumps({
        "appid": "myApp1",
    }))
    ok_(proxy)
    ok_(proxy.use_sandbox)
    eq_(proxy.cert_file, "sample.cert")
    eq_(proxy.key_file, "sample.key")
Beispiel #13
0
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")
Beispiel #14
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))
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))
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)
def test_instance():
    server = APNSProxyServer(dummy_setting)
    ok_(server)
    ok_(server.start)