You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
#lockdown nick.whiting [at]Nick.Whiting, [at]Mikko.Mononen #rb Nick.Whiting, Mikko.Mononen #jira UE-111731 #jira UE-111119 #jira UE-111117 #jira UE-111114 #jira UE-111091 #jira UE-111075 #jira UE-111060 #jira UE-111058 #jira UE-111049 #jira UE-111044 #jira UE-111040 #jira UE-111039 #jira UE-111038 #jira UE-111036 #jira UE-111033 #jira UE-111032 #jira UE-111029 #jira UE-111026 #jira UE-111024 #jira UE-111021 #jira UE-111020 #jira UE-111018 #jira UE-111017 #jira UE-111016 #jira UE-111015 #jira UE-111014 #jira UE-111013 #jira UE-111012 #jira UE-110977 #jira UE-110975 #jira UE-110974 #jira UE-110973 #jira UE-110971 #jira UE-110969 #jira UE-110965 #jira UE-110949 #preflight 606ebe61db0bbb00016e242e #ROBOMERGE-OWNER: mieszko.zielinski #ROBOMERGE-AUTHOR: mieszko.zielinski #ROBOMERGE-SOURCE: CL 15955453 in //UE5/Release-5.0-EarlyAccess/... #ROBOMERGE-BOT: STARSHIP (Release-5.0-EarlyAccess -> Main) (v787-15839533) #ROBOMERGE-CONFLICT from-shelf [CL 15975769 by mieszko zielinski in ue5-main branch]
57 lines
2.0 KiB
Python
57 lines
2.0 KiB
Python
# Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
import unittest
|
|
from unreal.mladapter.client import Client
|
|
import unreal.mladapter.utils as utils
|
|
from unreal.mladapter.error import *
|
|
from mock_server import MockServer
|
|
from time import time
|
|
|
|
|
|
class SocketTest(unittest.TestCase):
|
|
def test_free_socket(self):
|
|
port = utils.find_available_port()
|
|
self.assertTrue(port > 0)
|
|
self.assertTrue(utils.is_port_available(port))
|
|
|
|
|
|
class ClientTest(unittest.TestCase):
|
|
def test_connection_timeout(self):
|
|
c = Client(timeout=0.01, server_port=None)
|
|
with self.assertRaises(ConnectionTimeoutError):
|
|
c.call('foo')
|
|
|
|
def test_reconnection_limit(self):
|
|
timeout = 1024
|
|
c = Client(timeout=timeout, server_port=None, reconnect_limit=1)
|
|
time_start = time()
|
|
with self.assertRaises(ReconnectionLimitReached):
|
|
c.ensure_connection()
|
|
self.assertLess(time() - time_start, timeout)
|
|
|
|
def test_reconnect_to_new(self):
|
|
c = Client(server_port=None, reconnect_limit=100)
|
|
import concurrent.futures
|
|
with concurrent.futures.ThreadPoolExecutor() as executor:
|
|
# calling rpc function before the server is launched. The call should just hang in there waiting for the
|
|
# server to come on line (up until set limit of reconnect attempts)
|
|
future = executor.submit(c.call, 'sum', 1, 2)
|
|
with MockServer(c.address.port) as s:
|
|
return_value = future.result()
|
|
self.assertEqual(return_value, 3)
|
|
|
|
def test_rcp_functions(self):
|
|
c = Client()
|
|
with MockServer(c.address.port) as s:
|
|
self.assertTrue(c.call('foo'))
|
|
with self.assertRaises(RPCError):
|
|
c.call('not_existing')
|
|
|
|
c.add_functions()
|
|
self.assertTrue(c.call(Client.FUNCNAME_PING))
|
|
self.assertTrue(c.call('sum', 1, 2) == c.sum(1, 2))
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|