Пример #1
0
 def test_average_speed_per_second_raises_exception_when_distance_less_than_zero(self):
     # Arrange
     start = timezone.now()
     finish = start + datetime.timedelta(seconds=1)
     # Act & Assert
     with self.assertRaises(ValueError):
         compute.average_speed_per_second(start, finish, -0.1)
Пример #2
0
 def test_average_speed_per_second_raises_exception_when_finish_equals_start(self):
     # Arrange
     start = timezone.now()
     finish = start
     # Act & Assert
     with self.assertRaises(ValueError):
         compute.average_speed_per_second(start, finish, 10)
Пример #3
0
 def test_average_speed_per_second_raises_exception_when_finish_less_than_start(self):
     # Arrange
     finish = timezone.now()
     start = finish + datetime.timedelta(seconds=1)
     # Act & Assert
     with self.assertRaises(ValueError):
         compute.average_speed_per_second(start, finish, 10)
Пример #4
0
 def test_average_speed_per_second_raises_exception_when_distance_equals_zero(
         self):
     # Arrange
     start = timezone.now()
     finish = start + datetime.timedelta(seconds=1)
     # Act & assert
     with self.assertRaises(ValueError):
         compute.average_speed_per_second(start, finish, 0)
Пример #5
0
 def test_average_speed_per_second_raises_exception_when_finish_less_than_start(
         self):
     # Arrange
     finish = timezone.now()
     start = finish + datetime.timedelta(seconds=1)
     # Act & Assert
     with self.assertRaises(ValueError):
         compute.average_speed_per_second(start, finish, 10)
Пример #6
0
 def test_average_speed_per_second_raises_exception_when_finish_equals_start(
         self):
     # Arrange
     start = timezone.now()
     finish = start
     # Act & Assert
     with self.assertRaises(ValueError):
         compute.average_speed_per_second(start, finish, 10)
Пример #7
0
 def test_average_speed_per_second_returns_none_when_no_finish(self):
     # Arrange
     start = timezone.now()
     # Act
     avg_sps = compute.average_speed_per_second(start, None, 10)
     # Assert
     self.assertEqual(None, avg_sps)
Пример #8
0
 def test_average_speed_per_second_returns_none_when_no_finish(self):
     # Arrange
     start = timezone.now()
     # Act
     avg_sps = compute.average_speed_per_second(start, None, 10)
     # Assert
     self.assertEqual(None, avg_sps)
Пример #9
0
 def test_average_speed_per_second_returns_5mps_50m_in_10s(self):
     # Arrange
     start = timezone.now()
     finish = start + datetime.timedelta(seconds=10)
     # Act
     avg_sps = compute.average_speed_per_second(start, finish, 50)
     # Assert
     self.assertEqual(5, avg_sps)
Пример #10
0
 def test_average_speed_per_second_returns_5mps_50m_in_10s(self):
     # Arrange
     start = timezone.now()
     finish = start + datetime.timedelta(seconds=10)
     # Act
     avg_sps = compute.average_speed_per_second(start, finish, 50)
     # Assert
     self.assertEqual(5, avg_sps)