25 lines
764 B
Python
25 lines
764 B
Python
import datetime
|
|
import unittest
|
|
from unittest.mock import patch
|
|
|
|
from dse_shared_libs.mock.response import MyResponse
|
|
|
|
from orchestrator import Orchestrator
|
|
|
|
|
|
class TestOrchestrator(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.timestamp = datetime.datetime.now()
|
|
with patch('requests.sessions.Session.get', MyResponse):
|
|
self.orc = Orchestrator()
|
|
|
|
def test_full_speed_if_far_away(self):
|
|
self.orc.tls = {'1': {'color': 'RED', 'switching_time': 1, 'last_switch': self.timestamp}}
|
|
tl_geo = {'cursor': [
|
|
{'id': '1', 'calculatedRange': 1000}
|
|
]}
|
|
current_vel = 130.0
|
|
|
|
target_vel = self.orc._compute_velocity(tl_geo, current_vel)
|
|
self.assertEqual(current_vel, target_vel)
|