예제 #1
0
    def test_send_receive(self):

        #[3] Requirement: The server should accept a maximum of 100 connected clients
        with self.subTest():
            test_max_clients(self)

        #put the server ready to receive connections from clients
        t1 = threading.Thread(target=server.connect_clients)
        t1.start()
        time.sleep(0.2)

        #client send a connection request to server
        clients.connect_server()

        #[4] Requirement: The client should connect to the server with a TLS connection
        with self.subTest():
            test_tls(self)

        #[5] Requirement: The client should receive the current date from the server every 10 seconds.
        with self.subTest():
            test_date(self)

        #[6] Requirement: The client should send a text message to the server, the server should respond with the same string but reversed.
        with self.subTest():
            test_input(self)

        #send q to close connection
        clients.send(string_output='q')
예제 #2
0
def test_input(input):
    input_list = ['aditya', 'prateeksha', 'prerana']
    expected_list = ['aytida', 'ahskeetarp', 'anarerp']
    clients.send(string_output=input_list)
    output_list = []
    prefix = "Reversed input : "
    #remove output prefix and save the result
    for i in range(len(input_list)):
        out = clients.receive().replace(prefix, "")
        output_list.append(out)
    input.assertEqual(output_list, expected_list)
예제 #3
0
def test_input(input):

    input_list = ['roma', 'genova']
    expected_list = ['amor', 'avoneg']

    clients.send(string_output=input_list)

    output_list = []
    prefix = "Reversed input : "

    #remove output prefix and save the result
    for i in range(len(input_list)):
        out = clients.receive().replace(prefix, "")
        output_list.append(out)

    input.assertEqual(output_list, expected_list)