change datetime.now to datetime.utcnow;

fix test_ifeed test;
This commit is contained in:
Marco Zeisler
2021-06-17 23:19:16 +02:00
parent 1b12dd40b6
commit bf8d5c450e
7 changed files with 24 additions and 14 deletions
+2 -2
View File
@@ -61,7 +61,7 @@ class Orchestrator:
for traffic_light in traffic_lights['cursor']:
self.tls[traffic_light['id']] = {'color': traffic_light['color'],
'switching_time': traffic_light['switchingTime'],
'last_switch': datetime.now()}
'last_switch': datetime.utcnow()}
def setup_msg_queues(self):
"""
@@ -108,7 +108,7 @@ class Orchestrator:
print('Target velocity: {}'.format(target_vel))
response_channel.send(pickle.dumps(
TargetVelocity(vin=received_daf_object.vehicle_identification_number, target_velocity=target_vel,
timestamp=datetime.now())))
timestamp=datetime.utcnow())))
def handle_tl_state_receive(self, msg):
"""
+13 -2
View File
@@ -9,7 +9,7 @@ from orchestrator import Orchestrator
class TestOrchestrator(unittest.TestCase):
def setUp(self) -> None:
self.timestamp = datetime.datetime.now()
self.timestamp = datetime.datetime.utcnow()
with patch('requests.sessions.Session.get', MyResponse):
self.orc = Orchestrator()
@@ -18,7 +18,18 @@ class TestOrchestrator(unittest.TestCase):
tl_geo = {'cursor': [
{'id': '1', 'calculatedRange': 1000}
]}
current_vel = 130.0
current_vel = 55.0
target_vel = self.orc._compute_velocity(tl_geo, current_vel)
self.assertEqual(current_vel, target_vel)
def test_slow_down_if_passing_not_possible(self):
self.orc.tls = {'1': {'color': 'RED', 'switching_time': 1, 'last_switch': self.timestamp}}
tl_geo = {'cursor': [
{'id': '1', 'calculatedRange': 1000}
]}
current_vel = 50.0
target_vel = self.orc._compute_velocity(tl_geo, current_vel)
self.assertEqual(current_vel, target_vel)
print(target_vel)