예제 #1
0
    def test_check_for_new_clients_no_clients(self):
        with patch('socket.socket') as socket_socket_mock:
            with patch('select.select') as select_select_mock:

                serverSocketMock = Mock()
                socket_socket_mock.return_value = serverSocketMock
                select_select_mock.return_value = ([], [], [])

                sS = SocketServer("1.2.3.4", 1234)
                sS.CheckForNewClient(1.5)
                assert sS.clientSocketList == []
                del sS

                select_select_mock.assert_called_with([serverSocketMock], [],
                                                      [], 1.5)
                assert not serverSocketMock.accept.called
예제 #2
0
from SocketServer import SocketServer
from CheckInput import CheckInput
from GaduGaduServer import GaduGaduServer
server = SocketServer()
ggServer = GaduGaduServer(server)
print("Enter exit to close server!")
while True:
    server.CheckForNewClient()
    ggServer.Process()
    MESSAGE = CheckInput()
    if MESSAGE == 'exit':
        break