Exemplo n.º 1
0
 def test_average_speed_per_second_raises_exception_when_distance_equals_zero(self):
     # Arrange
     start = datetime.now(pytz.utc)
     finish = start + timedelta(seconds=1)
     # Act
     with self.assertRaises(ValueError) as context:
         compute.average_speed_per_second(start, finish, 0)
     # Assert
     self.assertEqual(context.exception.message,
                      'Track distance must be greater than zero!')
Exemplo n.º 2
0
 def test_average_speed_per_second_raises_exception_when_finish_less_than_start(self):
     # Arrange
     finish = datetime.now(pytz.utc)
     start = finish + timedelta(seconds=1)
     # Act & Assert
     with self.assertRaises(ValueError) as context:
         compute.average_speed_per_second(start, finish, 10)
     # Assert
     self.assertEqual(context.exception.message,
                      'Start time must be before finish time!')
Exemplo n.º 3
0
 def test_average_speed_per_second_returns_none_when_no_finish(self):
     # Arrange
     start = datetime.now(pytz.utc)
     # Act
     avg_sps = compute.average_speed_per_second(start, None, 10)
     # Assert
     self.assertEqual(None, avg_sps)
Exemplo n.º 4
0
 def test_average_speed_per_second_returns_5mps_50m_in_10s(self):
     # Arrange
     start = datetime.now(pytz.utc)
     finish = start + timedelta(seconds=10)
     # Act
     avg_sps = compute.average_speed_per_second(start, finish, 50)
     # Assert
     self.assertEqual(5, avg_sps)