Example #1
0
    def test_method_calc_points_no_point_structure(self,
                                                   mock_classification_entry,
                                                   mock_driver):
        driver_name = 'Kobernulf Monnur'
        position = 1
        best_lap = 42.0

        mock_driver.laps_complete = 6
        mock_driver.race_time = 42.00
        mock_driver.stops = 0
        mock_classification_entry.driver = mock_driver
        instance = RaceResults([mock_classification_entry])
        expected_result = '0'
        self.assertEqual(
            instance.calc_points((driver_name, position, best_lap)),
            expected_result)
Example #2
0
 def test_init_no_config(self, mock_classification_entry, mock_driver):
     mock_driver.laps_complete = 6
     mock_driver.race_time = 42.00
     mock_driver.stops = 0
     mock_classification_entry.driver = mock_driver
     instance = RaceResults([mock_classification_entry])
     expected_result = RaceResults
     self.assertIsInstance(instance, expected_result)
Example #3
0
    def test_method_calc_points_not_best_lap(self, mock_classification_entry,
                                             mock_driver):
        driver_name = 'Kobernulf Monnur'
        position = 1
        best_lap = 56.0

        configuration = {'point_structure': [5, 15, 12, 10, 8, 6, 4, 2, 1]}
        type(mock_classification_entry).best_lap = PropertyMock(
            return_value=42.0)

        mock_driver.laps_complete = 6
        mock_driver.race_time = 42.00
        mock_driver.stops = 0
        mock_classification_entry.driver = mock_driver

        instance = RaceResults([mock_classification_entry], **configuration)
        expected_result = '15'
        self.assertEqual(
            instance.calc_points((driver_name, position, best_lap),
                                 **configuration), expected_result)
Example #4
0
 def test_init_config(self, mock_classification_entry, mock_driver):
     configuration = {
         'participant_config': {
             'Kobernulf Monnur': {
                 'display': 'Senor Pez',
                 'car': '125cc Shifter Kart',
                 'team': 'DarkNitro',
             }
         },
         'point_structure': [5, 15, 12, 10, 8, 6, 4, 2, 1]
     }
     mock_driver.laps_complete = 6
     mock_driver.race_time = 42.00
     mock_driver.stops = 0
     mock_classification_entry.driver = mock_driver
     instance = RaceResults([mock_classification_entry], **configuration)
     expected_result = RaceResults
     self.assertIsInstance(instance, expected_result)
Example #5
0
 def test_method_format_time_passed_none(self):
     time = None
     expected_result = ""
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #6
0
 def test_method_format_time_passed_string(self):
     time = "ERROR"
     expected_result = ""
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #7
0
 def test_method_format_time_truncate(self):
     time = 3702.1234
     expected_result = '1:01:42.123'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #8
0
 def test_method_format_time_round(self):
     time = 3702.9876
     expected_result = '1:01:42.988'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #9
0
 def test_method_format_time_below_hour_round(self):
     time = 84.9876
     expected_result = '1:24.988'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #10
0
 def test_method_format_time(self):
     time = 3702
     expected_result = '1:01:42.000'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #11
0
 def test_method_format_time_below_hour_truncate(self):
     time = 84.1234
     expected_result = '1:24.123'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #12
0
 def test_method_format_time_below_hour(self):
     time = 84
     expected_result = '1:24.000'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #13
0
 def test_method_format_time_below_min_round(self):
     time = 42.9876
     expected_result = '42.988'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #14
0
 def test_method_format_time_below_min_truncate(self):
     time = 42.1234
     expected_result = '42.123'
     self.assertEqual(RaceResults.format_time(time), expected_result)
Example #15
0
 def test_method_format_time_below_min(self):
     time = 42
     expected_result = '42.000'
     self.assertEqual(RaceResults.format_time(time), expected_result)