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")
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 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 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_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")
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)