Exemplo n.º 1
0
	def send_requests_and_quit(self):
		time.sleep(1)
		global tcpServer
		ip, port = tcpServer.tcpServer.server_address
		self.requestSender = RemoteClient("{0}:{1}".format(ip, port),callback=self.on_request_callback)
		self.request = "player;getState\n"
		self.requestSender.sendRequest(self.request)
		return
Exemplo n.º 2
0
class TestServerApp:

	config.setConfigFolder('tests/config/')
	request_received_confirmed = False

	def test_server_default_setup(self):
		pass
		server = serverapp.setupTestServer()
		global tcpServer 
		tcpServer = server
		
		t = threading.Thread(target=self.send_requests_and_quit, name="reqsender")
		t.start()
		
		watcher = DeviceWatcher(callback=self.device_watcher_callback)
		watcher.start()

		tcpServer.start()
		watcher.stop()
		global tcpServerReallyBroadcastedItsPresence
		assert tcpServerReallyBroadcastedItsPresence
		
	def send_requests_and_quit(self):
		time.sleep(1)
		global tcpServer
		ip, port = tcpServer.tcpServer.server_address
		self.requestSender = RemoteClient("{0}:{1}".format(ip, port),callback=self.on_request_callback)
		self.request = "player;getState\n"
		self.requestSender.sendRequest(self.request)
		return

	def on_request_callback(self, answer):
		global tcpServer
		assert answer and len(answer) > 0 and answer == "STOPPED"
		tcpServer.stop()

	def device_watcher_callback(self, device):
		global tcpServerReallyBroadcastedItsPresence
		tcpServerReallyBroadcastedItsPresence = True

		global tcpServer
		assert tcpServer.device == device
Exemplo n.º 3
0
	def test_can_send_cmd(self):
		host_address = "127.0.0.1:5005"
		remoteClient = RemoteClient(host_address, callback=self.assert_server_answered)
		remoteClient.sendRequest('player;getState')
		time.sleep(3)
		assert self.assert_server_really_answ