62 lines
1.9 KiB
Python
62 lines
1.9 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))
|
|
|
|
import unittest
|
|
|
|
from RoboidControl.Thing import Thing
|
|
from RoboidControl.Participants.ParticipantUDP import ParticipantUDP
|
|
from RoboidControl.Participants.SiteServer import SiteServer
|
|
|
|
class ThingTest(unittest.TestCase):
|
|
|
|
def test_participant(self):
|
|
participant: ParticipantUDP = ParticipantUDP()
|
|
|
|
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(port=7681)
|
|
participant = ParticipantUDP(ip_address="127.0.0.1", port=7681, local_port=7682)
|
|
|
|
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 = ParticipantUDP(ip_address="127.0.0.1", port=7683)
|
|
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() |