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
+1 -1
View File
@@ -90,7 +90,7 @@ class TrafficLight:
self.current_color = TrafficLightColor((self._starting_color.value - 1) % num_colors)
while self.running:
self.current_color = TrafficLightColor((self.current_color.value + 1) % num_colors)
self.last_switch = datetime.now()
self.last_switch = datetime.utcnow()
self.send_status_update()
time.sleep(self.switching_time / SCALING)
+3 -3
View File
@@ -168,7 +168,7 @@ class Vehicle:
# Get old and updated timestamps
old_timestamp = self.last_update
updated_timestamp = datetime.now()
updated_timestamp = datetime.utcnow()
self.last_update = updated_timestamp
# get driving time between timestamps (in seconds)
@@ -201,7 +201,7 @@ class Vehicle:
informs the message broker about the current state (DAF) of the vehicle.
"""
print('{} starts driving ... SCALING: x{}\n\n'.format(self.vin, SCALING))
self.last_update = datetime.now()
self.last_update = datetime.utcnow()
self._driven_kms = 0
self._t = threading.Thread(target=self.drive)
@@ -266,7 +266,7 @@ class Vehicle:
print('\n\nEnd of route reached ... resetting and restarting vehicle')
self._gps_location = self._starting_point
self._driven_kms = 0
self.last_update = datetime.now()
self.last_update = datetime.utcnow()
self.nce = False
self.velocity = STARTING_VELOCITY
+2 -2
View File
@@ -21,7 +21,7 @@ class TestVehicle(unittest.TestCase):
self.vin = 'my_vin'
self.starting_velocity = 130
self.starting_point = geopy.Point(0, 0, 0)
self.timestamp = datetime.datetime.now()
self.timestamp = datetime.datetime.utcnow()
self.v = Vehicle(
vin=self.vin,
@@ -40,7 +40,7 @@ class TestVehicle(unittest.TestCase):
# initially false
self.assertEqual(self.v.nce, False)
# get past nce km
self.v._driven_kms = 3
self.v._gps_location.latitude = 48
# now nce should fire
self.assertEqual(self.v.nce, True)
# second call is false again