<s> import json <EOL> import logging <EOL> import unittest <EOL> import six <EOL> if six . PY3 : <EOL> from unittest import mock <EOL> else : <EOL> import mock <EOL> from socketio import packet <EOL> from socketio import server <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> class TestServer ( unittest . TestCase ) : <EOL> def tearDown ( self ) : <EOL> packet . Packet . json = json <EOL> def test_create ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr , binary = True , foo = '<STR_LIT:bar>' ) <EOL> eio . assert_called_once_with ( ** { '<STR_LIT:foo>' : '<STR_LIT:bar>' } ) <EOL> self . assertEqual ( s . manager , mgr ) <EOL> self . assertEqual ( s . eio . on . call_count , <NUM_LIT:3> ) <EOL> self . assertEqual ( s . binary , True ) <EOL> def test_on_event ( self , eio ) : <EOL> s = server . Server ( ) <EOL> @ s . on ( '<STR_LIT>' ) <EOL> def foo ( ) : <EOL> pass <EOL> def bar ( ) : <EOL> pass <EOL> s . on ( '<STR_LIT>' , bar ) <EOL> s . on ( '<STR_LIT>' , bar , namespace = '<STR_LIT>' ) <EOL> self . assertEqual ( s . handlers [ '<STR_LIT:/>' ] [ '<STR_LIT>' ] , foo ) <EOL> self . assertEqual ( s . handlers [ '<STR_LIT:/>' ] [ '<STR_LIT>' ] , bar ) <EOL> self . assertEqual ( s . handlers [ '<STR_LIT>' ] [ '<STR_LIT>' ] , bar ) <EOL> def test_emit ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . emit ( '<STR_LIT>' , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } , '<STR_LIT>' , '<STR_LIT>' , namespace = '<STR_LIT>' , <EOL> callback = '<STR_LIT>' ) <EOL> s . manager . emit . assert_called_once_with ( '<STR_LIT>' , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_emit_default_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . emit ( '<STR_LIT>' , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } , '<STR_LIT>' , '<STR_LIT>' , callback = '<STR_LIT>' ) <EOL> s . manager . emit . assert_called_once_with ( '<STR_LIT>' , { '<STR_LIT:foo>' : '<STR_LIT:bar>' } , '<STR_LIT:/>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_send ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . send ( '<STR_LIT:foo>' , '<STR_LIT>' , '<STR_LIT>' , namespace = '<STR_LIT>' , callback = '<STR_LIT>' ) <EOL> s . manager . emit . assert_called_once_with ( '<STR_LIT:message>' , '<STR_LIT:foo>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_enter_room ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . enter_room ( '<STR_LIT>' , '<STR_LIT>' , namespace = '<STR_LIT>' ) <EOL> s . manager . enter_room . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_enter_room_default_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . enter_room ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . manager . enter_room . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:/>' , '<STR_LIT>' ) <EOL> def test_leave_room ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . leave_room ( '<STR_LIT>' , '<STR_LIT>' , namespace = '<STR_LIT>' ) <EOL> s . manager . leave_room . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_leave_room_default_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . leave_room ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . manager . leave_room . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:/>' , '<STR_LIT>' ) <EOL> def test_close_room ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . close_room ( '<STR_LIT>' , namespace = '<STR_LIT>' ) <EOL> s . manager . close_room . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_close_room_default_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . close_room ( '<STR_LIT>' ) <EOL> s . manager . close_room . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> def test_rooms ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . rooms ( '<STR_LIT>' , namespace = '<STR_LIT>' ) <EOL> s . manager . get_rooms . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_rooms_default_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . rooms ( '<STR_LIT>' ) <EOL> s . manager . get_rooms . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> def test_handle_request ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . handle_request ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . eio . handle_request . assert_called_once_with ( '<STR_LIT>' , <EOL> '<STR_LIT>' ) <EOL> def test_emit_internal ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , namespace = '<STR_LIT>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_emit_internal_with_tuple ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , ( '<STR_LIT:foo>' , '<STR_LIT:bar>' ) , namespace = '<STR_LIT>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_emit_internal_with_list ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT:foo>' , '<STR_LIT:bar>' ] , namespace = '<STR_LIT>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_emit_internal_with_callback ( self , eio ) : <EOL> s = server . Server ( ) <EOL> id = s . manager . _generate_ack_id ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , namespace = '<STR_LIT>' , id = id ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_emit_internal_default_namespace ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_emit_internal_binary ( self , eio ) : <EOL> s = server . Server ( binary = True ) <EOL> s . _emit_internal ( '<STR_LIT>' , u'<STR_LIT>' , b'<STR_LIT>' ) <EOL> self . assertEqual ( s . eio . send . call_count , <NUM_LIT:2> ) <EOL> def test_transport ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . eio . transport = mock . MagicMock ( return_value = '<STR_LIT>' ) <EOL> s . _handle_eio_connect ( '<STR_LIT:foo>' , '<STR_LIT>' ) <EOL> self . assertEqual ( s . transport ( '<STR_LIT:foo>' ) , '<STR_LIT>' ) <EOL> s . eio . transport . assert_called_once_with ( '<STR_LIT:foo>' ) <EOL> def test_handle_connect ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . manager . connect . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:0>' , binary = False ) <EOL> def test_handle_connect_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler , namespace = '<STR_LIT>' ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . manager . connect . assert_any_call ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> s . manager . connect . assert_any_call ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . eio . send . assert_any_call ( '<STR_LIT>' , '<STR_LIT>' , binary = False ) <EOL> def test_handle_connect_rejected ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( return_value = False ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( s . manager . connect . call_count , <NUM_LIT:1> ) <EOL> self . assertEqual ( s . manager . disconnect . call_count , <NUM_LIT:1> ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:4>' , binary = False ) <EOL> def test_handle_connect_namespace_rejected ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( return_value = False ) <EOL> s . on ( '<STR_LIT>' , handler , namespace = '<STR_LIT>' ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( s . manager . connect . call_count , <NUM_LIT:2> ) <EOL> self . assertEqual ( s . manager . disconnect . call_count , <NUM_LIT:1> ) <EOL> s . eio . send . assert_any_call ( '<STR_LIT>' , '<STR_LIT>' , binary = False ) <EOL> def test_handle_disconnect ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_disconnect ( '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' ) <EOL> s . manager . disconnect . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:/>' ) <EOL> self . assertEqual ( s . environ , { } ) <EOL> def test_handle_disconnect_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . manager . get_namespaces = mock . MagicMock ( return_value = [ '<STR_LIT:/>' , '<STR_LIT>' ] ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> handler_namespace = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler_namespace , namespace = '<STR_LIT>' ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_disconnect ( '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' ) <EOL> handler_namespace . assert_called_once_with ( '<STR_LIT>' ) <EOL> self . assertEqual ( s . environ , { } ) <EOL> def test_handle_disconnect_only_namespace ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . manager . get_namespaces = mock . MagicMock ( return_value = [ '<STR_LIT:/>' , '<STR_LIT>' ] ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> handler_namespace = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler_namespace , namespace = '<STR_LIT>' ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . assertEqual ( handler . call_count , <NUM_LIT:0> ) <EOL> handler_namespace . assert_called_once_with ( '<STR_LIT>' ) <EOL> self . assertEqual ( s . environ , { '<STR_LIT>' : '<STR_LIT>' } ) <EOL> def test_handle_disconnect_unknown_client ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> s . _handle_eio_disconnect ( '<STR_LIT>' ) <EOL> def test_handle_event ( self , eio ) : <EOL> s = server . Server ( ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) <EOL> def test_handle_event_with_namespace ( self , eio ) : <EOL> s = server . Server ( ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler , namespace = '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) <EOL> def test_handle_event_binary ( self , eio ) : <EOL> s = server . Server ( ) <EOL> handler = mock . MagicMock ( ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( s . _attachment_count , <NUM_LIT:2> ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , b'<STR_LIT:foo>' ) <EOL> self . assertEqual ( s . _attachment_count , <NUM_LIT:1> ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , b'<STR_LIT:bar>' ) <EOL> self . assertEqual ( s . _attachment_count , <NUM_LIT:0> ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:a>' , b'<STR_LIT:bar>' , b'<STR_LIT:foo>' ) <EOL> def test_handle_event_binary_ack ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> self . assertEqual ( s . _attachment_count , <NUM_LIT:1> ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , b'<STR_LIT:foo>' ) <EOL> def test_handle_event_with_ack ( self , eio ) : <EOL> s = server . Server ( ) <EOL> handler = mock . MagicMock ( return_value = '<STR_LIT:foo>' ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:foo>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_handle_event_with_ack_tuple ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( return_value = ( <NUM_LIT:1> , '<STR_LIT:2>' , True ) ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_handle_event_with_ack_list ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr ) <EOL> handler = mock . MagicMock ( return_value = [ <NUM_LIT:1> , '<STR_LIT:2>' , True ] ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT:a>' , '<STR_LIT:b>' , '<STR_LIT:c>' ) <EOL> s . eio . send . assert_called_once_with ( '<STR_LIT>' , '<STR_LIT>' , <EOL> binary = False ) <EOL> def test_handle_event_with_ack_binary ( self , eio ) : <EOL> mgr = mock . MagicMock ( ) <EOL> s = server . Server ( client_manager = mgr , binary = True ) <EOL> handler = mock . MagicMock ( return_value = b'<STR_LIT:foo>' ) <EOL> s . on ( '<STR_LIT>' , handler ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> handler . assert_any_call ( '<STR_LIT>' , '<STR_LIT:foo>' ) <EOL> def test_handle_error_packet ( self , eio ) : <EOL> s = server . Server ( ) <EOL> self . assertRaises ( ValueError , s . _handle_eio_message , '<STR_LIT>' , '<STR_LIT:4>' ) <EOL> def test_handle_invalid_packet ( self , eio ) : <EOL> s = server . Server ( ) <EOL> self . assertRaises ( ValueError , s . _handle_eio_message , '<STR_LIT>' , '<STR_LIT>' ) <EOL> def test_send_with_ack ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> cb = mock . MagicMock ( ) <EOL> id1 = s . manager . _generate_ack_id ( '<STR_LIT>' , '<STR_LIT:/>' , cb ) <EOL> id2 = s . manager . _generate_ack_id ( '<STR_LIT>' , '<STR_LIT:/>' , cb ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT:foo>' ] , id = id1 ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT:bar>' ] , id = id2 ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> cb . assert_called_once_with ( '<STR_LIT:foo>' , <NUM_LIT:2> ) <EOL> def test_send_with_ack_namespace ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> cb = mock . MagicMock ( ) <EOL> id = s . manager . _generate_ack_id ( '<STR_LIT>' , '<STR_LIT>' , cb ) <EOL> s . _emit_internal ( '<STR_LIT>' , '<STR_LIT>' , [ '<STR_LIT:foo>' ] , namespace = '<STR_LIT>' , <EOL> id = id ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> cb . assert_called_once_with ( '<STR_LIT:foo>' , <NUM_LIT:2> ) <EOL> def test_disconnect ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . disconnect ( '<STR_LIT>' ) <EOL> s . eio . send . assert_any_call ( '<STR_LIT>' , '<STR_LIT:1>' , binary = False ) <EOL> def test_disconnect_namespace ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . _handle_eio_connect ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . _handle_eio_message ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> s . disconnect ( '<STR_LIT>' , namespace = '<STR_LIT>' ) <EOL> s . eio . send . assert_any_call ( '<STR_LIT>' , '<STR_LIT>' , binary = False ) <EOL> def test_logger ( self , eio ) : <EOL> s = server . Server ( logger = False ) <EOL> self . assertEqual ( s . logger . getEffectiveLevel ( ) , logging . ERROR ) <EOL> s . logger . setLevel ( logging . NOTSET ) <EOL> s = server . Server ( logger = True ) <EOL> self . assertEqual ( s . logger . getEffectiveLevel ( ) , logging . INFO ) <EOL> s . logger . setLevel ( logging . WARNING ) <EOL> s = server . Server ( logger = True ) <EOL> self . assertEqual ( s . logger . getEffectiveLevel ( ) , logging . WARNING ) <EOL> s . logger . setLevel ( logging . NOTSET ) <EOL> s = server . Server ( logger = '<STR_LIT:foo>' ) <EOL> self . assertEqual ( s . logger , '<STR_LIT:foo>' ) <EOL> def test_engineio_logger ( self , eio ) : <EOL> server . Server ( engineio_logger = '<STR_LIT:foo>' ) <EOL> eio . assert_called_once_with ( ** { '<STR_LIT>' : '<STR_LIT:foo>' } ) <EOL> def test_custom_json ( self , eio ) : <EOL> class CustomJSON ( object ) : <EOL> @ staticmethod <EOL> def dumps ( * args , ** kwargs ) : <EOL> return '<STR_LIT>' <EOL> @ staticmethod <EOL> def loads ( * args , ** kwargs ) : <EOL> return '<STR_LIT>' <EOL> server . Server ( json = CustomJSON ) <EOL> eio . assert_called_once_with ( ** { '<STR_LIT>' : CustomJSON } ) <EOL> pkt = packet . Packet ( packet_type = packet . EVENT , <EOL> data = { six . text_type ( '<STR_LIT:foo>' ) : six . text_type ( '<STR_LIT:bar>' ) } ) <EOL> self . assertEqual ( pkt . encode ( ) , '<STR_LIT>' ) <EOL> pkt2 = packet . Packet ( encoded_packet = pkt . encode ( ) ) <EOL> self . assertEqual ( pkt2 . data , '<STR_LIT>' ) <EOL> packet . Packet . json = json <EOL> def test_start_background_task ( self , eio ) : <EOL> s = server . Server ( ) <EOL> s . start_background_task ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , baz = '<STR_LIT>' ) <EOL> s . eio . start_background_task . assert_called_once_with ( '<STR_LIT:foo>' , '<STR_LIT:bar>' , <EOL> baz = '<STR_LIT>' ) </s>
