RoboidControl-python/test/thing_test.py
Pascal Serrarens d4d67e8233 Merged changes
2025-01-21 11:05:19 +01:00

62 lines
1.8 KiB
Python

import time
import sys
from pathlib import Path
# Add the project root to sys.path
sys.path.append(str(Path(__file__).resolve().parent.parent))
import unittest
from Thing import Thing
from Participant import Participant
from SiteServer import SiteServer
class ThingTest(unittest.TestCase):
def test_participant(self):
participant: Participant = Participant(ipAddress="127.0.0.1", port=7681)
milliseconds = time.time() * 1000
start_time = milliseconds
while milliseconds < start_time + 5000:
milliseconds = time.time() * 1000
participant.Update(milliseconds)
def test_site_server(self):
site = SiteServer(port=7681)
milliseconds = time.time() * 1000
start_time = milliseconds
while milliseconds < start_time + 5000:
milliseconds = time.time() * 1000
site.Update(milliseconds)
def test_site_participant(self):
site = SiteServer(7681)
participant = Participant("127.0.0.1", 7681)
milliseconds = time.time() * 1000
start_time = milliseconds
while milliseconds < start_time + 7000:
milliseconds = time.time() * 1000
site.Update(milliseconds)
participant.Update(milliseconds)
time.sleep(0.1)
def test_thing_msg(self):
site = SiteServer()
participant = Participant("127.0.0.1")
thing = Thing()
thing.name = "First thing"
thing.model_url = "https://passer.life/extras/ant.jpg"
milliseconds = time.time() * 1000
start_time = milliseconds
while milliseconds < start_time + 7000:
milliseconds = time.time() * 1000
site.Update(milliseconds)
participant.Update(milliseconds)
if __name__ == '__main__':
unittest.main()